]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Treat CNG as a silent frame in mod_bert
authorMoises Silva <moy@sangoma.com>
Mon, 14 Apr 2014 05:28:38 +0000 (01:28 -0400)
committerMoises Silva <moy@sangoma.com>
Tue, 9 Sep 2014 08:07:12 +0000 (04:07 -0400)
src/mod/applications/mod_bert/mod_bert.c

index 62d7e319c392799a9a7a52bd8f807536632a5684..0829786de07df4ac2dcbe61ed6d86335f5e1a41c 100644 (file)
@@ -34,6 +34,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_bert_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_bert_shutdown);
 SWITCH_MODULE_DEFINITION(mod_bert, mod_bert_load, mod_bert_shutdown, NULL);
 
+#define G711_ULAW_IDLE_OCTET        0xFF
+
 /* http://en.wikipedia.org/wiki/Digital_milliwatt */
 unsigned char ulaw_digital_milliwatt[8] = { 0x1e, 0x0b, 0x0b, 0x1e, 0x9e, 0x8b, 0x8b, 0x9e };
 
@@ -263,12 +265,14 @@ SWITCH_STANDARD_APP(bert_test_function)
                        }
                }
 
-               /* Ignore confort noise, TODO: we should probably deal with this and treat it as a full frame of silence?? */
-               if (switch_test_flag(read_frame, SFF_CNG) || !read_frame->datalen) {
-                       continue;
+               /* Treat CNG as silence */
+               if (switch_test_flag(read_frame, SFF_CNG)) {
+                       read_frame->samples = read_impl.samples_per_packet;
+                       read_frame->datalen = read_impl.samples_per_packet;
+                       memset(read_frame->data, G711_ULAW_IDLE_OCTET, read_frame->datalen);
                }
 
-               if (read_frame->samples != read_impl.samples_per_packet) {
+               if (read_frame->samples != read_impl.samples_per_packet || !read_frame->datalen) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Read %d samples, expected %d!\n", read_frame->samples, read_impl.samples_per_packet);
                        continue;
                }