]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8053 #resolve [When WebRTC's SDP contains a=sendonly for video, the client will...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 18 Nov 2015 16:31:30 +0000 (10:31 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 18 Nov 2015 16:31:30 +0000 (10:31 -0600)
src/mod/codecs/mod_vpx/mod_vpx.c
src/switch_core_media.c
src/switch_rtp.c

index e1311b8f84705927310e25835f0245bb8e0849ed..c772baa457f950e0b72d18e35fde67ec32108b5c 100644 (file)
@@ -227,6 +227,7 @@ struct vpx_context {
        uint8_t decoder_init;
        switch_buffer_t *vpx_packet_buffer;
        int got_key_frame;
+       int no_key_frame;
        int got_start_frame;
        uint32_t last_received_timestamp;
        switch_bool_t last_received_complete_picture;
@@ -273,6 +274,7 @@ static switch_status_t init_decoder(switch_codec_t *codec)
                context->last_received_complete_picture = 0;
                context->decoder_init = 1;
                context->got_key_frame = 0;
+               context->no_key_frame = 0;
                context->got_start_frame = 0;
                // the types of post processing to be done, should be combination of "vp8_postproc_level"
                ppcfg.post_proc_flag = VP8_DEBLOCK;//VP8_DEMACROBLOCK | VP8_DEBLOCK;
@@ -812,7 +814,18 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
                is_start = (*(unsigned char *)frame->data & 0x10);
                is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
        }
-
+       
+       
+    if (context->got_key_frame <= 0) {
+        context->no_key_frame++;
+        //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, %d\n", context->no_key_frame);
+        if (context->no_key_frame > 50) {
+            if ((is_keyframe = is_start)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, treating start as key.\n");
+            }
+        }
+    }
+       
        // if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
 
        if (context->need_decoder_reset != 0) {
@@ -845,9 +858,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
        if (is_keyframe) {
                if (context->got_key_frame <= 0) {
                        context->got_key_frame = 1;
-                       if (!is_keyframe) {
-                               get_refresh = 1;
-                       }
+                       context->no_key_frame = 0;
                } else {
                        context->got_key_frame++;
                }
@@ -855,6 +866,9 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
                if ((--context->got_key_frame % 200) == 0) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Waiting for key frame %d\n", context->got_key_frame);
                }
+
+               get_refresh = 1;
+               
                if (!context->got_start_frame) {
                        switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
                }
index dbec5b0d9551116daac52a9a0725c5cb0f74d3ac..fa989e092df5cf432edc91b31568b59342aeb39e 100644 (file)
@@ -3430,6 +3430,10 @@ static switch_status_t check_ice(switch_media_handle_t *smh, switch_media_type_t
 
        if (switch_channel_test_flag(smh->session->channel, CF_REINVITE)) {
 
+               if (v_engine->remote_ssrc) {
+                       switch_rtp_set_remote_ssrc(v_engine->rtp_session, v_engine->remote_ssrc);
+               }
+
                if (switch_rtp_ready(engine->rtp_session) && engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready && engine->new_ice) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "RE-Activating %s ICE\n", type2str(type));
 
index 3175e56e470f01157d36249f251a577886475ccd..c04d626a5956dc531b17ffdcee22dd81ae5893ab 100644 (file)
@@ -2266,7 +2266,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
                        rtcp_bytes = sbytes;
                }
 #endif
-//#define DEBUG_EXTRA
+               //#define DEBUG_EXTRA
 #ifdef DEBUG_EXTRA
                {
                        const char *old_host;
@@ -2740,6 +2740,17 @@ SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session
        rtp_session->max_missed_packets = max;
 }
 
+SWITCH_DECLARE(void) switch_rtp_reset_vb(switch_rtp_t *rtp_session)
+{
+       if (rtp_session->vb) {
+               switch_jb_reset(rtp_session->vb);
+       }
+
+       if (rtp_session->vbw) {
+               switch_jb_reset(rtp_session->vbw);
+       }
+}
+
 SWITCH_DECLARE(void) switch_rtp_reset(switch_rtp_t *rtp_session)
 {
        if (!rtp_session) {
@@ -2762,12 +2773,7 @@ SWITCH_DECLARE(void) switch_rtp_reset(switch_rtp_t *rtp_session)
        rtcp_stats_init(rtp_session);
        
        if (rtp_session->ice.ready) {
-               if (rtp_session->vb) {
-                       switch_jb_reset(rtp_session->vb);
-               }
-               if (rtp_session->vbw) {
-                       switch_jb_reset(rtp_session->vbw);
-               }
+               switch_rtp_reset_vb(rtp_session);
                rtp_session->ice.ready = rtp_session->ice.rready = 0;
        }