mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-11 03:57:14 +00:00
FS-7500: another refactoring pass, temp code still in place, WORK IN PROGRESS
This commit is contained in:
1 parent
258dacc742
commit
0cd5658caa
16 files changed
+482
-485
No files matched your search
+33
-27
@@ -46,38 +46,47 @@ struct vid_helper {
|
||||
int up;
|
||||
};
|
||||
|
||||
static void *SWITCH_THREAD_FUNC video_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
static void video_bridge_thread(switch_core_session_t *session, void *obj)
|
||||
{
|
||||
struct vid_helper *vh = obj;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(vh->session_a);
|
||||
switch_channel_t *b_channel = switch_core_session_get_channel(vh->session_b);
|
||||
switch_status_t status;
|
||||
switch_frame_t *read_frame = 0;
|
||||
const char *source = switch_channel_get_variable(channel, "source");
|
||||
const char *b_source = switch_channel_get_variable(b_channel, "source");
|
||||
|
||||
vh->up = 1;
|
||||
|
||||
switch_core_session_read_lock(vh->session_a);
|
||||
switch_core_session_read_lock(vh->session_b);
|
||||
|
||||
if (!switch_stristr("loopback", source) && !switch_stristr("loopback", b_source)) {
|
||||
switch_channel_set_flag(channel, CF_VIDEO_PASSIVE);
|
||||
//switch_channel_set_flag(b_channel, CF_VIDEO_PASSIVE);
|
||||
}
|
||||
|
||||
switch_core_session_refresh_video(vh->session_a);
|
||||
switch_core_session_refresh_video(vh->session_b);
|
||||
|
||||
while (switch_channel_up_nosig(channel) && switch_channel_up_nosig(b_channel) && vh->up == 1) {
|
||||
|
||||
if (switch_channel_media_up(channel)) {
|
||||
switch_codec_t *a_codec = switch_core_session_get_video_read_codec(vh->session_a);
|
||||
switch_codec_t *b_codec = switch_core_session_get_video_write_codec(vh->session_b);
|
||||
|
||||
if (!b_codec || !a_codec || a_codec->implementation->impl_id == b_codec->implementation->impl_id) {
|
||||
//switch_channel_clear_flag(channel, CF_VIDEO_DECODED_READ);
|
||||
} else {
|
||||
//switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
|
||||
}
|
||||
|
||||
switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
|
||||
|
||||
status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
switch_cond_next();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!switch_test_flag(read_frame, SFF_CNG)) {
|
||||
switch_core_session_write_video_frame(vh->session_a, read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
@@ -93,9 +102,6 @@ static void *SWITCH_THREAD_FUNC video_bridge_thread(switch_thread_t *thread, voi
|
||||
|
||||
}
|
||||
|
||||
switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE);
|
||||
//switch_channel_clear_flag(b_channel, CF_VIDEO_PASSIVE);
|
||||
|
||||
switch_core_session_kill_channel(vh->session_b, SWITCH_SIG_BREAK);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(vh->session_a), SWITCH_LOG_DEBUG, "%s video thread ended.\n", switch_channel_get_name(channel));
|
||||
|
||||
@@ -106,18 +112,12 @@ static void *SWITCH_THREAD_FUNC video_bridge_thread(switch_thread_t *thread, voi
|
||||
switch_core_session_rwunlock(vh->session_b);
|
||||
|
||||
vh->up = 0;
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
static switch_thread_t *launch_video(struct vid_helper *vh)
|
||||
static void launch_video(struct vid_helper *vh)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
|
||||
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(vh->session_a));
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, video_bridge_thread, vh, switch_core_session_get_pool(vh->session_a));
|
||||
return thread;
|
||||
switch_core_media_start_video_function(vh->session_a, video_bridge_thread, vh);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -229,7 +229,6 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
const char *exec_data = NULL;
|
||||
|
||||
#ifdef SWITCH_VIDEO_IN_THREADS
|
||||
switch_thread_t *vid_thread = NULL;
|
||||
struct vid_helper vh = { 0 };
|
||||
uint32_t vid_launch = 0;
|
||||
#endif
|
||||
@@ -246,6 +245,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
|
||||
chan_a = switch_core_session_get_channel(session_a);
|
||||
chan_b = switch_core_session_get_channel(session_b);
|
||||
|
||||
switch_channel_clear_flag(chan_a, CF_VIDEO_ECHO);
|
||||
switch_channel_clear_flag(chan_b, CF_VIDEO_ECHO);
|
||||
|
||||
|
||||
if ((exec_app = switch_channel_get_variable(chan_a, "bridge_pre_execute_app"))) {
|
||||
@@ -410,7 +412,10 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
vid_launch++;
|
||||
vh.session_a = session_a;
|
||||
vh.session_b = session_b;
|
||||
vid_thread = launch_video(&vh);
|
||||
//DFF TEMP
|
||||
if (switch_channel_test_flag(chan_a, CF_BRIDGE_ORIGINATOR)) {
|
||||
launch_video(&vh);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -590,7 +595,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
end_of_bridge_loop:
|
||||
|
||||
#ifdef SWITCH_VIDEO_IN_THREADS
|
||||
if (vid_thread) {
|
||||
if (vh.up > 0) {
|
||||
vh.up = -1;
|
||||
switch_channel_set_flag(chan_a, CF_NOT_READY);
|
||||
//switch_channel_set_flag(chan_b, CF_NOT_READY);
|
||||
@@ -634,9 +639,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
end:
|
||||
|
||||
#ifdef SWITCH_VIDEO_IN_THREADS
|
||||
if (vid_thread) {
|
||||
switch_status_t st;
|
||||
|
||||
if (switch_core_media_check_video_function(session_a)) {
|
||||
if (vh.up == 1) {
|
||||
vh.up = -1;
|
||||
}
|
||||
@@ -647,7 +650,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "Ending video thread.\n");
|
||||
switch_thread_join(&st, vid_thread);
|
||||
switch_core_media_end_video_function(session_a);
|
||||
switch_channel_clear_flag(chan_a, CF_NOT_READY);
|
||||
switch_channel_clear_flag(chan_b, CF_NOT_READY);
|
||||
}
|
||||
@@ -689,6 +692,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
|
||||
switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
|
||||
data->done = 1;
|
||||
switch_core_session_video_reset(session_a);
|
||||
switch_core_session_video_reset(session_b);
|
||||
|
||||
switch_core_session_rwunlock(session_b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user