From 84ca5133537cdcb50be4e983bfce9b2dc74ffc67 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 27 Mar 2015 14:02:07 -0500 Subject: [PATCH] FS-7500: fix some regressions regarding passthru video --- src/switch_channel.c | 7 +++++-- src/switch_core_media.c | 14 ++++++++------ src/switch_ivr_bridge.c | 2 -- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index 10a2af61ec..41f4ca1c99 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1966,8 +1966,11 @@ SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch ACTIVE = 1; } - if (flag == CF_VIDEO_PASSIVE && channel->flags[flag]) { - CLEAR = 1; + if (flag == CF_VIDEO_PASSIVE) { + channel->flags[CF_VIDEO_READY] = 1; + if (channel->flags[flag]) { + CLEAR = 1; + } } channel->flags[flag] = 0; diff --git a/src/switch_core_media.c b/src/switch_core_media.c index a043fb9e55..a80472a81b 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -4698,6 +4698,10 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi xloops = 0; } + if (!switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ) && (xloops > 20 || switch_channel_test_flag(channel, CF_VIDEO_PASSIVE))) { + switch_channel_set_flag(channel, CF_VIDEO_READY); + } + if (switch_channel_test_flag(channel, CF_VIDEO_PASSIVE) || do_sleep) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread paused. Echo is %s\n", switch_channel_get_name(session->channel), switch_channel_test_flag(channel, CF_VIDEO_ECHO) ? "on" : "off"); @@ -4742,24 +4746,22 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi if (!smh->video_write_fh || !switch_channel_test_flag(channel, CF_VIDEO_READY)) { status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - + if (!SWITCH_READ_ACCEPTABLE(status)) { switch_cond_next(); continue; } - + if (switch_test_flag(read_frame, SFF_CNG)) { continue; } - + if (read_frame->img) { if (++viloops > 10) { switch_channel_set_flag(channel, CF_VIDEO_READY); smh->vid_params.width = read_frame->img->d_w; smh->vid_params.height = read_frame->img->d_h; } - } else if (read_frame->datalen > 2 && !switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ) && vloops > 20) { - switch_channel_set_flag(channel, CF_VIDEO_READY); } } @@ -4770,7 +4772,7 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi vloops++; - if (!buf) { + if (!buf && switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) { int buflen = SWITCH_RECOMMENDED_BUFFER_SIZE * 4; buf = switch_core_session_alloc(session, buflen); fr.packet = buf; diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 22bf827f26..68b1efd300 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -63,7 +63,6 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj) switch_core_session_request_video_refresh(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); @@ -92,7 +91,6 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj) continue; } } - } switch_core_session_kill_channel(vh->session_b, SWITCH_SIG_BREAK);