From: Moises Silva Date: Tue, 12 Oct 2010 15:58:40 +0000 (-0400) Subject: mod_sangoma_codec: ignore cng frames X-Git-Tag: v1.2-rc1~265^2~11^2~206 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e06ba09eb808f8a439b1bad3ef1d334537d6a2d;p=thirdparty%2Ffreeswitch.git mod_sangoma_codec: ignore cng frames --- diff --git a/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c b/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c index 60ac3ef0be..da8d7fe73d 100644 --- a/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c +++ b/src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c @@ -476,8 +476,18 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec break; } - if (encoded_frame.payload != codec->implementation->ianacode - && encoded_frame.payload != IANACODE_CN) { + if (encoded_frame.payload == IANACODE_CN) { + /* confort noise is treated as silence by us */ + continue; + } + + if (encoded_frame.datalen != codec->implementation->encoded_bytes_per_packet) { + /* seen when silence suppression is enabled */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ignoring encoded frame of %d bytes intead of %d bytes\n", encoded_frame.datalen, codec->implementation->encoded_bytes_per_packet); + continue; + } + + if (encoded_frame.payload != codec->implementation->ianacode) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read unexpected payload %d in Sangoma encoder RTP session, expecting %d\n", encoded_frame.payload, codec->implementation->ianacode); break; @@ -657,13 +667,18 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses break; } - if (ulaw_frame.payload != IANA_ULAW - && ulaw_frame.payload != IANACODE_CN) { + if (ulaw_frame.payload == IANACODE_CN) { + /* confort noise is treated as silence by us */ + continue; + } + + if (ulaw_frame.payload != IANA_ULAW) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read unexpected payload %d in Sangoma decoder RTP session, expecting %d\n", ulaw_frame.payload, IANA_ULAW); break; } + if (sess->decoder.queue_windex == sess->decoder.queue_rindex) { if (sess->decoder.rtp_queue[sess->decoder.queue_rindex].datalen) { /* if there is something where we want to write, we're dropping it */