]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_sangoma_codec: ignore cng frames
authorMoises Silva <moy@sangoma.com>
Tue, 12 Oct 2010 15:58:40 +0000 (11:58 -0400)
committerMoises Silva <moy@sangoma.com>
Tue, 12 Oct 2010 16:19:34 +0000 (12:19 -0400)
src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c

index 60ac3ef0be59225948e32c8c0b25ee51c6ed4764..da8d7fe73d4dc7e1df2a3f5228ad10b4d8e90c61 100644 (file)
@@ -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 */