FS-9610 #resolve [Video keyframe requests not being propagated properly] %backport=1.6

This commit is contained in:
Anthony Minessale 2016-10-04 22:34:39 -05:00
parent 15a232b5bb
commit 2a3b8a230c
3 changed files with 18 additions and 28 deletions

View File

@ -5705,8 +5705,11 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
end: end:
switch_core_session_request_video_refresh(session);
if (b_session) { if (b_session) {
switch_core_session_request_video_refresh(b_session);
switch_core_session_rwunlock(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; frame_ms = (uint32_t) 1000 / fps;
frames = (uint32_t) ms / frame_ms; frames = (uint32_t) ms / frame_ms;
switch_core_media_gen_key_frame(session); switch_core_media_gen_key_frame(session);
for (i = 0; i < frames; i++) { for (i = 0; i < frames; i++) {
fr.img = blank_img;
switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0); switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, 0);
switch_yield(frame_ms * 1000); 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_media_gen_key_frame(session);
switch_core_session_request_video_refresh(session);
if (fh) { if (fh) {
switch_threadattr_t *thd_attr = NULL; 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_create(&thd_attr, switch_core_session_get_pool(session));
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
smh->video_write_thread_running = 1; 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_thread_join(&st, smh->video_write_thread);
switch_mutex_lock(v_engine->mh.file_write_mutex); switch_mutex_lock(v_engine->mh.file_write_mutex);
smh->video_write_thread = NULL; 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; 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 (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); return switch_core_codec_control(codec, cmd, ctype, cmd_data, atype, cmd_arg, rtype, ret_data);
} }

View File

@ -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)) { if (switch_channel_test_flag(channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(channel, CF_VIDEO_REFRESH_REQ);
refresh_timer = refresh_cnt; 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) {
if (refresh_timer > 0 && (refresh_timer % 100) == 0) { 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_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--; refresh_timer--;
} }
@ -140,20 +138,12 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
switch_cond_next(); switch_cond_next();
continue; 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)) { if (switch_test_flag(read_frame, SFF_CNG) ||
switch_channel_video_sync(channel); switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) {
switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
continue; continue;
} }
if (switch_channel_media_up(b_channel)) { 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) { if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {

View File

@ -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)) { 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; 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", if (extp->header.fmt != 15) { // <---- REMOVE WHEN BRIA STOPS SENDING UNSOLICITED REMB
rtp_type(rtp_session), msg->header.type, extp->header.fmt); 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)) { 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); switch_core_media_gen_key_frame(rtp_session->session);
if (rtp_session->vbw) { if (rtp_session->vbw) {
switch_jb_reset(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) { if (msg->header.type == _RTCP_PT_RTPFB && extp->header.fmt == _RTCP_RTPFB_NACK) {