|
|
|
@ -49,7 +49,7 @@ static uint8_t *wait_event(uint64_t id, int kind, size_t *size) { |
|
|
|
static void *producer(void *arg) { |
|
|
|
static void *producer(void *arg) { |
|
|
|
(void)arg; |
|
|
|
(void)arg; |
|
|
|
__atomic_store_n(&producer_started, 1, __ATOMIC_RELEASE); |
|
|
|
__atomic_store_n(&producer_started, 1, __ATOMIC_RELEASE); |
|
|
|
uint64_t pts = 500000; |
|
|
|
uint64_t pts = 1000000; |
|
|
|
while (!__atomic_load_n(&producer_stop, __ATOMIC_ACQUIRE)) { |
|
|
|
while (!__atomic_load_n(&producer_stop, __ATOMIC_ACQUIRE)) { |
|
|
|
int result = feed(3, 1, pts++, 1, video, sizeof(video)); |
|
|
|
int result = feed(3, 1, pts++, 1, video, sizeof(video)); |
|
|
|
if (result < 0) break; |
|
|
|
if (result < 0) break; |
|
|
|
@ -103,19 +103,22 @@ int main(void) { |
|
|
|
/* Commit новой revision удаляет старое видео, сохраняет аудио/epoch и не требует нового owner. */ |
|
|
|
/* Commit новой revision удаляет старое видео, сохраняет аудио/epoch и не требует нового owner. */ |
|
|
|
CHECK(feed(1, 1, 200000, 0, video, sizeof(video)) == 1); |
|
|
|
CHECK(feed(1, 1, 200000, 0, video, sizeof(video)) == 1); |
|
|
|
CHECK(feed(1, 0, 120000, 0, (const uint8_t *)"ops", 3) == 1); |
|
|
|
CHECK(feed(1, 0, 120000, 0, (const uint8_t *)"ops", 3) == 1); |
|
|
|
struct stream_media_format next_format = {1920, 1080, 270, STREAM_MEDIA_H264, STREAM_MEDIA_OPUS_STEREO, 2}; |
|
|
|
struct stream_media_format next_format = {1920, 1080, 270, STREAM_MEDIA_H265, STREAM_MEDIA_OPUS_STEREO, 2}; |
|
|
|
CHECK(android_stream_feed(1, 1, 300000, 0, video, sizeof(video), &next_format) == 0); |
|
|
|
CHECK(android_stream_feed(1, 1, 300000, 0, video, sizeof(video), &next_format) == 0); |
|
|
|
CHECK(android_stream_feed(1, 1, 300000, 1, video, sizeof(video), &next_format) == 1); |
|
|
|
CHECK(android_stream_feed(1, 1, 300000, 1, video, sizeof(video), &next_format) == 1); |
|
|
|
CHECK(feed(1, 1, 350000, 1, video, sizeof(video)) == 0); |
|
|
|
CHECK(feed(1, 1, 350000, 1, video, sizeof(video)) == 0); |
|
|
|
next_format.width++; |
|
|
|
next_format.width++; |
|
|
|
CHECK(android_stream_feed(1, 1, 400000, 1, video, sizeof(video), &next_format) == -1); |
|
|
|
CHECK(android_stream_feed(1, 1, 400000, 1, video, sizeof(video), &next_format) == -1); |
|
|
|
next_format.width--; |
|
|
|
next_format.width--; |
|
|
|
|
|
|
|
next_format.video_codec = STREAM_MEDIA_VP9; |
|
|
|
|
|
|
|
CHECK(android_stream_feed(1, 1, 400000, 1, video, sizeof(video), &next_format) == -1); |
|
|
|
|
|
|
|
next_format.video_codec = STREAM_MEDIA_H265; |
|
|
|
video_seen = audio_seen = 0; |
|
|
|
video_seen = audio_seen = 0; |
|
|
|
for (unsigned i = 0; i < 1000 && (!video_seen || !audio_seen); i++) { |
|
|
|
for (unsigned i = 0; i < 1000 && (!video_seen || !audio_seen); i++) { |
|
|
|
CHECK(android_stream_read_request(2, 300000, 80000, 80000) == 0); |
|
|
|
CHECK(android_stream_read_request(2, 300000, 80000, 80000) == 0); |
|
|
|
output = android_stream_pull(2, &size); |
|
|
|
output = android_stream_pull(2, &size); |
|
|
|
if (output && output[0] == 1) { |
|
|
|
if (output && output[0] == 1) { |
|
|
|
CHECK(stream_read_be(output + 8, 8) == 300000 && stream_read_be(output + 20, 4) == 2); |
|
|
|
CHECK(stream_read_be(output + 8, 8) == 300000 && stream_read_be(output + 20, 4) == 2 && output[24] == STREAM_MEDIA_H265); |
|
|
|
CHECK(stream_read_be(output + 2, 2) == 1920 && stream_read_be(output + 6, 2) == 270); video_seen++; |
|
|
|
CHECK(stream_read_be(output + 2, 2) == 1920 && stream_read_be(output + 6, 2) == 270); video_seen++; |
|
|
|
} else if (output && output[0] == 2) { CHECK(stream_read_be(output + 8, 8) == 120000); audio_seen++; } |
|
|
|
} else if (output && output[0] == 2) { CHECK(stream_read_be(output + 8, 8) == 120000); audio_seen++; } |
|
|
|
else if (output) CHECK(output[0] != 6); |
|
|
|
else if (output) CHECK(output[0] != 6); |
|
|
|
@ -152,6 +155,12 @@ int main(void) { |
|
|
|
CHECK(!strcmp(source_snapshot, "[]")); |
|
|
|
CHECK(!strcmp(source_snapshot, "[]")); |
|
|
|
current_format.rotation = 0; current_format.audio_codec = 0; |
|
|
|
current_format.rotation = 0; current_format.audio_codec = 0; |
|
|
|
CHECK(android_stream_open(3, group, 0, 1280, 720, 0, 0, 0, STREAM_MEDIA_H264) == 0); u_free(wait_event(3, 4, &size)); |
|
|
|
CHECK(android_stream_open(3, group, 0, 1280, 720, 0, 0, 0, STREAM_MEDIA_H264) == 0); u_free(wait_event(3, 4, &size)); |
|
|
|
|
|
|
|
uint8_t *large = u_malloc(500000); CHECK(large); memset(large, 1, 500000); |
|
|
|
|
|
|
|
CHECK(feed(3, 1, 500000, 1, large, 500000) == 1); u_free(large); |
|
|
|
|
|
|
|
test_clock_run_for(ua, 1000); |
|
|
|
|
|
|
|
struct android_stream_tx_stats stats; |
|
|
|
|
|
|
|
CHECK(android_stream_tx_snapshot(3, &stats) == 0 && stats.video_bytes > 0 && stats.video_bytes < 500000); |
|
|
|
|
|
|
|
CHECK(stats.total_bytes == stats.video_bytes && !stats.acked_1s && !stats.connections); |
|
|
|
pthread_t thread; CHECK(pthread_create(&thread, NULL, producer, NULL) == 0); |
|
|
|
pthread_t thread; CHECK(pthread_create(&thread, NULL, producer, NULL) == 0); |
|
|
|
while (!__atomic_load_n(&producer_started, __ATOMIC_ACQUIRE)) {} |
|
|
|
while (!__atomic_load_n(&producer_started, __ATOMIC_ACQUIRE)) {} |
|
|
|
android_stream_detach(inst); |
|
|
|
android_stream_detach(inst); |
|
|
|
|