From 557a4a85808cf6c8736295bbfe84b68625a71a9c Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Mon, 14 Apr 2014 01:28:38 -0400 Subject: [PATCH] Treat CNG as a silent frame in mod_bert --- src/mod/applications/mod_bert/mod_bert.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mod/applications/mod_bert/mod_bert.c b/src/mod/applications/mod_bert/mod_bert.c index 62d7e319c3..0829786de0 100644 --- a/src/mod/applications/mod_bert/mod_bert.c +++ b/src/mod/applications/mod_bert/mod_bert.c @@ -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; }