From c0e7e7b88c4f9b82787eb3c9d8d987d28c29c135 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 14 Jun 2014 07:05:00 +0500 Subject: [PATCH] add reset function to clear some state data in the rtp session --- src/include/switch_rtp.h | 1 + src/mod/endpoints/mod_verto/mod_verto.c | 5 ++++- src/switch_core_media.c | 4 ++++ src/switch_rtp.c | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index c6082fa9c5..9de008ce07 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -218,6 +218,7 @@ SWITCH_DECLARE(void) switch_rtp_reset_media_timer(switch_rtp_t *rtp_session); SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max); SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session); +SWITCH_DECLARE(void) switch_rtp_reset(switch_rtp_t *rtp_session); /*! \brief Assign a local address to the RTP session diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index 34a67b3866..ca260be05b 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -1634,7 +1634,6 @@ static void verto_set_media_options(verto_pvt_t *tech_pvt, verto_profile_t *prof //tech_pvt->mparams->manual_rtp_bugs = profile->manual_rtp_bugs; //tech_pvt->mparams->manual_video_rtp_bugs = profile->manual_video_rtp_bugs; - tech_pvt->mparams->local_network = switch_core_session_strdup(tech_pvt->session, profile->local_network); @@ -2382,6 +2381,10 @@ static switch_bool_t verto__attach_func(const char *method, cJSON *params, jsock switch_core_media_clear_ice(tech_pvt->session); switch_channel_set_flag(tech_pvt->channel, CF_REINVITE); + //switch_channel_audio_sync(tech_pvt->channel); + //switch_channel_set_flag(tech_pvt->channel, CF_VIDEO_BREAK); + //switch_core_session_kill_channel(tech_pvt->session, SWITCH_SIG_BREAK); + if ((match = switch_core_media_negotiate_sdp(tech_pvt->session, tech_pvt->r_sdp, &p, SDP_TYPE_RESPONSE))) { if (switch_core_media_activate_rtp(tech_pvt->session) != SWITCH_STATUS_SUCCESS) { switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "MEDIA ERROR"); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index f2eaa03cd0..0533781aab 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -2395,6 +2395,10 @@ static void clear_ice(switch_core_session_t *session, switch_media_type_t type) memset(&engine->ice_in, 0, sizeof(engine->ice_in)); engine->remote_rtcp_port = 0; + if (engine->rtp_session) { + switch_rtp_reset(engine->rtp_session); + } + } //? diff --git a/src/switch_rtp.c b/src/switch_rtp.c index b68534114c..0eb3c03516 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -543,8 +543,6 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_ rtp_session->stats.inbound.last_processed_seq = 0; if (!(packet[0] || packet[1] || packet[2] || packet[3]) && len >= 8) { - - packet += 4; len -= 4; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "DTMF payload offset by 4 bytes.\n"); @@ -2458,6 +2456,18 @@ 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(switch_rtp_t *rtp_session) +{ + if (!rtp_session) { + return; + } + + rtp_session->seq = (uint16_t) rand(); + rtp_session->ts = 0; + memset(&rtp_session->ts_norm, 0, sizeof(rtp_session->ts_norm)); + +} + SWITCH_DECLARE(void) switch_rtp_reset_media_timer(switch_rtp_t *rtp_session) { rtp_session->missed_count = 0;