From 5a0f43d95637e97c278c6a0e35c6bdbd3778870c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 21 Jun 2013 00:41:25 -0500 Subject: [PATCH] make sure sip-hold works on webrtc --- src/switch_core_media.c | 58 ++++++++++++++++++++++++++++++++++++++++- src/switch_rtp.c | 5 ++-- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 531038c68d..ce70d4e0c4 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -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) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 9096e7e88c..cb3d3b4695 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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) {