FS-9143 [avmd] #fix event headers

Make all headers starting from capital letter.
This commit is contained in:
Piotr Gregor 2016-06-24 18:36:55 +01:00
parent c8e0eaace7
commit 9e0ade83b8
17 changed files with 159 additions and 147 deletions

View File

@ -1,4 +1,9 @@
#ifndef __AVMD_AMPLITUDE_H__
/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/
#include <math.h>
@ -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__ */

View File

@ -4,7 +4,7 @@
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrek.gregor gmail.com>:
* Piotr Gregor <piotrgregor@rsyncme.org>
*/

View File

@ -1,3 +1,10 @@
/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
*/
#ifndef __BUFFER_H__
#include "avmd_buffer.h"
#endif

View File

@ -1,8 +1,10 @@
/*
* @brief Circular buffer.
*
* @author Eric des Courtis
* @par Modifications: Piotr Gregor < piotrek.gregor gmail.com >
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/

View File

@ -1,5 +1,9 @@
#ifndef __AVMD_DESA2_H__
/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/
#include <stdio.h>
#ifdef WIN32
@ -63,5 +67,3 @@ double avmd_desa2(circ_buffer_t *b, size_t i, double *amplitude) {
return result;
}
#endif /* __AVMD_DESA2_H__ */

View File

@ -4,7 +4,7 @@
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrek.gregor gmail.com>:
* Piotr Gregor <piotrgregor@rsyncme.org>
*/

View File

@ -1,22 +1,32 @@
/*
* Contributor(s):
*
* Piotr Gregor <piotrgregor@rsyncme.org>
*/
#ifndef __AVMD_DESA2_TWEAKED_H__
#include "avmd_desa2_tweaked.h"
#endif
#include <switch.h>
#include <stdio.h>
#ifdef WIN32
#include <float.h>
#define ISNAN(x) (!!(_isnan(x)))
#define ISINF(x) (isinf(x))
#include <float.h>
#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__ */

View File

@ -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 <piotrgregor@rsyncme.org>
*
* @date 20 Mar 2016
*/

View File

@ -1,25 +1,39 @@
/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/
#ifndef WIN32 /* currently we support fast acosf computation only on UNIX/Linux */
#include <switch.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef _MSC_VER
#include <stdint.h>
#include <stdint.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifndef _MSC_VER
#include <sys/mman.h>
#include <sys/mman.h>
#endif
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <string.h>
#ifndef _MSC_VER
#include <unistd.h>
#include <unistd.h>
#endif
#include "avmd_fast_acosf.h"
#include "avmd_options.h"

View File

@ -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 <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrek.gregor gmail.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/

View File

@ -1,6 +1,10 @@
/*
* @brief Filters.
* @author Piotr Gregor < piotrek.gregor gmail.com >
*
* Contributor(s):
*
* Piotr Gregor <piotrgregor@rsyncme.org>
*
* @date 23 Mar 2016
*/

View File

@ -1,9 +1,19 @@
#ifndef __AVMD_GOERTZEL_H__
/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
*/
#include <math.h>
#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__ */

View File

@ -1,6 +1,9 @@
/*
* @brief Goertzel algorithm.
* @author Eric des Courtis
*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
*/
@ -9,13 +12,14 @@
#ifndef _MSC_VER
#include <stdint.h>
#include <stdint.h>
#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

View File

@ -5,8 +5,7 @@
*
* Contributor(s):
*
* Piotr Gregor <piotrek.gregor gmail.com>:
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/

View File

@ -1,3 +1,11 @@
/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/
#ifndef __AVMD_PSI_H__
#define __AVMD_PSI_H__

View File

@ -4,7 +4,7 @@
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrek.gregor gmail.com>
* Piotr Gregor <piotrgregor@rsyncme.org>
*/

View File

@ -20,7 +20,7 @@
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
* Piotr Gregor <piotrek.gregor gmail.com>:
* Piotr Gregor <piotrgregor@rsyncme.org>
*
* 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);
}