FS-5401 --resolve whitespace only

This commit is contained in:
Jeff Lenk 2014-01-02 17:51:09 -06:00
parent e75497c98d
commit 7ebb663ce6
1 changed files with 307 additions and 307 deletions

View File

@ -98,28 +98,28 @@ SWITCH_STANDARD_APP(avmd_start_function);
/*! Status of the beep detection */ /*! Status of the beep detection */
typedef enum { typedef enum {
BEEP_DETECTED, BEEP_DETECTED,
BEEP_NOTDETECTED BEEP_NOTDETECTED
} avmd_beep_state_t; } avmd_beep_state_t;
/*! Data related to the current status of the beep */ /*! Data related to the current status of the beep */
typedef struct { typedef struct {
avmd_beep_state_t beep_state; avmd_beep_state_t beep_state;
size_t last_beep; size_t last_beep;
} avmd_state_t; } avmd_state_t;
/*! Type that holds session information pertinent to the avmd module. */ /*! Type that holds session information pertinent to the avmd module. */
typedef struct { typedef struct {
/*! Internal FreeSWITCH session. */ /*! Internal FreeSWITCH session. */
switch_core_session_t *session; switch_core_session_t *session;
uint32_t rate; uint32_t rate;
circ_buffer_t b; circ_buffer_t b;
sma_buffer_t sma_b; sma_buffer_t sma_b;
sma_buffer_t sqa_b; sma_buffer_t sqa_b;
size_t pos; size_t pos;
double f; double f;
/* freq_table_t ft; */ /* freq_table_t ft; */
avmd_state_t state; avmd_state_t state;
} avmd_session_t; } avmd_session_t;
static void avmd_process(avmd_session_t *session, switch_frame_t *frame); static void avmd_process(avmd_session_t *session, switch_frame_t *frame);
@ -135,26 +135,26 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se
static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_session_t *fs_session) static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_session_t *fs_session)
{ {
/*! This is a worst case sample rate estimate */ /*! This is a worst case sample rate estimate */
avmd_session->rate = 48000; avmd_session->rate = 48000;
INIT_CIRC_BUFFER(&avmd_session->b, BEEP_LEN(avmd_session->rate), FRAME_LEN(avmd_session->rate), fs_session); INIT_CIRC_BUFFER(&avmd_session->b, BEEP_LEN(avmd_session->rate), FRAME_LEN(avmd_session->rate), fs_session);
avmd_session->session = fs_session; avmd_session->session = fs_session;
avmd_session->pos = 0; avmd_session->pos = 0;
avmd_session->f = 0.0; avmd_session->f = 0.0;
avmd_session->state.last_beep = 0; avmd_session->state.last_beep = 0;
avmd_session->state.beep_state = BEEP_NOTDETECTED; avmd_session->state.beep_state = BEEP_NOTDETECTED;
INIT_SMA_BUFFER( INIT_SMA_BUFFER(
&avmd_session->sma_b, &avmd_session->sma_b,
BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate), BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate),
fs_session fs_session
); );
INIT_SMA_BUFFER( INIT_SMA_BUFFER(
&avmd_session->sqa_b, &avmd_session->sqa_b,
BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate), BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate),
fs_session fs_session
); );
} }
@ -168,42 +168,42 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se
*/ */
static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type) static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type)
{ {
avmd_session_t *avmd_session; avmd_session_t *avmd_session;
switch_codec_t *read_codec; switch_codec_t *read_codec;
switch_frame_t *frame; switch_frame_t *frame;
avmd_session = (avmd_session_t *) user_data; avmd_session = (avmd_session_t *) user_data;
if (avmd_session == NULL) { if (avmd_session == NULL) {
return SWITCH_FALSE; return SWITCH_FALSE;
} }
switch (type) { switch (type) {
case SWITCH_ABC_TYPE_INIT: case SWITCH_ABC_TYPE_INIT:
read_codec = switch_core_session_get_read_codec(avmd_session->session); read_codec = switch_core_session_get_read_codec(avmd_session->session);
avmd_session->rate = read_codec->implementation->samples_per_second; avmd_session->rate = read_codec->implementation->samples_per_second;
/* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */ /* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */
break; break;
case SWITCH_ABC_TYPE_READ_PING: case SWITCH_ABC_TYPE_READ_PING:
case SWITCH_ABC_TYPE_CLOSE: case SWITCH_ABC_TYPE_CLOSE:
case SWITCH_ABC_TYPE_READ: case SWITCH_ABC_TYPE_READ:
case SWITCH_ABC_TYPE_WRITE: case SWITCH_ABC_TYPE_WRITE:
case SWITCH_ABC_TYPE_TAP_NATIVE_READ: case SWITCH_ABC_TYPE_TAP_NATIVE_READ:
case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE: case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
break; break;
case SWITCH_ABC_TYPE_READ_REPLACE: case SWITCH_ABC_TYPE_READ_REPLACE:
frame = switch_core_media_bug_get_read_replace_frame(bug); frame = switch_core_media_bug_get_read_replace_frame(bug);
avmd_process(avmd_session, frame); avmd_process(avmd_session, frame);
return SWITCH_TRUE; return SWITCH_TRUE;
case SWITCH_ABC_TYPE_WRITE_REPLACE: case SWITCH_ABC_TYPE_WRITE_REPLACE:
break; break;
} }
return SWITCH_TRUE; return SWITCH_TRUE;
} }
/*! \brief FreeSWITCH module loading function /*! \brief FreeSWITCH module loading function
@ -214,40 +214,40 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
{ {
switch_application_interface_t *app_interface; switch_application_interface_t *app_interface;
switch_api_interface_t *api_interface; switch_api_interface_t *api_interface;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG,
SWITCH_LOG_NOTICE, SWITCH_LOG_NOTICE,
"Advanced Voicemail detection enabled\n" "Advanced Voicemail detection enabled\n"
); );
#ifdef FASTMATH #ifdef FASTMATH
init_fast_acosf(); init_fast_acosf();
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG,
SWITCH_LOG_NOTICE, SWITCH_LOG_NOTICE,
"Advanced Voicemail detection: fast math enabled\n" "Advanced Voicemail detection: fast math enabled\n"
); );
#endif #endif
SWITCH_ADD_APP( SWITCH_ADD_APP(
app_interface, app_interface,
"avmd", "avmd",
"Beep detection", "Beep detection",
"Advanced detection of voicemail beeps", "Advanced detection of voicemail beeps",
avmd_start_function, avmd_start_function,
"[start] [stop]", "[start] [stop]",
SAF_NONE SAF_NONE
); );
SWITCH_ADD_API(api_interface, "avmd", "Voicemail beep detection", avmd_api_main, AVMD_SYNTAX); SWITCH_ADD_API(api_interface, "avmd", "Voicemail beep detection", 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;
} }
/*! \brief FreeSWITCH application handler function. /*! \brief FreeSWITCH application handler function.
@ -258,63 +258,63 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load)
*/ */
SWITCH_STANDARD_APP(avmd_start_function) SWITCH_STANDARD_APP(avmd_start_function)
{ {
switch_media_bug_t *bug; switch_media_bug_t *bug;
switch_status_t status; switch_status_t status;
switch_channel_t *channel; switch_channel_t *channel;
avmd_session_t *avmd_session; avmd_session_t *avmd_session;
if (session == NULL) if (session == NULL)
return; return;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
/* Is this channel already using avmd ? */ /* Is this channel already using avmd ? */
bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_"); bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_");
/* If it is using avmd */ /* If it is using avmd */
if (bug != NULL) { if (bug != NULL) {
/* If we have a stop remove audio bug */ /* If we have a stop remove audio bug */
if (strcasecmp(data, "stop") == 0) { if (strcasecmp(data, "stop") == 0) {
switch_channel_set_private(channel, "_avmd_", NULL); switch_channel_set_private(channel, "_avmd_", NULL);
switch_core_media_bug_remove(session, &bug); switch_core_media_bug_remove(session, &bug);
return; return;
} }
/* We have already started */ /* We have already started */
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_WARNING, SWITCH_LOG_WARNING,
"Cannot run 2 at once on the same channel!\n" "Cannot run 2 at once on the same channel!\n"
); );
return; return;
} }
avmd_session = (avmd_session_t *)switch_core_session_alloc(session, sizeof(avmd_session_t)); avmd_session = (avmd_session_t *)switch_core_session_alloc(session, sizeof(avmd_session_t));
init_avmd_session_data(avmd_session, session); init_avmd_session_data(avmd_session, session);
status = switch_core_media_bug_add( status = switch_core_media_bug_add(
session, session,
"avmd", "avmd",
NULL, NULL,
avmd_callback, avmd_callback,
avmd_session, avmd_session,
0, 0,
SMBF_READ_REPLACE, SMBF_READ_REPLACE,
&bug &bug
); );
if (status != SWITCH_STATUS_SUCCESS) { if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_ERROR, SWITCH_LOG_ERROR,
"Failure hooking to stream\n" "Failure hooking to stream\n"
); );
return; return;
} }
switch_channel_set_private(channel, "_avmd_", bug); switch_channel_set_private(channel, "_avmd_", bug);
} }
/*! \brief Called when the module shuts down /*! \brief Called when the module shuts down
@ -326,16 +326,16 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
{ {
#ifdef FASTMATH #ifdef FASTMATH
destroy_fast_acosf(); destroy_fast_acosf();
#endif #endif
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG,
SWITCH_LOG_NOTICE, SWITCH_LOG_NOTICE,
"Advanced Voicemail detection disabled\n" "Advanced Voicemail detection disabled\n"
); );
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/*! \brief FreeSWITCH API handler function. /*! \brief FreeSWITCH API handler function.
@ -347,127 +347,127 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown)
*/ */
SWITCH_STANDARD_API(avmd_api_main) SWITCH_STANDARD_API(avmd_api_main)
{ {
switch_core_session_t *fs_session = NULL; switch_core_session_t *fs_session = NULL;
switch_media_bug_t *bug; switch_media_bug_t *bug;
avmd_session_t *avmd_session; avmd_session_t *avmd_session;
switch_channel_t *channel; switch_channel_t *channel;
switch_status_t status; switch_status_t status;
int argc; int argc;
char *argv[AVMD_PARAMS]; char *argv[AVMD_PARAMS];
char *ccmd = NULL; char *ccmd = NULL;
char *uuid; char *uuid;
char *command; char *command;
/* No command? Display usage */ /* No command? Display usage */
if (zstr(cmd)) { if (zstr(cmd)) {
stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Duplicated contents of original string */ /* Duplicated contents of original string */
ccmd = strdup(cmd); ccmd = strdup(cmd);
/* Separate the arguments */ /* Separate the arguments */
argc = switch_separate_string(ccmd, ' ', argv, AVMD_PARAMS); argc = switch_separate_string(ccmd, ' ', argv, AVMD_PARAMS);
/* If we don't have the expected number of parameters /* If we don't have the expected number of parameters
* display usage */ * display usage */
if (argc != AVMD_PARAMS) { if (argc != AVMD_PARAMS) {
stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX);
goto end; goto end;
} }
uuid = argv[0]; uuid = argv[0];
command = argv[1]; command = argv[1];
/* using uuid locate a reference to the FreeSWITCH session */ /* using uuid locate a reference to the FreeSWITCH session */
fs_session = switch_core_session_locate(uuid); fs_session = switch_core_session_locate(uuid);
/* If the session was not found exit */ /* If the session was not found exit */
if (fs_session == NULL) { if (fs_session == NULL) {
stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX);
goto end; goto end;
} }
/* Get current channel of the session to tag the session /* Get current channel of the session to tag the session
* This indicates that our module is present */ * This indicates that our module is present */
channel = switch_core_session_get_channel(fs_session); channel = switch_core_session_get_channel(fs_session);
/* Is this channel already set? */ /* Is this channel already set? */
bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_"); bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_avmd_");
/* If yes */ /* If yes */
if (bug != NULL) { if (bug != NULL) {
/* If we have a stop remove audio bug */ /* If we have a stop remove audio bug */
if (strcasecmp(command, "stop") == 0) { if (strcasecmp(command, "stop") == 0) {
switch_channel_set_private(channel, "_avmd_", NULL); switch_channel_set_private(channel, "_avmd_", NULL);
switch_core_media_bug_remove(fs_session, &bug); switch_core_media_bug_remove(fs_session, &bug);
switch_safe_free(ccmd); switch_safe_free(ccmd);
stream->write_function(stream, "+OK\n"); stream->write_function(stream, "+OK\n");
goto end; goto end;
} }
/* We have already started */ /* We have already started */
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_WARNING, SWITCH_LOG_WARNING,
"Cannot run 2 at once on the same channel!\n" "Cannot run 2 at once on the same channel!\n"
); );
goto end; goto end;
} }
/* If we don't see the expected start exit */ /* If we don't see the expected start exit */
if (strcasecmp(command, "start") != 0) { if (strcasecmp(command, "start") != 0) {
stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", AVMD_SYNTAX);
goto end; goto end;
} }
/* Allocate memory attached to this FreeSWITCH session for /* Allocate memory attached to this FreeSWITCH session for
* use in the callback routine and to store state information */ * use in the callback routine and to store state information */
avmd_session = (avmd_session_t *) switch_core_session_alloc(fs_session, sizeof(avmd_session_t)); avmd_session = (avmd_session_t *) switch_core_session_alloc(fs_session, sizeof(avmd_session_t));
init_avmd_session_data(avmd_session, fs_session); init_avmd_session_data(avmd_session, fs_session);
/* Add a media bug that allows me to intercept the /* Add a media bug that allows me to intercept the
* reading leg of the audio stream */ * reading leg of the audio stream */
status = switch_core_media_bug_add( status = switch_core_media_bug_add(
fs_session, fs_session,
"avmd", "avmd",
NULL, NULL,
avmd_callback, avmd_callback,
avmd_session, avmd_session,
0, 0,
SMBF_READ_REPLACE, SMBF_READ_REPLACE,
&bug &bug
); );
/* If adding a media bug fails exit */ /* If adding a media bug fails exit */
if (status != SWITCH_STATUS_SUCCESS) { if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_ERROR, SWITCH_LOG_ERROR,
"Failure hooking to stream\n" "Failure hooking to stream\n"
); );
goto end; goto end;
} }
/* Set the vmd tag to detect an existing vmd media bug */ /* Set the vmd tag to detect an existing vmd media bug */
switch_channel_set_private(channel, "_avmd_", bug); switch_channel_set_private(channel, "_avmd_", bug);
/* Everything went according to plan! Notify the user */ /* Everything went according to plan! Notify the user */
stream->write_function(stream, "+OK\n"); stream->write_function(stream, "+OK\n");
end: end:
if (fs_session) { if (fs_session) {
switch_core_session_rwunlock(fs_session); switch_core_session_rwunlock(fs_session);
} }
switch_safe_free(ccmd); switch_safe_free(ccmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/*! \brief Process one frame of data with avmd algorithm /*! \brief Process one frame of data with avmd algorithm
@ -477,102 +477,102 @@ end:
*/ */
static void avmd_process(avmd_session_t *session, switch_frame_t *frame) static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
{ {
switch_event_t *event; switch_event_t *event;
switch_status_t status; switch_status_t status;
switch_event_t *event_copy; switch_event_t *event_copy;
switch_channel_t *channel; switch_channel_t *channel;
circ_buffer_t *b; circ_buffer_t *b;
size_t pos; size_t pos;
double f; double f;
double v; double v;
// double error = 0.0; // double error = 0.0;
// double success = 0.0; // double success = 0.0;
// double amp = 0.0; // double amp = 0.0;
// double s_rate; // double s_rate;
// double e_rate; // double e_rate;
// double avg_a; // double avg_a;
//double sine_len; //double sine_len;
uint32_t sine_len_i; uint32_t sine_len_i;
//uint32_t beep_len_i; //uint32_t beep_len_i;
// int valid; // int valid;
b = &session->b; b = &session->b;
/*! If beep has already been detected skip the CPU heavy stuff */ /*! If beep has already been detected skip the CPU heavy stuff */
if(session->state.beep_state == BEEP_DETECTED){ if(session->state.beep_state == BEEP_DETECTED){
return; return;
} }
/*! Precompute values used heavily in the inner loop */ /*! Precompute values used heavily in the inner loop */
sine_len_i = SINE_LEN(session->rate); sine_len_i = SINE_LEN(session->rate);
//sine_len = (double)sine_len_i; //sine_len = (double)sine_len_i;
//beep_len_i = BEEP_LEN(session->rate); //beep_len_i = BEEP_LEN(session->rate);
channel = switch_core_session_get_channel(session->session); channel = switch_core_session_get_channel(session->session);
/*! Insert frame of 16 bit samples into buffer */ /*! Insert frame of 16 bit samples into buffer */
INSERT_INT16_FRAME(b, (int16_t *)(frame->data), frame->samples); INSERT_INT16_FRAME(b, (int16_t *)(frame->data), frame->samples);
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD sine_len_i=%d >>>\n", sine_len_i); //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD sine_len_i=%d >>>\n", sine_len_i);
/*! INNER LOOP -- OPTIMIZATION TARGET */ /*! INNER LOOP -- OPTIMIZATION TARGET */
for(pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++){ for(pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++){
if ((pos % sine_len_i) == 0) { if ((pos % sine_len_i) == 0) {
/*! Get a desa2 frequency estimate every sine len */ /*! Get a desa2 frequency estimate every sine len */
f = desa2(b, pos); f = desa2(b, pos);
if(f < MIN_FREQUENCY_R(session->rate) || f > MAX_FREQUENCY_R(session->rate)) { if(f < MIN_FREQUENCY_R(session->rate) || f > MAX_FREQUENCY_R(session->rate)) {
v = 99999.0; v = 99999.0;
RESET_SMA_BUFFER(&session->sma_b); RESET_SMA_BUFFER(&session->sma_b);
RESET_SMA_BUFFER(&session->sqa_b); RESET_SMA_BUFFER(&session->sqa_b);
} else { } else {
APPEND_SMA_VAL(&session->sma_b, f); APPEND_SMA_VAL(&session->sma_b, f);
APPEND_SMA_VAL(&session->sqa_b, f * f); APPEND_SMA_VAL(&session->sqa_b, f * f);
/* calculate variance */
v = session->sqa_b.sma - (session->sma_b.sma * session->sma_b.sma);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD v=%f f=%f %fHz sma=%f sqa=%f >>>\n", v, f, TO_HZ(session->rate, f), session->sma_b.sma, session->sqa_b.sma); /* calculate variance */
} v = session->sqa_b.sma - (session->sma_b.sma * session->sma_b.sma);
/*! If variance is less than threshold then we have detection */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD v=%f f=%f %fHz sma=%f sqa=%f >>>\n", v, f, TO_HZ(session->rate, f), session->sma_b.sma, session->sqa_b.sma);
if(v < VARIANCE_THRESHOLD){ }
/*! If variance is less than threshold then we have detection */
if(v < VARIANCE_THRESHOLD){
switch_channel_execute_on(switch_core_session_get_channel(session->session), "execute_on_avmd_beep"); switch_channel_execute_on(switch_core_session_get_channel(session->session), "execute_on_avmd_beep");
/*! Throw an event to FreeSWITCH */ /*! Throw an event to FreeSWITCH */
status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP); status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP);
if(status != SWITCH_STATUS_SUCCESS) { if(status != SWITCH_STATUS_SUCCESS) {
return; return;
} }
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "stop"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "stop");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session->session)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session->session));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "avmd"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "avmd");
if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) { if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) {
return; return;
} }
switch_core_session_queue_event(session->session, &event); switch_core_session_queue_event(session->session, &event);
switch_event_fire(&event_copy); switch_event_fire(&event_copy);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD - Beep Detected >>>\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_DEBUG, "<<< AVMD - Beep Detected >>>\n");
switch_channel_set_variable(channel, "avmd_detect", "TRUE"); switch_channel_set_variable(channel, "avmd_detect", "TRUE");
RESET_SMA_BUFFER(&session->sma_b); RESET_SMA_BUFFER(&session->sma_b);
RESET_SMA_BUFFER(&session->sqa_b); RESET_SMA_BUFFER(&session->sqa_b);
session->state.beep_state = BEEP_DETECTED; session->state.beep_state = BEEP_DETECTED;
return; return;
} }
//amp = 0.0; //amp = 0.0;
//success = 0.0; //success = 0.0;
//error = 0.0; //error = 0.0;
} }
} }
session->pos = pos; session->pos = pos;
} }
/* For Emacs: /* For Emacs: