From 797c42f8ab00bcb27be82ccd28edcd3893540531 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 26 Feb 2025 08:09:19 -0400 Subject: [PATCH] MT#55283 add evs-dtx= option Change-Id: I6489895e31e1fcf1c72c9767b122189f22f58792 (cherry picked from commit ccccded2871c430bf8482af96221672f3da87efd) --- daemon/codec.c | 4 ++++ daemon/main.c | 10 ++++++++++ docs/rtpengine.md | 17 +++++++++-------- include/main.h | 1 + lib/codeclib.c | 1 + lib/codeclib.h | 1 + 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 6f4b04a36..00a8148f3 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -3850,6 +3850,10 @@ static bool __ssrc_handler_decode_common(struct codec_ssrc_handler *ch, struct c if (rtpe_config.amr_cn_dtx) decoder_set_cn_dtx(ch->decoder, &rtpe_config.dtx_cn_params); } + else if (ch->decoder->def->evs) { + if (rtpe_config.evs_cn_dtx) + decoder_set_cn_dtx(ch->decoder, &rtpe_config.dtx_cn_params); + } else decoder_set_cn_dtx(ch->decoder, &rtpe_config.dtx_cn_params); } diff --git a/daemon/main.c b/daemon/main.c index 9c4d71e73..b0ae60832 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -506,6 +506,7 @@ static void options(int *argc, char ***argv) { g_autoptr(char_p) dtx_cn_params = NULL; bool debug_srtp = false; g_autoptr(char) amr_dtx = NULL; + g_autoptr(char) evs_dtx = NULL; #ifdef HAVE_MQTT g_autoptr(char) mqtt_publish_scope = NULL; #endif @@ -643,6 +644,7 @@ static void options(int *argc, char ***argv) { { "dtx-shift", 0,0, G_OPTION_ARG_INT, &rtpe_config.dtx_shift, "Length of time (in ms) to shift DTX buffer after over/underflow", "INT"}, { "dtx-cn-params",0,0, G_OPTION_ARG_STRING_ARRAY,&dtx_cn_params, "Parameters for CN generated from DTX","INT INT INT ..."}, { "amr-dtx", 0,0, G_OPTION_ARG_STRING, &amr_dtx, "DTX mechanism to use for AMR and AMR-WB","native|CN"}, + { "evs-dtx", 0,0, G_OPTION_ARG_STRING, &evs_dtx, "DTX mechanism to use for EVS","native|CN"}, { "silence-detect",0,0, G_OPTION_ARG_DOUBLE, &silence_detect, "Audio level threshold in percent for silence detection","FLOAT"}, { "cn-payload",0,0, G_OPTION_ARG_STRING_ARRAY,&cn_payload, "Comfort noise parameters to replace silence with","INT INT INT ..."}, { "player-cache",0,0, G_OPTION_ARG_NONE, &rtpe_config.player_cache,"Cache media files for playback in memory",NULL}, @@ -979,6 +981,14 @@ static void options(int *argc, char ***argv) { die("Invalid --amr-dtx ('%s')", amr_dtx); } + if (evs_dtx) { + if (!strcasecmp(evs_dtx, "native")) {} + else if (!strcasecmp(evs_dtx, "CN")) + rtpe_config.evs_cn_dtx = true; + else + die("Invalid --evs-dtx ('%s')", evs_dtx); + } + if (use_audio_player) { if (!strcasecmp(use_audio_player, "on-demand") || !strcasecmp(use_audio_player, "on demand") diff --git a/docs/rtpengine.md b/docs/rtpengine.md index e3f998ca8..74744dca5 100644 --- a/docs/rtpengine.md +++ b/docs/rtpengine.md @@ -999,16 +999,17 @@ call to inject-DTMF won't be sent to __\-\-dtmf-log-dest=__ or __\-\-listen-tcp- gaps. - __\-\-amr-dtx=native__\|__CN__ +- __\-\-evs-dtx=native__\|__CN__ - Select the DTX behaviour for AMR codecs. The default is use the codec's - internal processing: during a DTX event, a "no data" frame is passed to the - decoder and the output is used as audio data. + Select the DTX behaviour for AMR and EVS codecs, respectively. The default + is use the codec's internal processing: during a DTX event, a "no data" + frame is passed to the decoder and the output is used as audio data. - If __CN__ is selected here, the same DTX mechanism as other codecs use is used - for AMR, which is to fill in DTX gaps with either silence or RFC 3389 comfort - noise (see __dtx-cn-params__). This also affects processing of received SID - frames: SID frames would not be passed to the codec but instead be replaced by - generated silence or comfort noise. + If __CN__ is selected here, the same DTX mechanism as other codecs use is + used for AMR/EVS, which is to fill in DTX gaps with either silence or RFC + 3389 comfort noise (see __dtx-cn-params__). This also affects processing of + received SID frames: SID frames would not be passed to the codec but + instead be replaced by generated silence or comfort noise. - __\-\-silence-detect=__*FLOAT* diff --git a/include/main.h b/include/main.h index a7999f39f..1ca6ee989 100644 --- a/include/main.h +++ b/include/main.h @@ -147,6 +147,7 @@ struct rtpengine_config { int dtx_shift; str dtx_cn_params; bool amr_cn_dtx; + bool evs_cn_dtx; double silence_detect_double; uint32_t silence_detect_int; str cn_payload; diff --git a/lib/codeclib.c b/lib/codeclib.c index 6584c6619..f37f0dc40 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -633,6 +633,7 @@ static struct codec_def_s __codec_defs[] = { .select_encoder_format = evs_select_encoder_format, .packetizer = packetizer_passthrough, .bits_per_sample = 1, + .evs = 1, .media_type = MT_AUDIO, .codec_type = &codec_type_evs, .dtx_methods = { diff --git a/lib/codeclib.h b/lib/codeclib.h index c9640c94c..41f33db11 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -215,6 +215,7 @@ struct codec_def_s { unsigned int supplemental:1, dtmf:1, // special case fixed_sizes:1, // hint for `block-short` feature + evs:1, amr:1; const codec_type_t *codec_type;