From 795e4a7a1c2f6cd60e6077fcc42aaf71c0da89fc Mon Sep 17 00:00:00 2001 From: Evgenii Buchnev Date: Fri, 5 Apr 2024 12:02:19 +1000 Subject: [PATCH 1/3] [mod_avmd] adding avmd report variables Added the following variables to be added to the channel on success of detection: - avmd_report_amplitude - avmd_report_amplitude_max - avmd_report_amplitude_variance - avmd_report_detection_time - avmd_report_frequency - avmd_report_frequency_variance - avmd_report_idx - avmd_report_mode - avmd_report_offset - avmd_report_resolution --- src/mod/applications/mod_avmd/mod_avmd.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index e5076c1500..c93fc07265 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -21,6 +21,7 @@ * * Eric des Courtis * Piotr Gregor + * Evgenii Buchnev * * mod_avmd.c -- Advanced Voicemail Detection Module * @@ -1978,6 +1979,9 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected [%u][%u][%u][%u]: amplitude = [%f](max [%f]) variance = [%f], detection time [%" PRId64 "] [us] >>>\n", mode, b->resolution, b->offset, d->idx, sma_amp_b->sma, b->amplitude_max, v_amp, detection_time); } + switch_channel_set_variable_printf(channel, "avmd_report_amplitude", "%f", sma_amp_b->sma); + switch_channel_set_variable_printf(channel, "avmd_report_amplitude_max", "%f", b->amplitude_max); + switch_channel_set_variable_printf(channel, "avmd_report_amplitude_variance", "%f", v_amp); break; case AVMD_DETECT_FREQ: @@ -1988,6 +1992,8 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected [%u][%u][%u][%u]: f = [%f] variance = [%f], detection time [%" PRId64 "] [us] >>>\n", mode, b->resolution, b->offset, d->idx, AVMD_TO_HZ(s->rate, f_sma), v_fir, detection_time); } + switch_channel_set_variable_printf(channel, "avmd_report_frequency", "%f", AVMD_TO_HZ(s->rate, f_sma)); + switch_channel_set_variable_printf(channel, "avmd_report_frequency_variance", "%f", v_fir); break; case AVMD_DETECT_BOTH: @@ -1999,11 +2005,21 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected [%u][%u][%u][%u]: f = [%f] variance = [%f], amplitude = [%f](max [%f]) variance = [%f], detection time [%" PRId64 "] [us] >>>\n", mode, b->resolution, b->offset, d->idx, AVMD_TO_HZ(s->rate, f_sma), v_fir, sma_amp_b->sma, b->amplitude_max, v_amp, detection_time); } + switch_channel_set_variable_printf(channel, "avmd_report_amplitude", "%f", sma_amp_b->sma); + switch_channel_set_variable_printf(channel, "avmd_report_amplitude_max", "%f", b->amplitude_max); + switch_channel_set_variable_printf(channel, "avmd_report_amplitude_variance", "%f", v_amp); + switch_channel_set_variable_printf(channel, "avmd_report_frequency", "%f", AVMD_TO_HZ(s->rate, f_sma)); + switch_channel_set_variable_printf(channel, "avmd_report_frequency_variance", "%f", v_fir); break; default: break; } + switch_channel_set_variable_printf(channel, "avmd_report_mode", "%u", mode); + switch_channel_set_variable_printf(channel, "avmd_report_resolution", "%u", b->resolution); + switch_channel_set_variable_printf(channel, "avmd_report_offset", "%u", b->offset); + switch_channel_set_variable_printf(channel, "avmd_report_idx", "%u", d->idx); + switch_channel_set_variable_printf(channel, "avmd_report_detection_time", "%" PRId64, detection_time); s->state.beep_state = BEEP_DETECTED; } From b425ea661d25c852210b6e2e699d166a7c99c06e Mon Sep 17 00:00:00 2001 From: Evgenii Buchnev Date: Mon, 8 Apr 2024 12:01:39 +1000 Subject: [PATCH 2/3] PR comments fixes --- src/mod/applications/mod_avmd/mod_avmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index c93fc07265..db60f7b2ca 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -1979,6 +1979,7 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected [%u][%u][%u][%u]: amplitude = [%f](max [%f]) variance = [%f], detection time [%" PRId64 "] [us] >>>\n", mode, b->resolution, b->offset, d->idx, sma_amp_b->sma, b->amplitude_max, v_amp, detection_time); } + switch_channel_set_variable_printf(channel, "avmd_report_amplitude", "%f", sma_amp_b->sma); switch_channel_set_variable_printf(channel, "avmd_report_amplitude_max", "%f", b->amplitude_max); switch_channel_set_variable_printf(channel, "avmd_report_amplitude_variance", "%f", v_amp); @@ -2005,6 +2006,7 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected [%u][%u][%u][%u]: f = [%f] variance = [%f], amplitude = [%f](max [%f]) variance = [%f], detection time [%" PRId64 "] [us] >>>\n", mode, b->resolution, b->offset, d->idx, AVMD_TO_HZ(s->rate, f_sma), v_fir, sma_amp_b->sma, b->amplitude_max, v_amp, detection_time); } + switch_channel_set_variable_printf(channel, "avmd_report_amplitude", "%f", sma_amp_b->sma); switch_channel_set_variable_printf(channel, "avmd_report_amplitude_max", "%f", b->amplitude_max); switch_channel_set_variable_printf(channel, "avmd_report_amplitude_variance", "%f", v_amp); @@ -2015,11 +2017,12 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo default: break; } + switch_channel_set_variable_printf(channel, "avmd_report_mode", "%u", mode); switch_channel_set_variable_printf(channel, "avmd_report_resolution", "%u", b->resolution); switch_channel_set_variable_printf(channel, "avmd_report_offset", "%u", b->offset); switch_channel_set_variable_printf(channel, "avmd_report_idx", "%u", d->idx); - switch_channel_set_variable_printf(channel, "avmd_report_detection_time", "%" PRId64, detection_time); + switch_channel_set_variable_printf(channel, "avmd_report_detection_time", "%" SWITCH_TIME_T_FMT, detection_time); s->state.beep_state = BEEP_DETECTED; } From f96c4f5a9516b3e221ba1cbe4ffa2eb88047ace7 Mon Sep 17 00:00:00 2001 From: Evgenii Buchnev Date: Mon, 8 Apr 2024 12:04:36 +1000 Subject: [PATCH 3/3] PR comments fixes --- src/mod/applications/mod_avmd/mod_avmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index db60f7b2ca..67dd1da3ca 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -1993,6 +1993,7 @@ static void avmd_report_detection(avmd_session_t *s, enum avmd_detection_mode mo switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(s->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected [%u][%u][%u][%u]: f = [%f] variance = [%f], detection time [%" PRId64 "] [us] >>>\n", mode, b->resolution, b->offset, d->idx, AVMD_TO_HZ(s->rate, f_sma), v_fir, detection_time); } + switch_channel_set_variable_printf(channel, "avmd_report_frequency", "%f", AVMD_TO_HZ(s->rate, f_sma)); switch_channel_set_variable_printf(channel, "avmd_report_frequency_variance", "%f", v_fir); break;