From 2a3b8a230c66ff1cdd8cd0262de43d57530691db Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 4 Oct 2016 22:34:39 -0500 Subject: [PATCH] FS-9610 #resolve [Video keyframe requests not being propagated properly] %backport=1.6 --- src/switch_core_media.c | 22 +++++++++------------- src/switch_ivr_bridge.c | 16 +++------------- src/switch_rtp.c | 8 ++++++-- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 33b85a11b9..4410a41b87 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -5705,8 +5705,11 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session end: + switch_core_session_request_video_refresh(session); + if (b_session) { + switch_core_session_request_video_refresh(b_session); switch_core_session_rwunlock(b_session); } @@ -5792,8 +5795,11 @@ static void switch_core_session_write_blank_video(switch_core_session_t *session frame_ms = (uint32_t) 1000 / fps; frames = (uint32_t) ms / frame_ms; + + switch_core_media_gen_key_frame(session); for (i = 0; i < frames; i++) { + fr.img = blank_img; switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0); switch_yield(frame_ms * 1000); } @@ -6025,10 +6031,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses } switch_core_media_gen_key_frame(session); + switch_core_session_request_video_refresh(session); if (fh) { switch_threadattr_t *thd_attr = NULL; - switch_core_session_write_blank_video(session, 200); + switch_core_session_write_blank_video(session, 500); switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session)); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); smh->video_write_thread_running = 1; @@ -6045,7 +6052,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses switch_thread_join(&st, smh->video_write_thread); switch_mutex_lock(v_engine->mh.file_write_mutex); smh->video_write_thread = NULL; - switch_core_session_write_blank_video(session, 200); + switch_core_session_write_blank_video(session, 500); } smh->video_write_fh = fh; @@ -12867,17 +12874,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_sess } if (codec) { - if (cmd == SCC_VIDEO_GEN_KEYFRAME) { - switch_time_t now = switch_micro_time_now(); - - if (smh->last_codec_refresh && (now - smh->last_codec_refresh) < VIDEO_REFRESH_FREQ) { - return SWITCH_STATUS_BREAK; - } - - smh->last_codec_refresh = now; - switch_channel_set_flag(session->channel, CF_VIDEO_REFRESH_REQ); - } - return switch_core_codec_control(codec, cmd, ctype, cmd_data, atype, cmd_arg, rtype, ret_data); } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 0dd824dc01..4030233f62 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -99,6 +99,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj) if (switch_channel_test_flag(channel, CF_VIDEO_REFRESH_REQ)) { + switch_channel_clear_flag(channel, CF_VIDEO_REFRESH_REQ); refresh_timer = refresh_cnt; } @@ -126,10 +127,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj) if (refresh_timer) { if (refresh_timer > 0 && (refresh_timer % 100) == 0) { - switch_core_session_request_video_refresh(vh->session_a); switch_core_session_request_video_refresh(vh->session_b); - switch_core_media_gen_key_frame(vh->session_a); - switch_core_media_gen_key_frame(vh->session_b); } refresh_timer--; } @@ -140,20 +138,12 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj) switch_cond_next(); continue; } - - - if (switch_test_flag(read_frame, SFF_CNG)) { - switch_core_session_request_video_refresh(vh->session_a); - continue; - } } - if (switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) { - switch_channel_video_sync(channel); - switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0); + if (switch_test_flag(read_frame, SFF_CNG) || + switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) { continue; } - if (switch_channel_media_up(b_channel)) { if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index b411c16b22..7620d2dac0 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -5942,14 +5942,18 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && (msg->header.type == _RTCP_PT_RTPFB || msg->header.type == _RTCP_PT_PSFB)) { rtcp_ext_msg_t *extp = (rtcp_ext_msg_t *) msg; - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "PICKED UP %s XRTCP type: %d fmt: %d\n", - rtp_type(rtp_session), msg->header.type, extp->header.fmt); + if (extp->header.fmt != 15) { // <---- REMOVE WHEN BRIA STOPS SENDING UNSOLICITED REMB + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "PICKED UP %s XRTCP type: %d fmt: %d\n", + rtp_type(rtp_session), msg->header.type, extp->header.fmt); + } if (msg->header.type == _RTCP_PT_PSFB && (extp->header.fmt == _RTCP_PSFB_FIR || extp->header.fmt == _RTCP_PSFB_PLI)) { switch_core_media_gen_key_frame(rtp_session->session); if (rtp_session->vbw) { switch_jb_reset(rtp_session->vbw); } + + switch_channel_set_flag(switch_core_session_get_channel(rtp_session->session), CF_VIDEO_REFRESH_REQ); } if (msg->header.type == _RTCP_PT_RTPFB && extp->header.fmt == _RTCP_RTPFB_NACK) {