From 9e0ade83b88113e4a50aacee440a97ddde0a2c1c Mon Sep 17 00:00:00 2001 From: Piotr Gregor Date: Fri, 24 Jun 2016 18:36:55 +0100 Subject: [PATCH] FS-9143 [avmd] #fix event headers Make all headers starting from capital letter. --- .../applications/mod_avmd/avmd_amplitude.c | 11 +- .../applications/mod_avmd/avmd_amplitude.h | 2 +- src/mod/applications/mod_avmd/avmd_buffer.c | 7 + src/mod/applications/mod_avmd/avmd_buffer.h | 6 +- src/mod/applications/mod_avmd/avmd_desa2.c | 10 +- src/mod/applications/mod_avmd/avmd_desa2.h | 2 +- .../mod_avmd/avmd_desa2_tweaked.c | 28 +-- .../mod_avmd/avmd_desa2_tweaked.h | 6 +- .../applications/mod_avmd/avmd_fast_acosf.c | 20 ++- .../applications/mod_avmd/avmd_fast_acosf.h | 3 +- src/mod/applications/mod_avmd/avmd_fir.h | 6 +- src/mod/applications/mod_avmd/avmd_goertzel.c | 19 ++- src/mod/applications/mod_avmd/avmd_goertzel.h | 12 +- src/mod/applications/mod_avmd/avmd_options.h | 3 +- src/mod/applications/mod_avmd/avmd_psi.h | 8 + src/mod/applications/mod_avmd/avmd_sma_buf.h | 2 +- src/mod/applications/mod_avmd/mod_avmd.c | 161 ++++++------------ 17 files changed, 159 insertions(+), 147 deletions(-) diff --git a/src/mod/applications/mod_avmd/avmd_amplitude.c b/src/mod/applications/mod_avmd/avmd_amplitude.c index 16f1312d04..86523fad4b 100644 --- a/src/mod/applications/mod_avmd/avmd_amplitude.c +++ b/src/mod/applications/mod_avmd/avmd_amplitude.c @@ -1,4 +1,9 @@ -#ifndef __AVMD_AMPLITUDE_H__ +/* + * Contributor(s): + * + * Eric des Courtis + * Piotr Gregor + */ #include @@ -11,7 +16,3 @@ double avmd_amplitude(circ_buffer_t *b, size_t i, double f) { result = sqrt(PSI(b, i) / sin(f * f)); return result; } - - -#endif /* __AVMD_AMPLITUDE_H__ */ - diff --git a/src/mod/applications/mod_avmd/avmd_amplitude.h b/src/mod/applications/mod_avmd/avmd_amplitude.h index 0878390935..da98d083e5 100644 --- a/src/mod/applications/mod_avmd/avmd_amplitude.h +++ b/src/mod/applications/mod_avmd/avmd_amplitude.h @@ -4,7 +4,7 @@ * Contributor(s): * * Eric des Courtis - * Piotr Gregor : + * Piotr Gregor */ diff --git a/src/mod/applications/mod_avmd/avmd_buffer.c b/src/mod/applications/mod_avmd/avmd_buffer.c index a1fe28fd67..f05f0deb4c 100644 --- a/src/mod/applications/mod_avmd/avmd_buffer.c +++ b/src/mod/applications/mod_avmd/avmd_buffer.c @@ -1,3 +1,10 @@ +/* + * Contributor(s): + * + * Eric des Courtis + */ + + #ifndef __BUFFER_H__ #include "avmd_buffer.h" #endif diff --git a/src/mod/applications/mod_avmd/avmd_buffer.h b/src/mod/applications/mod_avmd/avmd_buffer.h index 345a624ed6..b7a6cbb233 100644 --- a/src/mod/applications/mod_avmd/avmd_buffer.h +++ b/src/mod/applications/mod_avmd/avmd_buffer.h @@ -1,8 +1,10 @@ /* * @brief Circular buffer. * - * @author Eric des Courtis - * @par Modifications: Piotr Gregor < piotrek.gregor gmail.com > + * Contributor(s): + * + * Eric des Courtis + * Piotr Gregor */ diff --git a/src/mod/applications/mod_avmd/avmd_desa2.c b/src/mod/applications/mod_avmd/avmd_desa2.c index 2f35d3beb5..c71ded6d06 100644 --- a/src/mod/applications/mod_avmd/avmd_desa2.c +++ b/src/mod/applications/mod_avmd/avmd_desa2.c @@ -1,5 +1,9 @@ -#ifndef __AVMD_DESA2_H__ - +/* + * Contributor(s): + * + * Eric des Courtis + * Piotr Gregor + */ #include #ifdef WIN32 @@ -63,5 +67,3 @@ double avmd_desa2(circ_buffer_t *b, size_t i, double *amplitude) { return result; } - -#endif /* __AVMD_DESA2_H__ */ diff --git a/src/mod/applications/mod_avmd/avmd_desa2.h b/src/mod/applications/mod_avmd/avmd_desa2.h index d555df448e..6e8f6e58a7 100644 --- a/src/mod/applications/mod_avmd/avmd_desa2.h +++ b/src/mod/applications/mod_avmd/avmd_desa2.h @@ -4,7 +4,7 @@ * Contributor(s): * * Eric des Courtis - * Piotr Gregor : + * Piotr Gregor */ diff --git a/src/mod/applications/mod_avmd/avmd_desa2_tweaked.c b/src/mod/applications/mod_avmd/avmd_desa2_tweaked.c index f1ad5243d6..6bf0b41348 100644 --- a/src/mod/applications/mod_avmd/avmd_desa2_tweaked.c +++ b/src/mod/applications/mod_avmd/avmd_desa2_tweaked.c @@ -1,22 +1,32 @@ +/* + * Contributor(s): + * + * Piotr Gregor + */ + #ifndef __AVMD_DESA2_TWEAKED_H__ + #include "avmd_desa2_tweaked.h" +#endif #include #include + #ifdef WIN32 -#include -#define ISNAN(x) (!!(_isnan(x))) -#define ISINF(x) (isinf(x)) + #include + #define ISNAN(x) (!!(_isnan(x))) + #define ISINF(x) (isinf(x)) #else -int __isnan(double); -#define ISNAN(x) (__isnan(x)) -#define ISINF(x) (__isinf(x)) + int __isnan(double); + #define ISNAN(x) (__isnan(x)) + #define ISINF(x) (__isinf(x)) #endif + #include "avmd_buffer.h" #include "avmd_desa2_tweaked.h" #include "avmd_options.h" -#ifdef AVMD_FAST_MATH -#include "avmd_fast_acosf.h" +#ifndef AVMD_FAST_MATH + #include "avmd_fast_acosf.h" #endif @@ -64,5 +74,3 @@ avmd_desa2_tweaked(circ_buffer_t *b, size_t i, double *amplitude) { *amplitude = 2.0 * PSI_Xn / sqrt(PSI_Yn); return result; } - -#endif /* __AVMD_DESA2_TWEAKED_H__ */ diff --git a/src/mod/applications/mod_avmd/avmd_desa2_tweaked.h b/src/mod/applications/mod_avmd/avmd_desa2_tweaked.h index 2d16ca2972..ac6d6fc4d8 100644 --- a/src/mod/applications/mod_avmd/avmd_desa2_tweaked.h +++ b/src/mod/applications/mod_avmd/avmd_desa2_tweaked.h @@ -7,7 +7,11 @@ * be checked for convergence in the same time. * If the partial results converge then frequency * converges too. - * @author Piotr Gregor < piotrek.gregor gmail.com > + * + * Contributor(s): + * + * Piotr Gregor + * * @date 20 Mar 2016 */ diff --git a/src/mod/applications/mod_avmd/avmd_fast_acosf.c b/src/mod/applications/mod_avmd/avmd_fast_acosf.c index cb0500b315..cd728bd577 100644 --- a/src/mod/applications/mod_avmd/avmd_fast_acosf.c +++ b/src/mod/applications/mod_avmd/avmd_fast_acosf.c @@ -1,25 +1,39 @@ +/* + * Contributor(s): + * + * Eric des Courtis + * Piotr Gregor + */ + + #ifndef WIN32 /* currently we support fast acosf computation only on UNIX/Linux */ #include #include #include + #ifndef _MSC_VER -#include + #include #endif + #include #include #include + #ifndef _MSC_VER -#include + #include #endif + #include #include #include #include + #ifndef _MSC_VER -#include + #include #endif + #include "avmd_fast_acosf.h" #include "avmd_options.h" diff --git a/src/mod/applications/mod_avmd/avmd_fast_acosf.h b/src/mod/applications/mod_avmd/avmd_fast_acosf.h index 0b9752713f..8de7954def 100644 --- a/src/mod/applications/mod_avmd/avmd_fast_acosf.h +++ b/src/mod/applications/mod_avmd/avmd_fast_acosf.h @@ -1,10 +1,11 @@ #ifndef WIN32 /* currently we support fast acosf computation only on UNIX/Linux */ /* * @brief Fast arithmetic using precomputed arc cosine table. + * * Contributor(s): * * Eric des Courtis - * Piotr Gregor + * Piotr Gregor */ diff --git a/src/mod/applications/mod_avmd/avmd_fir.h b/src/mod/applications/mod_avmd/avmd_fir.h index 76888a7ab2..23860f5887 100644 --- a/src/mod/applications/mod_avmd/avmd_fir.h +++ b/src/mod/applications/mod_avmd/avmd_fir.h @@ -1,6 +1,10 @@ /* * @brief Filters. - * @author Piotr Gregor < piotrek.gregor gmail.com > + * + * Contributor(s): + * + * Piotr Gregor + * * @date 23 Mar 2016 */ diff --git a/src/mod/applications/mod_avmd/avmd_goertzel.c b/src/mod/applications/mod_avmd/avmd_goertzel.c index 6fdfafc0c8..3c58ffbe51 100644 --- a/src/mod/applications/mod_avmd/avmd_goertzel.c +++ b/src/mod/applications/mod_avmd/avmd_goertzel.c @@ -1,9 +1,19 @@ -#ifndef __AVMD_GOERTZEL_H__ +/* + * Contributor(s): + * + * Eric des Courtis + */ #include -#include "avmd_goertzel.h" -#include "avmd_buffer.h" + +#ifndef __AVMD_GOERTZEL_H__ + #include "avmd_goertzel.h" +#endif + +#ifndef __AVMD_BUFFER_H__ + #include "avmd_buffer.h" +#endif extern double avmd_goertzel(circ_buffer_t *b, size_t pos, double f, size_t num) @@ -25,6 +35,3 @@ extern double avmd_goertzel(circ_buffer_t *b, size_t pos, double f, size_t num) return (p2 * p2) + (p * p) - (coeff * p2 * p); } - - -#endif /* __AVMD_GOERTZEL_H__ */ diff --git a/src/mod/applications/mod_avmd/avmd_goertzel.h b/src/mod/applications/mod_avmd/avmd_goertzel.h index fefb74271b..21ba3f5154 100644 --- a/src/mod/applications/mod_avmd/avmd_goertzel.h +++ b/src/mod/applications/mod_avmd/avmd_goertzel.h @@ -1,6 +1,9 @@ /* * @brief Goertzel algorithm. - * @author Eric des Courtis + * + * Contributor(s): + * + * Eric des Courtis */ @@ -9,13 +12,14 @@ #ifndef _MSC_VER -#include + #include #endif + #include "avmd_buffer.h" #if !defined(M_PI) -/* C99 systems may not define M_PI */ -#define M_PI 3.14159265358979323846264338327 + /* C99 systems may not define M_PI */ + #define M_PI 3.14159265358979323846264338327 #endif diff --git a/src/mod/applications/mod_avmd/avmd_options.h b/src/mod/applications/mod_avmd/avmd_options.h index d5c39368d5..a580af811e 100644 --- a/src/mod/applications/mod_avmd/avmd_options.h +++ b/src/mod/applications/mod_avmd/avmd_options.h @@ -5,8 +5,7 @@ * * Contributor(s): * - * Piotr Gregor : - * Eric des Courtis + * Piotr Gregor */ diff --git a/src/mod/applications/mod_avmd/avmd_psi.h b/src/mod/applications/mod_avmd/avmd_psi.h index db6d83a60e..dbbf401282 100644 --- a/src/mod/applications/mod_avmd/avmd_psi.h +++ b/src/mod/applications/mod_avmd/avmd_psi.h @@ -1,3 +1,11 @@ +/* + * Contributor(s): + * + * Eric des Courtis + * Piotr Gregor + */ + + #ifndef __AVMD_PSI_H__ #define __AVMD_PSI_H__ diff --git a/src/mod/applications/mod_avmd/avmd_sma_buf.h b/src/mod/applications/mod_avmd/avmd_sma_buf.h index b514b95bea..5c5c6a108a 100644 --- a/src/mod/applications/mod_avmd/avmd_sma_buf.h +++ b/src/mod/applications/mod_avmd/avmd_sma_buf.h @@ -4,7 +4,7 @@ * Contributor(s): * * Eric des Courtis - * Piotr Gregor + * Piotr Gregor */ diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index d7035d40b6..1f1f1aceb9 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -20,7 +20,7 @@ * Contributor(s): * * Eric des Courtis - * Piotr Gregor : + * Piotr Gregor * * mod_avmd.c -- Advanced Voicemail Detection Module * @@ -221,12 +221,10 @@ static switch_status_t avmd_load_xml_inbound_configuration(switch_mutex_t *mutex static switch_status_t avmd_load_xml_outbound_configuration(switch_mutex_t *mutex); /* bind reloadxml callback */ -static void -avmd_reloadxml_event_handler(switch_event_t *event); +static void avmd_reloadxml_event_handler(switch_event_t *event); /* API command */ -static void -avmd_show(switch_stream_handle_t *stream, switch_mutex_t *mutex); +static void avmd_show(switch_stream_handle_t *stream, switch_mutex_t *mutex); /*! \brief The avmd session data initialization function. @@ -371,8 +369,7 @@ avmd_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type) } } avmd_session->start_time = switch_micro_time_now(); - /* avmd_session->vmd_codec.channels = - * read_codec->implementation->number_of_channels; */ + /* avmd_session->vmd_codec.channels = read_codec->implementation->number_of_channels; */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session),SWITCH_LOG_INFO, "Avmd session initialized, [%u] samples/s\n", avmd_session->rate); break; @@ -442,8 +439,9 @@ avmd_fire_event(enum avmd_event type, switch_core_session_t *fs_s, double freq, return; } switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(fs_s)); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "avmd"); - switch (type) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-command", "avmd"); + switch (type) + { case AVMD_EVENT_BEEP: switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "DETECTED"); res = snprintf(buf, AVMD_CHAR_BUF_LEN, "%f", freq); @@ -496,7 +494,7 @@ avmd_fire_event(enum avmd_event type, switch_core_session_t *fs_s, double freq, switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", beep_status == BEEP_DETECTED ? "DETECTED" : "NOTDETECTED"); if (info == 0) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_s), SWITCH_LOG_ERROR, "Error, avmd session object not found in media bug!\n"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "stop-status", "ERROR (AVMD SESSION OBJECT NOT FOUND IN MEDIA BUG)"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Stop-status", "ERROR (AVMD SESSION OBJECT NOT FOUND IN MEDIA BUG)"); } total_time = stop_time - start_time; res = snprintf(buf, AVMD_CHAR_BUF_LEN, "%" PRId64 "", total_time); @@ -642,16 +640,12 @@ avmd_load_xml_configuration(switch_mutex_t *mutex) } else if (!strcmp(name, "require_continuous_streak")) { avmd_globals.settings.require_continuous_streak = switch_true(value) ? 1 : 0; } else if (!strcmp(name, "sample_n_continuous_streak")) { - if(avmd_parse_u16_user_input(value, - &avmd_globals.settings.sample_n_continuous_streak, 0, UINT16_MAX) == -1) - { + if(avmd_parse_u16_user_input(value, &avmd_globals.settings.sample_n_continuous_streak, 0, UINT16_MAX) == -1) { status = SWITCH_STATUS_TERM; goto done; } } else if (!strcmp(name, "sample_n_to_skip")) { - if(avmd_parse_u16_user_input(value, - &avmd_globals.settings.sample_n_to_skip, 0, UINT16_MAX) == -1) - { + if(avmd_parse_u16_user_input(value, &avmd_globals.settings.sample_n_to_skip, 0, UINT16_MAX) == -1) { status = SWITCH_STATUS_TERM; goto done; } @@ -1074,7 +1068,7 @@ SWITCH_STANDARD_APP(avmd_start_app) goto end; } - if (avmd_session->settings.report_status == 1) { /* report dynamic parameters */ + if (avmd_session->settings.report_status == 1) { /* dump dynamic parameters */ avmd_config_dump(avmd_session); } if (avmd_session->settings.outbound_channnel == 1) { @@ -1259,9 +1253,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) } /*! \brief FreeSWITCH API handler function. - * This function handles API calls such as the ones - * from mod_event_socket and in some cases - * scripts such as LUA scripts. + * This function handles API calls from mod_event_socket and LUA scripts. */ SWITCH_STANDARD_API(avmd_api_main) { @@ -1280,8 +1272,7 @@ SWITCH_STANDARD_API(avmd_api_main) /* No command? Display usage */ if (zstr(cmd)) { - stream->write_function(stream, "-ERR, bad command!\n" - "-USAGE: %s\n\n", AVMD_SYNTAX); + stream->write_function(stream, "-ERR, bad command!\n-USAGE: %s\n\n", AVMD_SYNTAX); goto end; } @@ -1301,23 +1292,21 @@ SWITCH_STANDARD_API(avmd_api_main) command = argv[0]; if (strcasecmp(command, "reload") == 0) { - if (avmd_load_xml_configuration(NULL) != SWITCH_STATUS_SUCCESS) - { - stream->write_function(stream, "-ERR, couldn't reload XML configuration\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Couldn't reload XML configuration\n"); - } + status = avmd_load_xml_configuration(NULL); if (avmd_globals.settings.report_status == 1) { - stream->write_function(stream, "+OK\n XML reloaded\n\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "XML reloaded\n"); + if (status != SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "-ERR, couldn't reload XML configuration\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't reload XML configuration\n"); + } else { + stream->write_function(stream, "+OK\n XML reloaded\n\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "XML reloaded\n"); + } + goto end; } - goto end; } if (strcasecmp(command, "load") == 0) { if (argc != 2) { - stream->write_function(stream, "-ERR, load command takes 1 parameter!\n" - "-USAGE: %s\n\n", AVMD_SYNTAX); + stream->write_function(stream, "-ERR, load command takes 1 parameter!\n-USAGE: %s\n\n", AVMD_SYNTAX); goto end; } command = argv[1]; @@ -1326,13 +1315,10 @@ SWITCH_STANDARD_API(avmd_api_main) if (avmd_globals.settings.report_status == 1) { if (status != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR, couldn't load XML configuration\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Couldn't load XML configuration\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load XML configuration\n"); } else { - stream->write_function(stream, "+OK\n inbound " - "XML configuration loaded\n\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Inbound XML configuration loaded\n"); + stream->write_function(stream, "+OK\n inbound XML configuration loaded\n\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Inbound XML configuration loaded\n"); } goto end; } @@ -1341,56 +1327,44 @@ SWITCH_STANDARD_API(avmd_api_main) if (avmd_globals.settings.report_status == 1) { if (status != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR, couldn't load XML configuration\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Couldn't load XML configuration\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load XML configuration\n"); } else { - stream->write_function(stream, "+OK\n outbound " - "XML configuration loaded\n\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Outbound XML configuration loaded\n"); + stream->write_function(stream, "+OK\n outbound XML configuration loaded\n\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Outbound XML configuration loaded\n"); } goto end; } } else { - stream->write_function(stream, "-ERR, load command: bad syntax!\n" - "-USAGE: %s\n\n", AVMD_SYNTAX); + stream->write_function(stream, "-ERR, load command: bad syntax!\n-USAGE: %s\n\n", AVMD_SYNTAX); } goto end; } if (strcasecmp(command, "set") == 0) { if (argc != 2) { - stream->write_function(stream, "-ERR, set command takes 1 parameter!\n" - "-USAGE: %s\n\n", AVMD_SYNTAX); + stream->write_function(stream, "-ERR, set command takes 1 parameter!\n-USAGE: %s\n\n", AVMD_SYNTAX); goto end; } command = argv[1]; if (strcasecmp(command, "inbound") == 0) { avmd_set_xml_inbound_configuration(NULL); if (avmd_globals.settings.report_status == 1) { - stream->write_function(stream, "+OK\n inbound " - "XML configuration loaded\n\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Inbound XML configuration loaded\n"); + stream->write_function(stream, "+OK\n inbound XML configuration loaded\n\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Inbound XML configuration loaded\n"); } } else if (strcasecmp(command, "outbound") == 0) { avmd_set_xml_outbound_configuration(NULL); if (avmd_globals.settings.report_status == 1) { - stream->write_function(stream, "+OK\n outbound " - "XML configuration loaded\n\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Outbound XML configuration loaded\n"); + stream->write_function(stream, "+OK\n outbound XML configuration loaded\n\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Outbound XML configuration loaded\n"); } } else if (strcasecmp(command, "default") == 0) { avmd_set_xml_default_configuration(NULL); if (avmd_globals.settings.report_status == 1) { - stream->write_function(stream, "+OK\n reset " - "to factory settings\n\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, - "Reset to factory settings\n"); + stream->write_function(stream, "+OK\n reset to factory settings\n\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Reset to factory settings\n"); } } else { - stream->write_function(stream, "-ERR, set command: bad syntax!\n" - "-USAGE: %s\n\n", AVMD_SYNTAX); + stream->write_function(stream, "-ERR, set command: bad syntax!\n-USAGE: %s\n\n", AVMD_SYNTAX); } goto end; } @@ -1410,8 +1384,7 @@ SWITCH_STANDARD_API(avmd_api_main) /* If the session was not found exit */ if (fs_session == NULL) { - stream->write_function(stream, "-ERR, no FreeSWITCH session for uuid [%s]!" - "\n-USAGE: %s\n\n", uuid, AVMD_SYNTAX); + stream->write_function(stream, "-ERR, no FreeSWITCH session for uuid [%s]!\n-USAGE: %s\n\n", uuid, AVMD_SYNTAX); goto end; } @@ -1450,10 +1423,8 @@ SWITCH_STANDARD_API(avmd_api_main) } if (avmd_globals.settings.report_status == 1) { /* We have already started */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), - SWITCH_LOG_ERROR, "Avmd already started!\n"); - stream->write_function(stream, "-ERR, avmd for FreeSWITCH session [%s]" - "\n already started\n\n", uuid); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Avmd already started!\n"); + stream->write_function(stream, "-ERR, avmd for FreeSWITCH session [%s]\n already started\n\n", uuid); } goto end; } @@ -1463,16 +1434,14 @@ SWITCH_STANDARD_API(avmd_api_main) stream->write_function(stream, "+ERR, avmd has not yet been started on\n" " [%s] [%s]\n\n", uuid_dup, switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, - "Stop failed - avmd has not yet been started on channel [%s]!\n", - switch_channel_get_name(channel)); + "Stop failed - avmd has not yet been started on channel [%s]!\n", switch_channel_get_name(channel)); goto end; } if (avmd_globals.settings.outbound_channnel == 1) { if (SWITCH_CALL_DIRECTION_OUTBOUND != switch_channel_direction(channel)) { stream->write_function(stream, "-ERR, channel for FreeSWITCH session [%s]" "\n is not outbound\n\n", uuid); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, - "Channel [%s] is not outbound!\n", switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Channel [%s] is not outbound!\n", switch_channel_get_name(channel)); goto end; } else { flags |= SMBF_READ_REPLACE; @@ -1482,8 +1451,7 @@ SWITCH_STANDARD_API(avmd_api_main) if (SWITCH_CALL_DIRECTION_INBOUND != switch_channel_direction(channel)) { stream->write_function(stream, "-ERR, channel for FreeSWITCH session [%s]" "\n is not inbound\n\n", uuid); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, - "Channel [%s] is not inbound!\n", switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Channel [%s] is not inbound!\n", switch_channel_get_name(channel)); goto end; } else { flags |= SMBF_WRITE_REPLACE; @@ -1500,11 +1468,9 @@ SWITCH_STANDARD_API(avmd_api_main) if (avmd_globals.settings.outbound_channnel == 1) { if (switch_channel_test_flag(channel, CF_MEDIA_SET) == 0) { stream->write_function(stream, "-ERR, channel [%s] for FreeSWITCH session [%s]" - "\n has no read codec assigned yet. Please try again.\n\n", - switch_channel_get_name(channel), uuid); + "\n has no read codec assigned yet. Please try again.\n\n", switch_channel_get_name(channel), uuid); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, - "Failed to start session. Channel [%s] has no codec assigned yet." - " Please try again\n", switch_channel_get_name(channel)); + "Failed to start session. Channel [%s] has no codec assigned yet. Please try again\n", switch_channel_get_name(channel)); goto end; } } @@ -1517,32 +1483,23 @@ SWITCH_STANDARD_API(avmd_api_main) avmd_session = (avmd_session_t *) switch_core_session_alloc(fs_session, sizeof(avmd_session_t)); /* Allocate memory attached to this FreeSWITCH session for use in the callback routine and to store state information */ status = init_avmd_session_data(avmd_session, fs_session, NULL); if (status != SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "-ERR, failed to initialize avmd session\n" - " for FreeSWITCH session [%s]\n", uuid); + stream->write_function(stream, "-ERR, failed to initialize avmd session\n for FreeSWITCH session [%s]\n", uuid); switch (status) { case SWITCH_STATUS_MEMERR: stream->write_function(stream, "-ERR, buffer error\n\n"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), - SWITCH_LOG_ERROR, "Failed to init avmd session." - " Buffer error!\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Failed to init avmd session. Buffer error!\n"); break; case SWITCH_STATUS_MORE_DATA: stream->write_function(stream, "-ERR, SMA buffer size is 0\n\n"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), - SWITCH_LOG_ERROR, "Failed to init avmd session." - " SMA buffer size is 0!\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Failed to init avmd session. SMA buffer size is 0!\n"); break; case SWITCH_STATUS_FALSE: stream->write_function(stream, "-ERR, SMA buffer error\n\n"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), - SWITCH_LOG_ERROR, "Failed to init avmd session." - " SMA buffers error\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Failed to init avmd session. SMA buffers error\n"); break; default: stream->write_function(stream, "-ERR, unknown error\n\n"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), - SWITCH_LOG_ERROR, "Failed to init avmd session." - " Unknown error\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Failed to init avmd session. Unknown error\n"); break; } goto end; @@ -1551,10 +1508,8 @@ SWITCH_STANDARD_API(avmd_api_main) status = switch_core_media_bug_add(fs_session, "avmd", NULL, avmd_callback, avmd_session, 0, flags, &bug); /* Add a media bug that allows me to intercept the reading leg of the audio stream */ if (status != SWITCH_STATUS_SUCCESS) { /* If adding a media bug fails exit */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), - SWITCH_LOG_ERROR, "Failed to add media bug!\n"); - stream->write_function(stream, - "-ERR, [%s] failed to add media bug!\n\n", uuid); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_ERROR, "Failed to add media bug!\n"); + stream->write_function(stream, "-ERR, [%s] failed to add media bug!\n\n", uuid); goto end; } @@ -1562,10 +1517,8 @@ SWITCH_STANDARD_API(avmd_api_main) avmd_fire_event(AVMD_EVENT_SESSION_START, fs_session, 0, 0, 0, 0, 0, 0, 0, 0, avmd_session->start_time, 0); if (avmd_globals.settings.report_status == 1) { - stream->write_function(stream, "+OK\n [%s] [%s] started!\n\n", - uuid, switch_channel_get_name(channel)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_INFO, - "Avmd on channel [%s] started!\n", switch_channel_get_name(channel)); + stream->write_function(stream, "+OK\n [%s] [%s] started!\n\n", uuid, switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_session), SWITCH_LOG_INFO, "Avmd on channel [%s] started!\n", switch_channel_get_name(channel)); switch_assert(status == SWITCH_STATUS_SUCCESS); } end: @@ -1741,9 +1694,7 @@ done: return; } -static void -avmd_reloadxml_event_handler(switch_event_t *event) -{ +static void avmd_reloadxml_event_handler(switch_event_t *event) { avmd_load_xml_configuration(avmd_globals.mutex); }