From ea16f82d200e5c3b8fd63be8131e7af1de6a8e67 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 12 May 2015 17:32:29 -0500 Subject: [PATCH] FS-7500: move img test down into read function --- src/switch_core_media.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index f1e31752a7..8818128af0 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -211,6 +211,8 @@ struct switch_media_handle_s { uint64_t vid_frames; time_t vid_started; + int ready_loops; + }; @@ -4779,7 +4781,6 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi switch_image_t *blank_img = NULL; switch_rgb_color_t bgcolor; switch_rtp_engine_t *v_engine = NULL; - int ready_loops = 0; const char *var; if (!(smh = session->media_handle)) { @@ -4883,12 +4884,6 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi if (switch_test_flag(read_frame, SFF_CNG)) { continue; } - - if (read_frame->img && read_frame->img->d_w && read_frame->img->d_h && ++ready_loops > 5) { - 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; - } } if (vloops < 300 && (vloops % 100) == 0) { @@ -10377,9 +10372,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core switch_status_t status = SWITCH_STATUS_FALSE; switch_io_event_hook_video_read_frame_t *ptr; uint32_t loops = 0; + switch_media_handle_t *smh; switch_assert(session != NULL); + if (!(smh = session->media_handle)) { + return SWITCH_STATUS_FALSE; + } + + top: loops++; @@ -10452,6 +10453,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core (*frame)->img->w, (*frame)->img->h, (*frame)->img->d_w, (*frame)->img->d_h); } + + if ((*frame)->img && (*frame)->img->d_w && (*frame)->img->d_h && ++smh->ready_loops > 5) { + switch_channel_set_flag(session->channel, CF_VIDEO_READY); + smh->vid_params.width = (*frame)->img->d_w; + smh->vid_params.height = (*frame)->img->d_h; + } + if (switch_test_flag((*frame), SFF_WAIT_KEY_FRAME)) { switch_core_session_request_video_refresh(session); switch_clear_flag((*frame), SFF_WAIT_KEY_FRAME);