From 4e085205d2139f1583c61cb15cca8a8d2875a05f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 10 Sep 2012 12:58:06 -0500 Subject: [PATCH] video tweaks for echo app --- src/switch_ivr_async.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 4ab523a3a5..03f9839f78 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -580,11 +580,24 @@ static void *SWITCH_THREAD_FUNC echo_video_thread(switch_thread_t *thread, void switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status; switch_frame_t *read_frame; + switch_core_session_message_t msg = { 0 }; + + + msg.from = __FILE__; + msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ; + + switch_core_session_receive_message(session, &msg); eh->up = 1; while (switch_channel_ready(channel)) { status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); + + if (switch_channel_test_flag(channel, CF_VIDEO_REFRESH_REQ)) { + switch_core_session_receive_message(session, &msg); + switch_channel_clear_flag(channel, CF_VIDEO_REFRESH_REQ); + } + if (!SWITCH_READ_ACCEPTABLE(status)) { break; } @@ -606,6 +619,8 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session, swi switch_status_t status; switch_frame_t *read_frame; switch_channel_t *channel = switch_core_session_get_channel(session); + int orig_vid = switch_channel_test_flag(channel, CF_VIDEO); + #ifdef SWITCH_VIDEO_IN_THREADS struct echo_helper eh = { 0 }; switch_thread_t *thread; @@ -615,6 +630,9 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session, swi if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { return; } + + restart: + #ifdef SWITCH_VIDEO_IN_THREADS if (switch_channel_test_flag(channel, CF_VIDEO)) { eh.session = session; @@ -630,6 +648,12 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session, swi if (!SWITCH_READ_ACCEPTABLE(status)) { break; } + + if (!orig_vid && switch_channel_test_flag(channel, CF_VIDEO)) { + orig_vid = 1; + goto restart; + } + switch_ivr_parse_all_events(session);