From 9ca929218fafa1fe4271693c16f3dbe05c884730 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 6 Jul 2012 11:12:14 -0500 Subject: [PATCH] FS-4382 --resolve --- src/include/switch_types.h | 8 +++++++- src/mod/endpoints/mod_sofia/sofia_glue.c | 8 ++++++++ src/switch_rtp.c | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index dd301bd5ce..08b6c61954 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -712,7 +712,7 @@ typedef enum { */ - RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8) + RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8), /* Some RTP endpoints (and by some we mean *cough* _SONUS_!) do not like it when the timestamps jump forward or backwards in time. @@ -726,6 +726,12 @@ typedef enum { */ + RTP_BUG_NEVER_CHANGE_SSRC_ON_MARKER = (1 << 9) + + /* + By default FS will change the SSRC when the marker is set and it detects a timestamp reset. + If this setting is enabled it will NOT do this (old behaviour). + */ } switch_rtp_bug_flag_t; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 2cdd45e171..75c201ddb2 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -7022,6 +7022,14 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str if (switch_stristr("~GEN_ONE_GEN_ALL", str)) { *flag_pole &= ~RTP_BUG_GEN_ONE_GEN_ALL; } + + if (switch_stristr("NEVER_CHANGE_SSRC_ON_MARKER", str)) { + *flag_pole |= RTP_BUG_NEVER_CHANGE_SSRC_ON_MARKER; + } + + if (switch_stristr("~NEVER_CHANGE_SSRC_ON_MARKER", str)) { + *flag_pole &= ~RTP_BUG_NEVER_CHANGE_SSRC_ON_MARKER; + } } char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index bbb3dfdb6e..7d6ad297a2 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -4062,6 +4062,12 @@ static int rtp_common_write(switch_rtp_t *rtp_session, send_msg->header.m = (m && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) ? 1 : 0; + /* If the marker was set, and the timestamp seems to have started over - set a new SSRC, to indicate this is a new stream */ + if (send_msg->header.m && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_CHANGE_SSRC_ON_MARKER) && (rtp_session->last_write_ts == RTP_TS_RESET || + (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->last_write_ts > 0))) { + switch_rtp_set_ssrc(rtp_session, (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL))); + } + memcpy(send_msg->body, data, datalen); bytes = datalen + rtp_header_len; }