]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
make sure sip-hold works on webrtc
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 21 Jun 2013 05:41:25 +0000 (00:41 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 21 Jun 2013 05:41:25 +0000 (00:41 -0500)
src/switch_core_media.c
src/switch_rtp.c

index 531038c68db57eb138065a943f0a281d10eb9a9e..ce70d4e0c4d1dd55b742f0fca63a78419d8c6782 100644 (file)
@@ -1934,7 +1934,7 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
        sdp_attribute_t *attr;
        int i = 0, got_rtcp_mux = 0;
 
-       if (engine->ice_in.chosen[0] && engine->ice_in.chosen[1]) {
+       if (engine->ice_in.chosen[0] && engine->ice_in.chosen[1] && !switch_channel_test_flag(smh->session->channel, CF_REINVITE)) {
                return;
        }
 
@@ -2175,6 +2175,62 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
                engine->rtcp_mux = -1;
        }
 
+
+       
+       if (switch_channel_test_flag(smh->session->channel, CF_REINVITE)) {
+               if (switch_rtp_ready(engine->rtp_session) && engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "RE-Activating %s ICE\n", type2str(type));
+
+                       switch_rtp_activate_ice(engine->rtp_session, 
+                                                                       engine->ice_in.ufrag,
+                                                                       engine->ice_out.ufrag,
+                                                                       engine->ice_out.pwd,
+                                                                       engine->ice_in.pwd,
+                                                                       IPR_RTP,
+#ifdef GOOGLE_ICE
+                                                                       ICE_GOOGLE_JINGLE,
+                                                                       NULL
+#else
+                                                                       switch_channel_direction(smh->session->channel) == 
+                                                                       SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
+                                                                       &engine->ice_in
+#endif
+                                                                       );
+
+               
+                       
+               }
+               
+
+
+               if (engine->ice_in.cands[engine->ice_in.chosen[1]][1].ready) {
+                       if (!strcmp(engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr)
+                               && engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port == engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "Skipping %s RTCP ICE (Same as RTP)\n", type2str(type));
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "Activating %s RTCP ICE\n", type2str(type));
+                               
+                               switch_rtp_activate_ice(engine->rtp_session, 
+                                                                               engine->ice_in.ufrag,
+                                                                               engine->ice_out.ufrag,
+                                                                               engine->ice_out.pwd,
+                                                                               engine->ice_in.pwd,
+                                                                               IPR_RTCP,
+#ifdef GOOGLE_ICE
+                                                                               ICE_GOOGLE_JINGLE,
+                                                                               NULL
+#else
+                                                                               switch_channel_direction(smh->session->channel) == 
+                                                                               SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
+                                                                               &engine->ice_in
+#endif
+                                                                               );
+                       }
+                       
+               }
+               
+       }
+       
 }
 #ifdef _MSC_VER
 #pragma warning(pop)
index 9096e7e88cef7331ad7667a84f26c07b6f61a8cf..cb3d3b46955e92482bac55069980ce893a47438e 100644 (file)
@@ -876,7 +876,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
                if (!zstr(username)) {
                        if (!strcmp(username, ice->user_ice)) {
                                ok = 1;
-                       } else if(!strcmp(username, rtp_session->rtcp_ice.user_ice)) {
+                       } else if(!zstr(rtp_session->rtcp_ice.user_ice) && !strcmp(username, rtp_session->rtcp_ice.user_ice)) {
                                ice = &rtp_session->rtcp_ice;
                                ok = 1;
                        }
@@ -891,7 +891,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
                        char *host = NULL;
 
                        ice->missed_count++;
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "missed %d\n", ice->missed_count);
+                       //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "missed %d\n", ice->missed_count);
 
                        if (elapsed > 20000 && pri) {
                                int i, j;
@@ -971,6 +971,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
 
        if (ice->missed_count > 5) {
                ice->rready = 0;
+               ok = 1;
        }
 
        if (ok) {