|
|
|
|
@ -39,7 +39,7 @@ static void chat_event(struct UTUN_INSTANCE *inst, int type, const uint8_t *data
|
|
|
|
|
|
|
|
|
|
static uint8_t *wait_event(uint64_t id, int kind, size_t *size) { |
|
|
|
|
for (unsigned i = 0; i < 1000; i++) { |
|
|
|
|
if (id == 2 && kind == 5) CHECK(android_stream_read_request(id, 1000000, 80000, 80000) == 0); |
|
|
|
|
if (id == 2) CHECK(android_stream_read_request(id, kind == 5 ? 1000000 : -1, 1, 80000) == 0); |
|
|
|
|
uint8_t *data = android_stream_pull(id, size); |
|
|
|
|
if (data && data[0] == kind) return data; |
|
|
|
|
u_free(data); test_clock_poll(ua, 100); |
|
|
|
|
@ -91,7 +91,7 @@ int main(void) {
|
|
|
|
|
CHECK(feed(1, 0, 100000, 0, (const uint8_t *)"ops", 3) == 1); |
|
|
|
|
uint8_t *output = NULL; int video_seen = 0, audio_seen = 0; |
|
|
|
|
for (unsigned i = 0; i < 1000 && (!video_seen || !audio_seen); i++) { |
|
|
|
|
CHECK(android_stream_read_request(2, 100000, 80000, 80000) == 0); |
|
|
|
|
CHECK(android_stream_read_request(2, 100000, 1, 80000) == 0); |
|
|
|
|
output = android_stream_pull(2, &size); |
|
|
|
|
if (output && output[0] == 1) { |
|
|
|
|
CHECK(size == sizeof(video) + ANDROID_STREAM_HEADER_SIZE && stream_read_be(output + 8, 8) == 100000 && !memcmp(output + ANDROID_STREAM_HEADER_SIZE, video, sizeof(video))); |
|
|
|
|
@ -115,7 +115,7 @@ int main(void) {
|
|
|
|
|
next_format.video_codec = STREAM_MEDIA_H265; |
|
|
|
|
video_seen = audio_seen = 0; |
|
|
|
|
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, 1, 80000) == 0); |
|
|
|
|
output = android_stream_pull(2, &size); |
|
|
|
|
if (output && output[0] == 1) { |
|
|
|
|
CHECK(stream_read_be(output + 8, 8) == 300000 && stream_read_be(output + 20, 4) == 2 && output[24] == STREAM_MEDIA_H265); |
|
|
|
|
@ -135,7 +135,7 @@ int main(void) {
|
|
|
|
|
CHECK(feed(1, 0, audio_pts, 0, (const uint8_t *)"ops", 3) == 1); |
|
|
|
|
video_seen = audio_seen = 0; |
|
|
|
|
for (unsigned i = 0; i < 1000 && (!video_seen || !audio_seen); i++) { |
|
|
|
|
CHECK(android_stream_read_request(2, (int64_t)video_pts, 80000, 80000) == 0); |
|
|
|
|
CHECK(android_stream_read_request(2, (int64_t)video_pts, 1, 80000) == 0); |
|
|
|
|
output = android_stream_pull(2, &size); |
|
|
|
|
if (output && output[0] == 1) { |
|
|
|
|
CHECK(stream_read_be(output + 8, 8) == video_pts && stream_read_be(output + 20, 4) == next_format.revision); |
|
|
|
|
@ -150,6 +150,21 @@ int main(void) {
|
|
|
|
|
struct stream_member_state after_switch; |
|
|
|
|
CHECK(stream_member_load(inst, group, inst->node_id, &after_switch, NULL) == STREAM_OK); |
|
|
|
|
CHECK(after_switch.published && after_switch.source.source_epoch == member.source.source_epoch); |
|
|
|
|
/* Повторные запросы готовят один ответ; получение ответа не создаёт скрытую следующую копию. */ |
|
|
|
|
for (unsigned i = 0; i < 5; i++) |
|
|
|
|
CHECK(android_stream_feed(1, 1, 800000 + i * 40000, 0, video, sizeof(video), &next_format) == 1); |
|
|
|
|
for (unsigned i = 0; i < 50; i++) { CHECK(android_stream_read_request(2, 700000, 1, -1) == 0); test_clock_poll(ua, 100); } |
|
|
|
|
output = android_stream_pull(2, &size); CHECK(output && output[0] == 1 && stream_read_be(output + 8, 8) == 800000); u_free(output); |
|
|
|
|
test_clock_run_for(ua, 1000); CHECK(!android_stream_pull(2, &size)); |
|
|
|
|
CHECK(android_stream_read_request(2, 700000, 0, -1) == 0); test_clock_run_for(ua, 1000); |
|
|
|
|
CHECK(!android_stream_pull(2, &size)); |
|
|
|
|
for (unsigned frame = 1; frame < 5; frame++) { |
|
|
|
|
output = NULL; |
|
|
|
|
for (unsigned i = 0; i < 1000 && !output; i++) { |
|
|
|
|
CHECK(android_stream_read_request(2, 700000, 1, -1) == 0); test_clock_poll(ua, 100); output = android_stream_pull(2, &size); |
|
|
|
|
} |
|
|
|
|
CHECK(output && output[0] == 1 && stream_read_be(output + 8, 8) == 800000 + frame * 40000); u_free(output); |
|
|
|
|
} |
|
|
|
|
android_stream_stop(1); u_free(wait_event(2, 5, &size)); android_stream_stop(2); u_free(wait_event(1, 5, &size)); |
|
|
|
|
while ((output = android_stream_pull(2, &size))) u_free(output); |
|
|
|
|
CHECK(!strcmp(source_snapshot, "[]")); |
|
|
|
|
|