]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9610 #resolve [Video keyframe requests not being propagated properly] %backport=1.6
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 5 Oct 2016 03:34:39 +0000 (22:34 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 5 Oct 2016 03:34:47 +0000 (22:34 -0500)
src/switch_core_media.c
src/switch_ivr_bridge.c
src/switch_rtp.c

index 33b85a11b94a6e3f852ac7763f28689df80ea315..4410a41b87edce3fdd4d0629e98a9772e74edfed 100644 (file)
@@ -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);
        }
 
index 0dd824dc01e97388c3aade4c602c2e7d5e4d1044..4030233f620e437e984013db7c5e71bf5c0ae478 100644 (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)) {
+                               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) {
index b411c16b22a737bfd71f63dc7b028fd6357d5105..7620d2dac09d19b07b5291dabf5d7bbe75d0c042 100644 (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)) {
                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) {