[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
This commit is contained in:
Evgenii Buchnev 2024-04-05 12:02:19 +10:00
parent 739e770c34
commit 795e4a7a1c
1 changed files with 16 additions and 0 deletions

View File

@ -21,6 +21,7 @@
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
* Evgenii Buchnev <evgenii.buchnev@yabbr.io>
*
* 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;
}