From 221fbdb0f3f551f733d2e97edcedc5d56c2a4490 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 23 Sep 2008 13:54:06 +0000 Subject: [PATCH] patch for FSCORE-191 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9622 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia.c | 6 ++++-- src/mod/endpoints/mod_sofia/sofia_glue.c | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 91eb521e19..a042709100 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1132,7 +1132,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } } else if (!strcasecmp(var, "rfc2833-pt")) { profile->te = (switch_payload_t) atoi(val); - } else if (!strcasecmp(var, "cng-pt")) { + } else if (!strcasecmp(var, "cng-pt") && !(profile->pflags & PFLAG_SUPPRESS_CNG)) { profile->cng_pt = (switch_payload_t) atoi(val); } else if (!strcasecmp(var, "vad")) { if (!strcasecmp(val, "in")) { @@ -1166,6 +1166,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) } else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) { if (switch_true(val)) { profile->pflags |= PFLAG_SUPPRESS_CNG; + profile->cng_pt = 0; } else { profile->pflags &= ~PFLAG_SUPPRESS_CNG; } @@ -1489,7 +1490,7 @@ switch_status_t config_sofia(int reload, char *profile_name) } } else if (!strcasecmp(var, "rfc2833-pt")) { profile->te = (switch_payload_t) atoi(val); - } else if (!strcasecmp(var, "cng-pt")) { + } else if (!strcasecmp(var, "cng-pt") && !(profile->pflags & PFLAG_SUPPRESS_CNG)) { profile->cng_pt = (switch_payload_t) atoi(val); } else if (!strcasecmp(var, "sip-port")) { profile->sip_port = atoi(val); @@ -1621,6 +1622,7 @@ switch_status_t config_sofia(int reload, char *profile_name) } else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) { if (switch_true(val)) { profile->pflags |= PFLAG_SUPPRESS_CNG; + profile->cng_pt = 0; } } else if (!strcasecmp(var, "NDLB-to-in-200-contact")) { if (switch_true(val)) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 8a6f4bbbfe..d89ed30f23 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -127,7 +127,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te); } - if (tech_pvt->cng_pt && use_cng) { + if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) { switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt); } @@ -174,7 +174,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 if (tech_pvt->dtmf_type == DTMF_2833 && tech_pvt->te > 95) { switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te); } - if (tech_pvt->cng_pt && use_cng) { + if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) { switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d CN/8000\n", tech_pvt->cng_pt); if (!tech_pvt->rm_encoding) { tech_pvt->cng_pt = 0; @@ -413,10 +413,12 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * tech_pvt->dtmf_type = profile->dtmf_type; - if (tech_pvt->bcng_pt) { - tech_pvt->cng_pt = tech_pvt->bcng_pt; - } else if (!tech_pvt->cng_pt) { - tech_pvt->cng_pt = profile->cng_pt; + if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG)) { + if (tech_pvt->bcng_pt) { + tech_pvt->cng_pt = tech_pvt->bcng_pt; + } else if (!tech_pvt->cng_pt) { + tech_pvt->cng_pt = profile->cng_pt; + } } tech_pvt->session = session; @@ -1744,7 +1746,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f flags |= SWITCH_RTP_FLAG_RAW_WRITE; } - if (tech_pvt->cng_pt) { + if (tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) { + tech_pvt->cng_pt = 0; + } else if (tech_pvt->cng_pt) { flags |= SWITCH_RTP_FLAG_AUTO_CNG; } @@ -1927,7 +1931,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if (tech_pvt->te) { switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te); } - if (tech_pvt->cng_pt) { + if (tech_pvt->cng_pt && !(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", tech_pvt->cng_pt); switch_rtp_set_cng_pt(tech_pvt->rtp_session, tech_pvt->cng_pt); } @@ -2295,7 +2299,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * } } - if (!cng_pt && !strcasecmp(rm_encoding, "CN")) { + if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) { cng_pt = tech_pvt->cng_pt = (switch_payload_t) map->rm_pt; if (tech_pvt->rtp_session) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt);