diff --git a/src/mod/codecs/mod_g722/mod_g722.c b/src/mod/codecs/mod_g722/mod_g722.c index e98f215796..bdc6f57569 100644 --- a/src/mod/codecs/mod_g722/mod_g722.c +++ b/src/mod/codecs/mod_g722/mod_g722.c @@ -143,7 +143,7 @@ static switch_codec_implementation_t g722_16k_implementation = { /*.ianacode */ 9, /*.iananame */ "G722", /*.fmtp */ NULL, - /*.samples_per_second */ 8000, + /*.samples_per_second */ 16000, /*.bits_per_second */ 64000, /*.microseconds_per_frame */ 20000, /*.samples_per_frame */ 160, diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 40c1ce2307..7b381eefb4 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -87,12 +87,19 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt); } else if (tech_pvt->num_codecs) { int i; + int already_did[256] = { 0 }; for (i = 0; i < tech_pvt->num_codecs; i++) { const switch_codec_implementation_t *imp = tech_pvt->codecs[i]; if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) { continue; } + + if (already_did[imp->ianacode]) { + continue; + } + + already_did[imp->ianacode] = 1; snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode); if (!ptime) { @@ -113,6 +120,9 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por if (tech_pvt->rm_encoding) { rate = tech_pvt->rm_rate; + if (tech_pvt->pt == 9) { + rate = 8000; + } snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->pt, tech_pvt->rm_encoding, rate); if (tech_pvt->fmtp_out) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out); @@ -123,6 +133,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por } else if (tech_pvt->num_codecs) { int i; + int already_did[256] = { 0 }; for (i = 0; i < tech_pvt->num_codecs; i++) { const switch_codec_implementation_t *imp = tech_pvt->codecs[i]; @@ -130,12 +141,20 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por continue; } + if (already_did[imp->ianacode]) { + continue; + } + + already_did[imp->ianacode] = 1; + rate = imp->samples_per_second; if (ptime && ptime != imp->microseconds_per_frame / 1000) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime); } - + if (imp->ianacode == 9) { + rate = 8000; + } snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rate); if (imp->fmtp) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp); @@ -170,6 +189,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt); } else if (tech_pvt->num_codecs) { int i; + int already_did[256] = { 0 }; for (i = 0; i < tech_pvt->num_codecs; i++) { const switch_codec_implementation_t *imp = tech_pvt->codecs[i]; @@ -177,6 +197,12 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por continue; } + if (already_did[imp->ianacode]) { + continue; + } + + already_did[imp->ianacode] = 1; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode); if (!ptime) { ptime = imp->microseconds_per_frame / 1000; @@ -194,6 +220,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por } } else if (tech_pvt->num_codecs) { int i; + int already_did[256] = { 0 }; for (i = 0; i < tech_pvt->num_codecs; i++) { const switch_codec_implementation_t *imp = tech_pvt->codecs[i]; @@ -201,6 +228,12 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t por continue; } + if (already_did[imp->ianacode]) { + continue; + } + + already_did[imp->ianacode] = 1; + if (!rate) { rate = imp->samples_per_second; }