[avmd] FS-9019 Extend syntax description

Add commands to syntax description.
This commit is contained in:
Piotr Gregor 2016-04-05 14:53:01 +01:00
parent 1aa2bf8d77
commit 439be5d122

View File

@ -19,16 +19,14 @@
* *
* Contributor(s): * Contributor(s):
* *
* Piotr Gregor <piotrek.gregor gmail.com>:
* Eric des Courtis <eric.des.courtis@benbria.com> * Eric des Courtis <eric.des.courtis@benbria.com>
* *
* mod_avmd.c -- Advanced Voicemail Detection Module * mod_avmd.c -- Advanced Voicemail Detection Module
* *
* This module detects voicemail beeps using a generalized approach. * This module detects single frequency tones (used in voicemail to denote
* * the moment caller's voice is started to be recorded, aka. beep sounds,
* Modifications: * beeps) using modified DESA-2 algorithm.
* Piotr Gregor <piotrek.gregor gmail.com>:
* FS-8808, FS-8809, FS-8810, FS-8852, FS-8853, FS-8854, FS-8855,
* FS-8860, FS-8861, FS-8875
*/ */
#include <switch.h> #include <switch.h>
@ -99,7 +97,7 @@
#endif #endif
/*! Syntax of the API call. */ /*! Syntax of the API call. */
#define AVMD_SYNTAX "<uuid> <command>" #define AVMD_SYNTAX "<uuid> <start|stop>"
/*! Number of expected parameters in api call. */ /*! Number of expected parameters in api call. */
#define AVMD_PARAMS 2 #define AVMD_PARAMS 2
@ -113,10 +111,9 @@
/* Prototypes */ /* Prototypes */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown);
SWITCH_STANDARD_API(avmd_api_main);
SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load); SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load);
SWITCH_MODULE_DEFINITION(mod_avmd, mod_avmd_load, mod_avmd_shutdown, NULL); SWITCH_MODULE_DEFINITION(mod_avmd, mod_avmd_load, mod_avmd_shutdown, NULL);
SWITCH_STANDARD_API(avmd_api_main);
SWITCH_STANDARD_APP(avmd_start_function); SWITCH_STANDARD_APP(avmd_start_function);
/*! Status of the beep detection */ /*! Status of the beep detection */
@ -216,20 +213,14 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug,
avmd_session = (avmd_session_t *) user_data; avmd_session = (avmd_session_t *) user_data;
if (avmd_session == NULL) { if (avmd_session == NULL) {
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG, "No avmd session assigned!\n");
SWITCH_LOG_ERROR,
"No avmd session assigned!\n"
);
return SWITCH_FALSE; return SWITCH_FALSE;
} }
fs_session = avmd_session->session; fs_session = avmd_session->session;
if (fs_session == NULL) { if (fs_session == NULL) {
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG, "No FreeSWITCH session assigned!\n");
SWITCH_LOG_ERROR,
"No FreeSWITCH session assigned!\n"
);
return SWITCH_FALSE; return SWITCH_FALSE;
} }
@ -238,19 +229,13 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug,
case SWITCH_ABC_TYPE_INIT: case SWITCH_ABC_TYPE_INIT:
read_codec = switch_core_session_get_read_codec(fs_session); read_codec = switch_core_session_get_read_codec(fs_session);
if (read_codec == NULL) { if (read_codec == NULL) {
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_WARNING,
SWITCH_CHANNEL_SESSION_LOG(fs_session), "No codec assigned, default session rate to 8000 samples/s\n");
SWITCH_LOG_WARNING,
"No codec assigned, default session rate to 8000 samples/s\n"
);
avmd_session->rate = 8000; avmd_session->rate = 8000;
} else { } else {
if (read_codec->implementation == NULL) { if (read_codec->implementation == NULL) {
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_WARNING,
SWITCH_CHANNEL_SESSION_LOG(fs_session), "No codec implementation assigned, default session rate to 8000 samples/s\n");
SWITCH_LOG_WARNING,
"No codec implementation assigned, default session rate to 8000 samples/s\n"
);
avmd_session->rate = 8000; avmd_session->rate = 8000;
} else { } else {
avmd_session->rate = read_codec->implementation->samples_per_second; avmd_session->rate = read_codec->implementation->samples_per_second;
@ -259,11 +244,8 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug,
avmd_session->start_time = switch_micro_time_now(); avmd_session->start_time = switch_micro_time_now();
/* avmd_session->vmd_codec.channels = /* avmd_session->vmd_codec.channels =
* read_codec->implementation->number_of_channels; */ * read_codec->implementation->number_of_channels; */
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session),SWITCH_LOG_INFO,
SWITCH_CHANNEL_SESSION_LOG(fs_session), "Avmd session started, [%u] samples/s\n", avmd_session->rate);
SWITCH_LOG_INFO,
"Avmd session started, [%u] samples/s\n", avmd_session->rate
);
break; break;
case SWITCH_ABC_TYPE_READ_REPLACE: case SWITCH_ABC_TYPE_READ_REPLACE:
@ -308,9 +290,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
SWITCH_CHANNEL_LOG,
SWITCH_LOG_NOTICE,
"Advanced Voicemail detection enabled\n" "Advanced Voicemail detection enabled\n"
); );
@ -321,48 +301,33 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
switch (ret) { switch (ret) {
case -1: case -1:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG,
SWITCH_LOG_ERROR,
"Can't access file [%s], error [%s]\n", "Can't access file [%s], error [%s]\n",
ACOS_TABLE_FILENAME, err ACOS_TABLE_FILENAME, err);
);
break; break;
case -2: case -2:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG,
SWITCH_LOG_ERROR,
"Error creating file [%s], error [%s]\n", "Error creating file [%s], error [%s]\n",
ACOS_TABLE_FILENAME, err ACOS_TABLE_FILENAME, err);
);
break; break;
case -3: case -3:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG,
SWITCH_LOG_ERROR,
"Access rights are OK but can't open file [%s], error [%s]\n", "Access rights are OK but can't open file [%s], error [%s]\n",
ACOS_TABLE_FILENAME, err ACOS_TABLE_FILENAME, err);
);
break; break;
case -4: case -4:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG,
SWITCH_LOG_ERROR,
"Access rights are OK but can't mmap file [%s], error [%s]\n", "Access rights are OK but can't mmap file [%s], error [%s]\n",
ACOS_TABLE_FILENAME, err ACOS_TABLE_FILENAME, err);
);
break; break;
default: default:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG,
SWITCH_LOG_ERROR,
"Unknown error [%d] while initializing fast cos table [%s], " "Unknown error [%d] while initializing fast cos table [%s], "
"errno [%s]\n", ret, ACOS_TABLE_FILENAME, err "errno [%s]\n", ret, ACOS_TABLE_FILENAME, err);
);
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
@ -375,18 +340,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
); );
#endif #endif
SWITCH_ADD_APP( SWITCH_ADD_APP(app_interface, "avmd","Beep detection",
app_interface, "Advanced detection of voicemail beeps", avmd_start_function,
"avmd", AVMD_SYNTAX, SAF_NONE);
"Beep detection",
"Advanced detection of voicemail beeps",
avmd_start_function,
"[start] [stop]",
SAF_NONE
);
SWITCH_ADD_API(api_interface, "avmd", "Voicemail beep detection", SWITCH_ADD_API(api_interface, "avmd", "Voicemail beep detection",
avmd_api_main, AVMD_SYNTAX); avmd_api_main, AVMD_SYNTAX);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -493,18 +452,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
if (res != 0) { if (res != 0) {
switch (res) { switch (res) {
case -1: case -1:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG, "Failed unmap arc cosine table\n");
SWITCH_LOG_ERROR,
"Failed unmap arc cosine table\n"
);
break; break;
case -2: case -2:
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
SWITCH_CHANNEL_LOG, "Failed closing arc cosine table\n");
SWITCH_LOG_ERROR,
"Failed closing arc cosine table\n"
);
break; break;
default: default:
break; break;
@ -512,11 +465,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
} }
#endif #endif
switch_log_printf( switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
SWITCH_CHANNEL_LOG, "Advanced Voicemail detection disabled\n");
SWITCH_LOG_NOTICE,
"Advanced Voicemail detection disabled\n"
);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }