From 77405bd53ecfa28859d3e9cee5fab2c125a78cc2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 12 Nov 2007 20:36:00 +0000 Subject: [PATCH] add supress-cng param and supress_cng variable git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6222 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.h | 3 ++- src/mod/endpoints/mod_sofia/sofia.c | 4 ++++ src/mod/endpoints/mod_sofia/sofia_glue.c | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 92a587836f..00d4c0a2d4 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -114,7 +114,8 @@ typedef enum { PFLAG_RUNNING = (1 << 8), PFLAG_RESPAWN = (1 << 9), PFLAG_GREEDY = (1 << 10), - PFLAG_MULTIREG = (1 << 11) + PFLAG_MULTIREG = (1 << 11), + PFLAG_SUPRESS_CNG = (1 << 12) } PFLAGS; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index cac857186f..030e4fc98e 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -907,6 +907,10 @@ switch_status_t config_sofia(int reload, char *profile_name) if (switch_true(val)) { profile->pflags |= PFLAG_MULTIREG; } + } else if (!strcasecmp(var, "supress-cng")) { + if (switch_true(val)) { + profile->pflags |= PFLAG_SUPRESS_CNG; + } } else if (!strcasecmp(var, "NDLB-to-in-200-contact")) { if (switch_true(val)) { profile->ndlb |= PFLAG_NDLB_TO_IN_200_CONTACT; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 7a7e712989..0bbb2cce47 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -44,6 +44,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 int ptime = 0; uint32_t rate = 0; uint32_t v_port; + int use_cng = 1; + const char *val; + + if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPRESS_CNG) || + ((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val))) { + use_cng = 0; + } if (!force && !ip && !sr && switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) { return; @@ -113,8 +120,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 if (tech_pvt->te > 95) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te); } - - if (tech_pvt->cng_pt) { + + if (tech_pvt->cng_pt && use_cng) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt); } @@ -163,11 +170,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 if (tech_pvt->te > 95) { 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) { + if (tech_pvt->cng_pt && use_cng) { 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; } + } else { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=silenceSupp:off - - - -\n"); } if (ptime) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);