|
|
|
@ -7,7 +7,6 @@ |
|
|
|
#include "../../../src/utun_instance.h" |
|
|
|
#include "../../../src/utun_instance.h" |
|
|
|
#include "../../../src/chat/chat_core.h" |
|
|
|
#include "../../../src/chat/chat_core.h" |
|
|
|
#include "../../../src/stream/stream.h" |
|
|
|
#include "../../../src/stream/stream.h" |
|
|
|
#include "../../../src/stream/stream_member.h" |
|
|
|
|
|
|
|
#include "../../../src/stream/stream_media.h" |
|
|
|
#include "../../../src/stream/stream_media.h" |
|
|
|
#include "../../../src/stream/stream_network.h" |
|
|
|
#include "../../../src/stream/stream_network.h" |
|
|
|
#include "../../../src/stream/stream_publisher.h" |
|
|
|
#include "../../../src/stream/stream_publisher.h" |
|
|
|
@ -172,48 +171,24 @@ static void media_process(void *arg) { |
|
|
|
if (stream_watch_sources(media_inst, watch_group) != STREAM_OK) |
|
|
|
if (stream_watch_sources(media_inst, watch_group) != STREAM_OK) |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "Android stream source watch failed group=%llx", (unsigned long long)watch_group); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "Android stream source watch failed group=%llx", (unsigned long long)watch_group); |
|
|
|
} |
|
|
|
} |
|
|
|
struct android_media_session *sessions[] = {&viewer}; |
|
|
|
if (viewer.opening) { |
|
|
|
for (unsigned i = 0; i < 1; i++) { |
|
|
|
if (viewer.stopping) media_close(&viewer, 5); |
|
|
|
struct android_media_session *s = sessions[i]; |
|
|
|
else { |
|
|
|
if (s->opening) { |
|
|
|
viewer.opening = 0; |
|
|
|
if (s->stopping) { media_close(s, 5); continue; } |
|
|
|
int result = stream_media_open(media_inst, viewer.group, viewer.source, viewer.expected_epoch, |
|
|
|
s->opening = 0; |
|
|
|
STREAM_MEDIA_TRACK_VIDEO | (viewer.listen_audio ? STREAM_MEDIA_TRACK_AUDIO : 0), &viewer.handle); |
|
|
|
int result = STREAM_OK; |
|
|
|
viewer.reason = result == STREAM_ERR_CONFLICT ? STREAM_CLOSE_SOURCE_CHANGED : STREAM_CLOSE_FAILED; |
|
|
|
s->reason = STREAM_CLOSE_FAILED; |
|
|
|
|
|
|
|
if (s->source && s->expected_epoch) { |
|
|
|
|
|
|
|
struct stream_member_state state; |
|
|
|
|
|
|
|
result = stream_member_load(media_inst, s->group, s->source, &state, NULL); |
|
|
|
|
|
|
|
if (result == STREAM_OK && (!state.published || state.source.source_epoch != s->expected_epoch)) { |
|
|
|
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "Android selected source changed group=%llx source=%llx expected=%llx actual=%llx", |
|
|
|
|
|
|
|
(unsigned long long)s->group, (unsigned long long)s->source, (unsigned long long)s->expected_epoch, |
|
|
|
|
|
|
|
(unsigned long long)(state.published ? state.source.source_epoch : 0)); |
|
|
|
|
|
|
|
result = STREAM_ERR_CONFLICT; s->reason = STREAM_CLOSE_SOURCE_CHANGED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (result == STREAM_OK) result = s->source ? stream_subscribe_open(media_inst, s->group, s->source, &s->handle) |
|
|
|
|
|
|
|
: stream_publish_open(media_inst, s->group, NULL, &s->handle); |
|
|
|
|
|
|
|
if (result == STREAM_OK) result = stream_media_enable(s->handle, |
|
|
|
|
|
|
|
s->source ? STREAM_MEDIA_TRACK_VIDEO | (s->listen_audio ? STREAM_MEDIA_TRACK_AUDIO : 0) : 0); |
|
|
|
|
|
|
|
struct stream_info info; |
|
|
|
|
|
|
|
if (result == STREAM_OK) { |
|
|
|
|
|
|
|
result = stream_get_info(s->handle, &info); |
|
|
|
|
|
|
|
if (result == STREAM_OK) { |
|
|
|
|
|
|
|
s->epoch = info.descriptor.source_epoch; |
|
|
|
|
|
|
|
if (s->expected_epoch && s->epoch != s->expected_epoch) { |
|
|
|
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "Android viewer opened stale epoch id=%llu", (unsigned long long)s->id); |
|
|
|
|
|
|
|
result = STREAM_ERR_CONFLICT; s->reason = STREAM_CLOSE_SOURCE_CHANGED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (result != STREAM_OK) { |
|
|
|
if (result != STREAM_OK) { |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "Android stream open failed id=%llu group=%llx source=%llx result=%d", |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "Android stream open failed id=%llu group=%llx source=%llx result=%d", |
|
|
|
(unsigned long long)s->id, (unsigned long long)s->group, (unsigned long long)s->source, result); |
|
|
|
(unsigned long long)viewer.id, (unsigned long long)viewer.group, (unsigned long long)viewer.source, result); |
|
|
|
media_close(s, 6); |
|
|
|
media_close(&viewer, 6); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (s->source) { viewer_status_id = s->id; memset(&viewer_status, 0, sizeof(viewer_status)); } |
|
|
|
viewer.epoch = viewer.expected_epoch; |
|
|
|
media_output(s->id, 4, NULL, 0, 0, NULL, 0); |
|
|
|
viewer_status_id = viewer.id; memset(&viewer_status, 0, sizeof(viewer_status)); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "Android stream opened id=%llu publisher=%d group=%llx source=%llx", |
|
|
|
media_output(viewer.id, 4, NULL, 0, 0, NULL, 0); |
|
|
|
(unsigned long long)s->id, !s->source, (unsigned long long)s->group, (unsigned long long)s->source); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "Android viewer opened id=%llu group=%llx source=%llx epoch=%llx", |
|
|
|
|
|
|
|
(unsigned long long)viewer.id, (unsigned long long)viewer.group, |
|
|
|
|
|
|
|
(unsigned long long)viewer.source, (unsigned long long)viewer.epoch); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|