Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
January 2009
- 18 participants
- 356 discussions
15 Jan '09
Author: rupa
Date: Thu Jan 15 15:51:15 2009
New Revision: 11232
Log:
move svn braces
Modified:
freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c
Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Thu Jan 15 15:51:15 2009
@@ -131,7 +131,8 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lcr_shutdown);
SWITCH_MODULE_DEFINITION(mod_lcr, mod_lcr_load, mod_lcr_shutdown, NULL);
-static char *get_bridge_data(const char *dialed_number, lcr_route cur_route) {
+static char *get_bridge_data(const char *dialed_number, lcr_route cur_route)
+{
size_t lstrip;
size_t tstrip;
char *data = NULL;
@@ -158,7 +159,8 @@
return data;
}
-void init_max_lens(max_len maxes) {
+void init_max_lens(max_len maxes)
+{
maxes->digit_str = (headers[LCR_DIGITS_PLACE] == NULL ? 0 : strlen(headers[LCR_DIGITS_PLACE]));
maxes->carrier_name = (headers[LCR_CARRIER_PLACE] == NULL ? 0 : strlen(headers[LCR_CARRIER_PLACE]));
maxes->dialstring = (headers[LCR_DIALSTRING_PLACE] == NULL ? 0 : strlen(headers[LCR_DIALSTRING_PLACE]));
@@ -166,7 +168,8 @@
maxes->rate = 8;
}
-switch_status_t process_max_lengths(max_obj_t *maxes, lcr_route routes, char *destination_number) {
+switch_status_t process_max_lengths(max_obj_t *maxes, lcr_route routes, char *destination_number)
+{
lcr_route current = NULL;
if (routes == NULL) {
@@ -211,7 +214,8 @@
}
/* try each type of random until we suceed */
-static switch_bool_t set_db_random() {
+static switch_bool_t set_db_random()
+{
char *sql = NULL;
if (globals.odbc_dsn) {
sql = "SELECT * FROM lcr ORDER BY rand() LIMIT 1";
@@ -231,7 +235,8 @@
}
/* make a new string with digits only */
-static char* string_digitsonly(const char *str) {
+static char *string_digitsonly(const char *str)
+{
char *p, *np, *newstr;
size_t len;
@@ -253,7 +258,8 @@
return newstr;
}
-static switch_bool_t lcr_execute_sql_callback(char *sql, switch_core_db_callback_func_t callback, void *pdata) {
+static switch_bool_t lcr_execute_sql_callback(char *sql, switch_core_db_callback_func_t callback, void *pdata)
+{
if (globals.odbc_dsn) {
if(switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata)
== SWITCH_ODBC_FAIL) {
@@ -265,7 +271,8 @@
return SWITCH_FALSE;
}
-int route_add_callback(void *pArg, int argc, char **argv, char **columnNames) {
+int route_add_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
lcr_route additional = NULL;
lcr_route current = NULL;
callback_t *cbt = (callback_t *) pArg;
@@ -325,7 +332,8 @@
return SWITCH_STATUS_SUCCESS;
}
-switch_status_t lcr_do_lookup(callback_t *cb_struct, char *digits, char* profile_name) {
+switch_status_t lcr_do_lookup(callback_t *cb_struct, char *digits, char* profile_name)
+{
/* instantiate the object/struct we defined earlier */
switch_stream_handle_t sql_stream = { 0 };
size_t n, digit_len = strlen(digits);
@@ -380,7 +388,8 @@
}
}
-static switch_status_t lcr_load_config() {
+static switch_status_t lcr_load_config()
+{
char *cf = "lcr.conf";
switch_xml_t cfg, xml, settings, param, x_profile, x_profiles;
switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -513,7 +522,8 @@
return status;
}
-static void destroy_list(lcr_route *head) {
+static void destroy_list(lcr_route *head)
+{
lcr_route cur = NULL, top = *head;
while (top) {
@@ -531,7 +541,8 @@
*head = NULL;
}
-SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt) {
+SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt)
+{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
callback_t routes = { 0 };
@@ -569,7 +580,8 @@
return extension;
}
-void str_repeat(size_t how_many, char *what, switch_stream_handle_t *str_stream) {
+void str_repeat(size_t how_many, char *what, switch_stream_handle_t *str_stream)
+{
size_t i;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "repeating %d of '%s'\n", how_many, what);
@@ -629,7 +641,8 @@
}
}
-SWITCH_STANDARD_API(dialplan_lcr_function) {
+SWITCH_STANDARD_API(dialplan_lcr_function)
+{
char *argv[4] = { 0 };
int argc;
char *mydata = NULL;
@@ -731,7 +744,8 @@
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_MODULE_LOAD_FUNCTION(mod_lcr_load) {
+SWITCH_MODULE_LOAD_FUNCTION(mod_lcr_load)
+{
switch_api_interface_t *dialplan_lcr_api_interface;
switch_application_interface_t *app_interface;
switch_dialplan_interface_t *dp_interface;
@@ -770,7 +784,8 @@
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lcr_shutdown) {
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lcr_shutdown)
+{
return SWITCH_STATUS_SUCCESS;
}
1
0
15 Jan '09
Author: rupa
Date: Thu Jan 15 14:32:25 2009
New Revision: 11231
Log:
Ensure that mod_lcr digits only has digits
Modified:
freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c
Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c Thu Jan 15 14:32:25 2009
@@ -230,6 +230,29 @@
return SWITCH_FALSE;
}
+/* make a new string with digits only */
+static char* string_digitsonly(const char *str) {
+ char *p, *np, *newstr;
+ size_t len;
+
+ p = (char *)str;
+
+ len = strlen(str);
+ switch_zmalloc(newstr, len+1); /* worst case, same string */
+ np = newstr;
+
+ while(*p) {
+ if(switch_isdigit(*p)) {
+ *np = *p;
+ np++;
+ }
+ p++;
+ }
+ *np = '\0';
+
+ return newstr;
+}
+
static switch_bool_t lcr_execute_sql_callback(char *sql, switch_core_db_callback_func_t callback, void *pdata) {
if (globals.odbc_dsn) {
if(switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata)
@@ -322,8 +345,6 @@
return SWITCH_STATUS_FALSE;
}
- digits_copy = strdup(digits);
-
SWITCH_STANDARD_STREAM(sql_stream);
/* set up the query to be executed */
@@ -331,10 +352,12 @@
"SELECT l.digits, c.carrier_name, l.rate, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix "
);
sql_stream.write_function(&sql_stream, "FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN (");
+ digits_copy = string_digitsonly(digits);
for (n = digit_len; n > 0; n--) {
digits_copy[n] = '\0';
sql_stream.write_function(&sql_stream, "%s%s", (n==digit_len ? "" : ", "), digits_copy);
}
+ switch_safe_free(digits_copy);
sql_stream.write_function(&sql_stream, ") AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end ");
if(profile->id > 0) {
sql_stream.write_function(&sql_stream, "AND lcr_profile=%d ", profile->id);
1
0
15 Jan '09
Author: andrew
Date: Thu Jan 15 14:08:08 2009
New Revision: 11230
Log:
testing commit access to mod_portaudio
Modified:
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Thu Jan 15 14:08:08 2009
@@ -29,6 +29,7 @@
* mod_portaudio.c -- PortAudio Endpoint Module
*
*/
+
#include "switch.h"
#include <stdio.h>
1
0
Author: brian
Date: Thu Jan 15 13:20:05 2009
New Revision: 11228
Log:
add fsgdb
Modified:
freeswitch/trunk/support-d/.bashrc
Modified: freeswitch/trunk/support-d/.bashrc
==============================================================================
--- freeswitch/trunk/support-d/.bashrc (original)
+++ freeswitch/trunk/support-d/.bashrc Thu Jan 15 13:20:05 2009
@@ -26,4 +26,5 @@
alias mcommit='svn commit --no-auth-cache --username=mikej'
alias dp='emacs /usr/local/freeswitch/conf/dialplan/default.xml'
alias fstop='top -p `cat /usr/local/freeswitch/log/freeswitch.pid`'
+alias fsgdb='gdb /usr/local/freeswitch/bin/freeswitch `cat /usr/local/freeswitch/log/freeswitch.pid`'
# End of file
1
0
15 Jan '09
Author: anthm
Date: Thu Jan 15 12:39:51 2009
New Revision: 11227
Log:
apply portaudio patches from jira and add some fixes for linux
Modified:
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c
freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Thu Jan 15 12:39:51 2009
@@ -157,7 +157,7 @@
static int dump_info(int verbose);
static switch_status_t load_config(void);
static int get_dev_by_name(char *name, int in);
-static int get_dev_by_number(int number, int in);
+static int get_dev_by_number(char *numstr, int in);
SWITCH_STANDARD_API(pa_cmd);
/*
@@ -263,6 +263,7 @@
unsigned int pos = 0;
switch_core_file_seek(&fh, &pos, 0, SEEK_SET);
}
+
if (globals.ring_stream) {
WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.timer);
}
@@ -784,6 +785,10 @@
switch_console_set_complete("add pa indev");
switch_console_set_complete("add pa outdev");
switch_console_set_complete("add pa ringdev");
+ switch_console_set_complete("add pa play");
+ switch_console_set_complete("add pa ringtest");
+ switch_console_set_complete("add pa looptest");
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
@@ -836,19 +841,19 @@
set_global_cid_num(val);
} else if (!strcmp(var, "indev")) {
if (*val == '#') {
- globals.indev = get_dev_by_number(atoi(val + 1), 1);
+ globals.indev = get_dev_by_number(val + 1, 1);
} else {
globals.indev = get_dev_by_name(val, 1);
}
} else if (!strcmp(var, "outdev")) {
if (*val == '#') {
- globals.outdev = get_dev_by_number(atoi(val + 1), 0);
+ globals.outdev = get_dev_by_number(val + 1, 0);
} else {
globals.outdev = get_dev_by_name(val, 0);
}
} else if (!strcmp(var, "ringdev")) {
if (*val == '#') {
- globals.ringdev = get_dev_by_number(atoi(val + 1), 0);
+ globals.ringdev = get_dev_by_number(val + 1, 0);
} else {
globals.ringdev = get_dev_by_name(val, 0);
}
@@ -910,6 +915,8 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_portaudio_shutdown)
{
+
+
if (globals.read_codec.implementation) {
switch_core_codec_destroy(&globals.read_codec);
}
@@ -918,19 +925,30 @@
switch_core_codec_destroy(&globals.write_codec);
}
+
switch_core_timer_destroy(&globals.timer);
switch_core_timer_destroy(&globals.hold_timer);
Pa_Terminate();
switch_core_hash_destroy(&globals.call_hash);
+ switch_event_free_subclass(MY_EVENT_RINGING);
+
return SWITCH_STATUS_SUCCESS;
}
-static int get_dev_by_number(int number, int in)
+static int get_dev_by_number(char *numstr, int in)
{
int numDevices = Pa_GetDeviceCount();
const PaDeviceInfo *pdi;
+ char *end_ptr;
+ int number;
+
+ number = (int) strtol(numstr, &end_ptr, 10);
+
+ if (end_ptr == numstr || number < 0) {
+ return -1;
+ }
if (number > -1 && number < numDevices && (pdi = Pa_GetDeviceInfo(number))) {
if (in && pdi->maxInputChannels) {
@@ -974,11 +992,7 @@
}
}
- if (switch_strlen_zero(name)) {
- return -1;
- }
-
- return get_dev_by_name(NULL, in);
+ return -1;
}
@@ -1110,13 +1124,13 @@
inputParameters.device = i;
inputParameters.channelCount = deviceInfo->maxInputChannels;
inputParameters.sampleFormat = paInt16;
- inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
+ inputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; /* ignored by Pa_IsFormatSupported() */
inputParameters.hostApiSpecificStreamInfo = NULL;
-
+
outputParameters.device = i;
outputParameters.channelCount = deviceInfo->maxOutputChannels;
outputParameters.sampleFormat = paInt16;
- outputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
+ outputParameters.suggestedLatency = deviceInfo->defaultLowOutputLatency; /* ignored by Pa_IsFormatSupported() */
outputParameters.hostApiSpecificStreamInfo = NULL;
if (inputParameters.channelCount > 0) {
@@ -1131,7 +1145,7 @@
}
if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
-
+
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"full-duplex 16 bit %d channel input, %d channel output rates:", inputParameters.channelCount,
outputParameters.channelCount);
@@ -1226,6 +1240,9 @@
outputParameters.sampleFormat = SAMPLE_TYPE;
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
+ //err = OpenAudioStream(&globals.audio_stream, NULL/*&inputParameters*/, &outputParameters, sample_rate, paClipOff,
+ //globals.read_codec.implementation->samples_per_packet);
+
err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
globals.read_codec.implementation->samples_per_packet);
/* UNLOCKED ************************************************************************************************* */
@@ -1630,7 +1647,10 @@
"pa devlist\n"
"pa indev #<num>|<partial name>\n"
"pa outdev #<num>|<partial name>\n"
- "pa ringdev #<num>|<partial name>\n" "--------------------------------------------------------------------------------\n";
+ "pa ringdev #<num>|<partial name>\n"
+ "pa play <filename>\n"
+ "pa ringtest\n"
+ "pa looptest\n" "--------------------------------------------------------------------------------\n";
if (stream->param_event) {
@@ -1719,34 +1739,98 @@
func = dtmf_call;
} else if (argv[1] && !strcmp(argv[0], "indev")) {
if (*argv[1] == '#') {
- devval = get_dev_by_number(atoi(argv[1] + 1), 1);
+ devval = get_dev_by_number(argv[1] + 1, 1);
} else {
devval = get_dev_by_name(argv[1], 1);
}
devname = "indev";
- if (devval > 0) {
+ if (devval > -1) {
globals.indev = devval;
}
} else if (argv[1] && !strcmp(argv[0], "outdev")) {
if (*argv[1] == '#') {
- devval = get_dev_by_number(atoi(argv[1] + 1), 0);
+ devval = get_dev_by_number(argv[1] + 1, 0);
} else {
devval = get_dev_by_name(argv[1], 0);
}
devname = "outdev";
- if (devval > 0) {
+ if (devval > -1) {
globals.outdev = devval;
}
} else if (argv[1] && !strcmp(argv[0], "ringdev")) {
if (*argv[1] == '#') {
- devval = get_dev_by_number(atoi(argv[1] + 1), 0);
+ devval = get_dev_by_number(argv[1] + 1, 0);
} else {
devval = get_dev_by_name(argv[1], 0);
}
devname = "ringdev";
- if (devval > 0) {
+ if (devval > -1) {
globals.ringdev = devval;
}
+ } else if ((argv[1] && !strcasecmp(argv[0], "play")) || !strcasecmp(argv[0], "ringtest")) {
+ if (globals.audio_stream) {
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
+ goto done;
+ }
+
+ switch_file_handle_t fh = { 0 };
+ char *playfile = NULL;
+
+ if (!strcasecmp(argv[0], "ringtest")) {
+ playfile = globals.ring_file;
+ } else {
+ playfile = argv[1];
+ }
+
+ if (engage_device(globals.sample_rate, globals.codec_ms) == SWITCH_STATUS_SUCCESS) {
+ if (switch_core_file_open(&fh,
+ playfile,
+ globals.read_codec.implementation->number_of_channels,
+ globals.read_codec.implementation->actual_samples_per_second,
+ SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
+ switch_size_t olen = globals.timer.samples;
+ int16_t abuf[2048];
+
+ while (switch_core_file_read(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) {
+ WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.timer);
+ switch_core_timer_next(&globals.timer);
+ olen = globals.timer.samples;
+ }
+
+ switch_core_file_close(&fh);
+ } else {
+ stream->write_function(stream, "Cannot play requested file %s\n", argv[1]);
+ }
+ deactivate_audio_device();
+ } else {
+ stream->write_function(stream, "Failed to engage audio device\n");
+ }
+ goto done;
+ } else if (!strcasecmp(argv[0], "looptest")) {
+ if (globals.audio_stream) {
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
+ goto done;
+ }
+
+ if (engage_device(globals.sample_rate, globals.codec_ms) == SWITCH_STATUS_SUCCESS) {
+ int samples = 0;
+ int success = 0;
+ for(int i = 0; i < 400; i++) {
+ if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
+ globals.read_codec.implementation->samples_per_packet, &globals.timer))) {
+ WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &globals.timer);
+ success = 1;
+ }
+ switch_yield(10000);
+ }
+ deactivate_audio_device();
+ if (!success) {
+ stream->write_function(stream, "Failed to read any bytes from indev\n");
+ }
+ } else {
+ stream->write_function(stream, "Failed to engage audio device\n");
+ }
+ goto done;
}
if (func) {
@@ -1763,7 +1847,7 @@
}
} else {
if (devname) {
- if (devval > 0) {
+ if (devval > -1) {
stream->write_function(stream, "%s set to %d\n", devname, devval);
} else {
stream->write_function(stream, "%s not set (invalid value)\n", devname);
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c Thu Jan 15 12:39:51 2009
@@ -55,7 +55,9 @@
/******** Prototypes ****************************************************/
/************************************************************************/
-static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
+static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer,
+ unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
+static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame);
static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
@@ -67,7 +69,7 @@
/* Called from PortAudio.
* Read and write data
*/
-static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
+static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
{
PABLIO_Stream *data = (PABLIO_Stream *) userData;
@@ -80,6 +82,16 @@
PaUtil_WriteRingBuffer(&data->inFIFO, inputBuffer, numBytes);
}
}
+
+ return 0;
+}
+
+static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer,
+ unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
+{
+ PABLIO_Stream *data = (PABLIO_Stream *) userData;
+ long numBytes = data->bytesPerFrame * framesPerBuffer;
+
if (outputBuffer != NULL) {
int i;
int numRead = PaUtil_ReadRingBuffer(&data->outFIFO, outputBuffer, numBytes);
@@ -268,12 +280,15 @@
/* Open a PortAudio stream that we will use to communicate with the underlying
* audio drivers. */
- err = Pa_OpenStream(&aStream->stream, inputParameters, outputParameters, sampleRate, samples_per_packet, streamFlags, blockingIOCallback, aStream);
+ err = Pa_OpenStream(&aStream->istream, inputParameters, NULL, sampleRate, samples_per_packet, streamFlags, iblockingIOCallback, aStream);
+ err = Pa_OpenStream(&aStream->ostream, NULL, outputParameters, sampleRate, samples_per_packet, streamFlags, oblockingIOCallback, aStream);
if (err != paNoError)
goto error;
- err = Pa_StartStream(aStream->stream);
+ err = Pa_StartStream(aStream->istream);
+ err = Pa_StartStream(aStream->ostream);
+
if (err != paNoError)
goto error;
*rwblPtr = aStream;
@@ -288,7 +303,6 @@
/************************************************************/
PaError CloseAudioStream(PABLIO_Stream * aStream)
{
- PaError err;
int bytesEmpty;
int byteSize = aStream->outFIFO.bufferSize;
@@ -301,17 +315,20 @@
}
}
- err = Pa_StopStream(aStream->stream);
- if (err != paNoError)
- goto error;
- err = Pa_CloseStream(aStream->stream);
- if (err != paNoError)
- goto error;
- Pa_Terminate();
+ if (Pa_IsStreamActive(aStream->istream)) {
+ Pa_StopStream(aStream->istream);
+ Pa_CloseStream(aStream->istream);
+ }
+
+ if (Pa_IsStreamActive(aStream->ostream)) {
+ Pa_StopStream(aStream->ostream);
+ Pa_CloseStream(aStream->ostream);
+ }
- error:
PABLIO_TermFIFO(&aStream->inFIFO);
PABLIO_TermFIFO(&aStream->outFIFO);
free(aStream);
- return err;
+
+ return paNoError;
}
+
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h Thu Jan 15 12:39:51 2009
@@ -59,7 +59,8 @@
typedef struct {
PaUtilRingBuffer inFIFO;
PaUtilRingBuffer outFIFO;
- PaStream *stream;
+ PaStream *istream;
+ PaStream *ostream;
int bytesPerFrame;
} PABLIO_Stream;
1
0
Author: anthm
Date: Thu Jan 15 11:47:21 2009
New Revision: 11226
Log:
mux multi-channel audio files to mono to support playing stereo sound files
Modified:
freeswitch/trunk/src/include/switch_resample.h
freeswitch/trunk/src/switch_core_file.c
freeswitch/trunk/src/switch_resample.c
Modified: freeswitch/trunk/src/include/switch_resample.h
==============================================================================
--- freeswitch/trunk/src/include/switch_resample.h (original)
+++ freeswitch/trunk/src/include/switch_resample.h Thu Jan 15 11:47:21 2009
@@ -168,6 +168,8 @@
SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples);
+SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, uint32_t samples, uint32_t channels);
+
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
Modified: freeswitch/trunk/src/switch_core_file.c
==============================================================================
--- freeswitch/trunk/src/switch_core_file.c (original)
+++ freeswitch/trunk/src/switch_core_file.c Thu Jan 15 11:47:21 2009
@@ -120,7 +120,11 @@
if (fh->pre_buffer_datalen) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Prebuffering %d bytes\n", (int)fh->pre_buffer_datalen);
switch_buffer_create_dynamic(&fh->pre_buffer, fh->pre_buffer_datalen * fh->channels, fh->pre_buffer_datalen * fh->channels / 2, 0);
- fh->pre_buffer_data = switch_core_alloc(fh->memory_pool, fh->pre_buffer_datalen);
+ fh->pre_buffer_data = switch_core_alloc(fh->memory_pool, fh->pre_buffer_datalen * fh->channels);
+ }
+
+ if (fh->channels > 1) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File has %d channels, muxing to mono will occur.\n", fh->channels);
}
switch_set_flag(fh, SWITCH_FILE_OPEN);
@@ -164,6 +168,9 @@
if ((status = fh->file_interface->file_read(fh, fh->pre_buffer_data, &rlen)) != SWITCH_STATUS_SUCCESS || !rlen) {
switch_set_flag(fh, SWITCH_FILE_BUFFER_DONE);
} else {
+ if (fh->channels > 1) {
+ switch_mux_channels((int16_t *)fh->pre_buffer_data, rlen, fh->channels);
+ }
switch_buffer_write(fh->pre_buffer, fh->pre_buffer_data, asis ? rlen : rlen * 2);
}
}
@@ -185,6 +192,11 @@
switch_set_flag(fh, SWITCH_FILE_DONE);
goto top;
}
+
+ if (fh->channels > 1) {
+ switch_mux_channels((int16_t *)data, *len, fh->channels);
+ }
+
}
Modified: freeswitch/trunk/src/switch_resample.c
==============================================================================
--- freeswitch/trunk/src/switch_resample.c (original)
+++ freeswitch/trunk/src/switch_resample.c Thu Jan 15 11:47:21 2009
@@ -244,6 +244,27 @@
return x;
}
+SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, uint32_t samples, uint32_t channels)
+{
+ int16_t *buf;
+ switch_size_t len = samples * sizeof(int16_t);
+ uint32_t i = 0, j = 0, k = 0;
+
+ switch_zmalloc(buf, len);
+
+ for(i = 0; i < samples; i++) {
+ for (j = 0; j < channels; j++) {
+ int32_t z = buf[i] + data[k++];
+ switch_normalize_to_16bit(z);
+ buf[i] = (int16_t) z;
+ }
+ }
+
+ memcpy(data, buf, len);
+ free(buf);
+
+}
+
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
{
double newrate = 0;
1
0
Author: anthm
Date: Thu Jan 15 10:54:13 2009
New Revision: 11225
Log:
refactor
Modified:
freeswitch/trunk/src/switch_core_io.c
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Jan 15 10:54:13 2009
@@ -137,8 +137,8 @@
if (session->read_codec && !session->track_id && session->track_duration) {
if (session->read_frame_count == 0) {
switch_event_t *event;
- session->read_frame_count = (session->read_codec->implementation->actual_samples_per_second /
- session->read_codec->implementation->samples_per_packet) * session->track_duration;
+ session->read_frame_count = (session->read_impl.actual_samples_per_second /
+ session->read_impl.samples_per_packet) * session->track_duration;
switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
switch_channel_event_set_data(session->channel, event);
@@ -150,7 +150,7 @@
if (switch_channel_test_flag(session->channel, CF_HOLD)) {
- switch_yield(session->read_codec->implementation->microseconds_per_packet);
+ switch_yield(session->read_impl.microseconds_per_packet);
status = SWITCH_STATUS_BREAK;
goto even_more_done;
}
@@ -215,7 +215,7 @@
goto done;
}
- if ((*frame)->codec->implementation->actual_samples_per_second != session->read_codec->implementation->actual_samples_per_second) {
+ if ((*frame)->codec->implementation->actual_samples_per_second != session->read_impl.actual_samples_per_second) {
do_resample = 1;
}
@@ -257,7 +257,7 @@
session->read_codec,
read_frame->data,
read_frame->datalen,
- session->read_codec->implementation->actual_samples_per_second,
+ session->read_impl.actual_samples_per_second,
session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
}
@@ -272,8 +272,8 @@
status = switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->actual_samples_per_second,
read_frame->codec->implementation->decoded_bytes_per_packet,
- session->read_codec->implementation->actual_samples_per_second,
- session->read_codec->implementation->decoded_bytes_per_packet, session->pool);
+ session->read_impl.actual_samples_per_second,
+ session->read_impl.decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
@@ -285,7 +285,7 @@
case SWITCH_STATUS_SUCCESS:
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
session->raw_read_frame.rate = read_frame->rate;
- if (read_frame->codec->implementation->samples_per_packet != session->read_codec->implementation->samples_per_packet) {
+ if (read_frame->codec->implementation->samples_per_packet != session->read_impl.samples_per_packet) {
session->raw_read_frame.timestamp = 0;
} else {
session->raw_read_frame.timestamp = read_frame->timestamp;
@@ -398,11 +398,11 @@
}
- if (read_frame->datalen == session->read_codec->implementation->decoded_bytes_per_packet) {
+ if (read_frame->datalen == session->read_impl.decoded_bytes_per_packet) {
perfect = TRUE;
} else {
if (!session->raw_read_buffer) {
- switch_size_t bytes = session->read_codec->implementation->decoded_bytes_per_packet;
+ switch_size_t bytes = session->read_impl.decoded_bytes_per_packet;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes vs %u\n",
(uint32_t) bytes, (uint32_t) (*frame)->datalen);
switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0);
@@ -414,16 +414,16 @@
}
- if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_codec->implementation->decoded_bytes_per_packet) {
+ if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_impl.decoded_bytes_per_packet) {
if (perfect) {
enc_frame = read_frame;
session->raw_read_frame.rate = read_frame->rate;
} else {
session->raw_read_frame.datalen = (uint32_t) switch_buffer_read(session->raw_read_buffer,
session->raw_read_frame.data,
- session->read_codec->implementation->decoded_bytes_per_packet);
+ session->read_impl.decoded_bytes_per_packet);
- session->raw_read_frame.rate = session->read_codec->implementation->actual_samples_per_second;
+ session->raw_read_frame.rate = session->read_impl.actual_samples_per_second;
enc_frame = &session->raw_read_frame;
}
session->enc_read_frame.datalen = session->enc_read_frame.buflen;
@@ -436,16 +436,16 @@
enc_frame->codec,
enc_frame->data,
enc_frame->datalen,
- session->read_codec->implementation->actual_samples_per_second,
+ session->read_impl.actual_samples_per_second,
session->enc_read_frame.data, &session->enc_read_frame.datalen, &session->enc_read_frame.rate, &flag);
switch (status) {
case SWITCH_STATUS_RESAMPLE:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fixme 1\n");
case SWITCH_STATUS_SUCCESS:
- session->enc_read_frame.samples = session->read_codec->implementation->decoded_bytes_per_packet / sizeof(int16_t);
+ session->enc_read_frame.samples = session->read_impl.decoded_bytes_per_packet / sizeof(int16_t);
if (perfect) {
- if (enc_frame->codec->implementation->samples_per_packet != session->read_codec->implementation->samples_per_packet) {
+ if (enc_frame->codec->implementation->samples_per_packet != session->read_impl.samples_per_packet) {
session->enc_read_frame.timestamp = 0;
} else {
session->enc_read_frame.timestamp = read_frame->timestamp;
@@ -454,7 +454,7 @@
session->enc_read_frame.ssrc = read_frame->ssrc;
session->enc_read_frame.seq = read_frame->seq;
session->enc_read_frame.m = read_frame->m;
- session->enc_read_frame.payload = session->read_codec->implementation->ianacode;
+ session->enc_read_frame.payload = session->read_impl.ianacode;
}
*frame = &session->enc_read_frame;
break;
@@ -616,7 +616,7 @@
if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
- if (session->write_codec->implementation->codec_id == frame->codec->implementation->codec_id) {
+ if (session->write_impl.codec_id == frame->codec->implementation->codec_id) {
ptime_mismatch = TRUE;
if (switch_test_flag(frame->codec, SWITCH_CODEC_FLAG_PASSTHROUGH) || switch_test_flag(session->read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH)) {
status = perform_write(session, frame, flags, stream_id);
@@ -635,7 +635,7 @@
need_codec = TRUE;
}
- if (frame->codec->implementation->actual_samples_per_second != session->write_codec->implementation->actual_samples_per_second) {
+ if (frame->codec->implementation->actual_samples_per_second != session->write_impl.actual_samples_per_second) {
need_codec = TRUE;
do_resample = TRUE;
}
@@ -660,7 +660,7 @@
session->write_codec,
frame->data,
frame->datalen,
- session->write_codec->implementation->actual_samples_per_second,
+ session->write_impl.actual_samples_per_second,
session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
@@ -679,8 +679,8 @@
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->decoded_bytes_per_packet,
- session->write_codec->implementation->actual_samples_per_second,
- session->write_codec->implementation->decoded_bytes_per_packet, session->pool);
+ session->write_impl.actual_samples_per_second,
+ session->write_impl.decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
goto done;
@@ -807,33 +807,15 @@
if (session->write_codec) {
if (!ptime_mismatch &&
- write_frame->codec->implementation->decoded_bytes_per_packet == session->write_codec->implementation->decoded_bytes_per_packet) {
+ write_frame->codec->implementation->decoded_bytes_per_packet == session->write_impl.decoded_bytes_per_packet) {
perfect = TRUE;
- } else {
- if (!session->raw_write_buffer) {
- switch_size_t bytes = session->write_codec->implementation->decoded_bytes_per_packet;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "Engaging Write Buffer at %u bytes to accommodate %u->%u\n",
- (uint32_t) bytes, write_frame->datalen, session->write_codec->implementation->decoded_bytes_per_packet);
- if ((status = switch_buffer_create_dynamic(&session->raw_write_buffer,
- bytes * SWITCH_BUFFER_BLOCK_FRAMES,
- bytes * SWITCH_BUFFER_START_FRAMES, 0)) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer Failed!\n");
- goto error;
- }
- }
-
- if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
- status = SWITCH_STATUS_MEMERR; goto error;
- }
}
-
+
if (perfect) {
- if (write_frame->datalen < session->write_codec->implementation->decoded_bytes_per_packet) {
- memset(write_frame->data, 255, session->write_codec->implementation->decoded_bytes_per_packet - write_frame->datalen);
- write_frame->datalen = session->write_codec->implementation->decoded_bytes_per_packet;
+ if (write_frame->datalen < session->write_impl.decoded_bytes_per_packet) {
+ memset(write_frame->data, 255, session->write_impl.decoded_bytes_per_packet - write_frame->datalen);
+ write_frame->datalen = session->write_impl.decoded_bytes_per_packet;
}
enc_frame = write_frame;
@@ -843,7 +825,7 @@
frame->codec,
enc_frame->data,
enc_frame->datalen,
- session->write_codec->implementation->actual_samples_per_second,
+ session->write_impl.actual_samples_per_second,
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
switch (status) {
@@ -853,12 +835,12 @@
case SWITCH_STATUS_SUCCESS:
session->enc_write_frame.codec = session->write_codec;
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
- if (frame->codec->implementation->samples_per_packet != session->write_codec->implementation->samples_per_packet) {
+ if (frame->codec->implementation->samples_per_packet != session->write_impl.samples_per_packet) {
session->enc_write_frame.timestamp = 0;
} else {
session->enc_write_frame.timestamp = frame->timestamp;
}
- session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
+ session->enc_write_frame.payload = session->write_impl.ianacode;
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
session->enc_write_frame.seq = frame->seq;
@@ -891,9 +873,31 @@
status = perform_write(session, write_frame, flags, stream_id);
goto error;
} else {
- switch_size_t used = switch_buffer_inuse(session->raw_write_buffer);
- uint32_t bytes = session->write_codec->implementation->decoded_bytes_per_packet;
- switch_size_t frames = (used / bytes);
+ switch_size_t used;
+ uint32_t bytes;
+ switch_size_t frames;
+
+ if (!session->raw_write_buffer) {
+ switch_size_t bytes_per_packet = session->write_impl.decoded_bytes_per_packet;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "Engaging Write Buffer at %u bytes to accommodate %u->%u\n",
+ (uint32_t) bytes_per_packet, write_frame->datalen, session->write_impl.decoded_bytes_per_packet);
+ if ((status = switch_buffer_create_dynamic(&session->raw_write_buffer,
+ bytes_per_packet * SWITCH_BUFFER_BLOCK_FRAMES,
+ bytes_per_packet * SWITCH_BUFFER_START_FRAMES, 0)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer Failed!\n");
+ goto error;
+ }
+ }
+
+ if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
+ status = SWITCH_STATUS_MEMERR; goto error;
+ }
+
+ used = switch_buffer_inuse(session->raw_write_buffer);
+ bytes = session->write_impl.decoded_bytes_per_packet;
+ frames = (used / bytes);
status = SWITCH_STATUS_SUCCESS;
if (!frames) {
@@ -905,13 +909,13 @@
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
int rate;
enc_frame = &session->raw_write_frame;
- session->raw_write_frame.rate = session->write_codec->implementation->actual_samples_per_second;
+ session->raw_write_frame.rate = session->write_impl.actual_samples_per_second;
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
if (frame->codec && frame->codec->implementation) {
rate = frame->codec->implementation->actual_samples_per_second;
} else {
- rate = session->write_codec->implementation->actual_samples_per_second;
+ rate = session->write_impl.actual_samples_per_second;
}
status = switch_core_codec_encode(session->write_codec,
@@ -928,15 +932,15 @@
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
- session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
+ session->enc_write_frame.payload = session->write_impl.ianacode;
write_frame = &session->enc_write_frame;
if (!session->write_resampler) {
switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->decoded_bytes_per_packet,
- session->write_codec->implementation->actual_samples_per_second,
- session->write_codec->implementation->decoded_bytes_per_packet, session->pool);
+ session->write_impl.actual_samples_per_second,
+ session->write_impl.decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
@@ -949,7 +953,7 @@
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
- session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
+ session->enc_write_frame.payload = session->write_impl.ianacode;
write_frame = &session->enc_write_frame;
break;
case SWITCH_STATUS_NOOP:
1
0
[commit] r11224 - in freeswitch/trunk/src: . include mod/languages/mod_java mod/languages/mod_java/src/org/freeswitch/swig mod/languages/mod_lua mod/languages/mod_managed mod/languages/mod_managed/managed mod/languages/mod_perl mod/languages/mod_python
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: brian
Date: Thu Jan 15 09:38:32 2009
New Revision: 11224
Log:
try not to break backwards and api compatibility refer to rev 11211
Modified:
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx
freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
freeswitch/trunk/src/switch_cpp.cpp
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Thu Jan 15 09:38:32 2009
@@ -303,7 +303,7 @@
int max_digits,
int max_tries,
int timeout, char *terminators, char *audio_files, char *bad_input_audio_files,
- char *var_name, char *digits_regex);
+ char *digits_regex, const char *var_name = NULL);
/** \brief Play a file that resides on disk into the channel
*
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java Thu Jan 15 09:38:32 2009
@@ -233,8 +233,12 @@
return freeswitchJNI.CoreSession_read(swigCPtr, this, min_digits, max_digits, prompt_audio_file, timeout, valid_terminators);
}
- public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String var_name, String digits_regex) {
- return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, var_name, digits_regex);
+ public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex, String var_name) {
+ return freeswitchJNI.CoreSession_playAndGetDigits__SWIG_0(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex, var_name);
+ }
+
+ public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex) {
+ return freeswitchJNI.CoreSession_playAndGetDigits__SWIG_1(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex);
}
public int streamFile(String file, int starting_sample_count) {
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java Thu Jan 15 09:38:32 2009
@@ -133,7 +133,8 @@
public final static native int CoreSession_transfer__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native int CoreSession_transfer__SWIG_2(long jarg1, CoreSession jarg1_, String jarg2);
public final static native String CoreSession_read(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, String jarg4, int jarg5, String jarg6);
- public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10);
+ public final static native String CoreSession_playAndGetDigits__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10);
+ public final static native String CoreSession_playAndGetDigits__SWIG_1(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
public final static native int CoreSession_sleep__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, int jarg3);
Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -2577,7 +2577,7 @@
}
-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10) {
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10) {
jstring jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -2624,7 +2624,7 @@
arg10 = (char *)jenv->GetStringUTFChars(jarg10, 0);
if (!arg10) return 0;
}
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
if(result) jresult = jenv->NewStringUTF((const char *)result);
if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6);
if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7);
@@ -2635,6 +2635,57 @@
}
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9) {
+ jstring jresult = 0 ;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ (void)jarg1_;
+ arg1 = *(CoreSession **)&jarg1;
+ arg2 = (int)jarg2;
+ arg3 = (int)jarg3;
+ arg4 = (int)jarg4;
+ arg5 = (int)jarg5;
+ arg6 = 0;
+ if (jarg6) {
+ arg6 = (char *)jenv->GetStringUTFChars(jarg6, 0);
+ if (!arg6) return 0;
+ }
+ arg7 = 0;
+ if (jarg7) {
+ arg7 = (char *)jenv->GetStringUTFChars(jarg7, 0);
+ if (!arg7) return 0;
+ }
+ arg8 = 0;
+ if (jarg8) {
+ arg8 = (char *)jenv->GetStringUTFChars(jarg8, 0);
+ if (!arg8) return 0;
+ }
+ arg9 = 0;
+ if (jarg9) {
+ arg9 = (char *)jenv->GetStringUTFChars(jarg9, 0);
+ if (!arg9) return 0;
+ }
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ if(result) jresult = jenv->NewStringUTF((const char *)result);
+ if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6);
+ if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7);
+ if (arg8) jenv->ReleaseStringUTFChars(jarg8, (const char *)arg8);
+ if (arg9) jenv->ReleaseStringUTFChars(jarg9, (const char *)arg9);
+ return jresult;
+}
+
+
SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1streamFile_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
jint jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -5913,7 +5913,7 @@
}
-static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
+static int _wrap_CoreSession_playAndGetDigits__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -5937,7 +5937,7 @@
if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *");
if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *");
if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *");
- if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char *");
+ if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession);
@@ -5952,7 +5952,7 @@
arg8 = (char *)lua_tostring(L, 8);
arg9 = (char *)lua_tostring(L, 9);
arg10 = (char *)lua_tostring(L, 10);
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
SWIG_arg=0;
lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
@@ -5965,6 +5965,181 @@
}
+static int _wrap_CoreSession_playAndGetDigits__SWIG_1(lua_State* L) {
+ int SWIG_arg = -1;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("playAndGetDigits",9,9)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("playAndGetDigits",1,"CoreSession *");
+ if(!lua_isnumber(L,2)) SWIG_fail_arg("playAndGetDigits",2,"int");
+ if(!lua_isnumber(L,3)) SWIG_fail_arg("playAndGetDigits",3,"int");
+ if(!lua_isnumber(L,4)) SWIG_fail_arg("playAndGetDigits",4,"int");
+ if(!lua_isnumber(L,5)) SWIG_fail_arg("playAndGetDigits",5,"int");
+ if(!lua_isstring(L,6)) SWIG_fail_arg("playAndGetDigits",6,"char *");
+ if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *");
+ if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *");
+ if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+ SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession);
+ }
+
+ arg2 = (int)lua_tonumber(L, 2);
+ arg3 = (int)lua_tonumber(L, 3);
+ arg4 = (int)lua_tonumber(L, 4);
+ arg5 = (int)lua_tonumber(L, 5);
+ arg6 = (char *)lua_tostring(L, 6);
+ arg7 = (char *)lua_tostring(L, 7);
+ arg8 = (char *)lua_tostring(L, 8);
+ arg9 = (char *)lua_tostring(L, 9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ SWIG_arg=0;
+ lua_pushstring(L,(const char*)result); SWIG_arg++;
+ return SWIG_arg;
+
+ if(0) SWIG_fail;
+
+fail:
+ lua_error(L);
+ return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
+ int argc;
+ int argv[11]={
+ 1,2,3,4,5,6,7,8,9,10,11
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 9) {
+ int _v;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[4]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[5]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[6]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[7]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[8]);
+ }
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 10) {
+ int _v;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[4]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[5]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[6]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[7]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[8]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[9]);
+ }
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_0(L);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ lua_pushstring(L,"No matching function for overloaded 'CoreSession_playAndGetDigits'");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_CoreSession_streamFile__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx Thu Jan 15 09:38:32 2009
@@ -27368,7 +27368,7 @@
char *arg7 = (char *) 0 ;
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
- char *arg10 = (char *) 0 ;
+ char *arg10 = (char *) NULL ;
char *result = 0 ;
arg1 = (CoreSession *)jarg1;
@@ -27381,7 +27381,7 @@
arg8 = (char *)jarg8;
arg9 = (char *)jarg9;
arg10 = (char *)jarg10;
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs Thu Jan 15 09:38:32 2009
@@ -282,8 +282,8 @@
return ret;
}
- public string PlayAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, string terminators, string audio_files, string bad_input_audio_files, string var_name, string digits_regex) {
- string ret = freeswitchPINVOKE.CoreSession_PlayAndGetDigits(swigCPtr, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, var_name, digits_regex);
+ public string PlayAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, string terminators, string audio_files, string bad_input_audio_files, string digits_regex, string var_name) {
+ string ret = freeswitchPINVOKE.CoreSession_PlayAndGetDigits(swigCPtr, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex, var_name);
return ret;
}
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -7858,7 +7858,7 @@
}
-XS(_wrap_CoreSession_playAndGetDigits) {
+XS(_wrap_CoreSession_playAndGetDigits__SWIG_0) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -7900,7 +7900,7 @@
dXSARGS;
if ((items < 10) || (items > 10)) {
- SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,var_name,digits_regex);");
+ SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex,var_name);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
@@ -7949,10 +7949,10 @@
arg9 = reinterpret_cast< char * >(buf9);
res10 = SWIG_AsCharPtrAndSize(ST(9), &buf10, NULL, &alloc10);
if (!SWIG_IsOK(res10)) {
- SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
+ SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char const *""'");
}
arg10 = reinterpret_cast< char * >(buf10);
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
@@ -7981,6 +7981,332 @@
}
+XS(_wrap_CoreSession_playAndGetDigits__SWIG_1) {
+ {
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ int res6 ;
+ char *buf6 = 0 ;
+ int alloc6 = 0 ;
+ int res7 ;
+ char *buf7 = 0 ;
+ int alloc7 = 0 ;
+ int res8 ;
+ char *buf8 = 0 ;
+ int alloc8 = 0 ;
+ int res9 ;
+ char *buf9 = 0 ;
+ int alloc9 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 9) || (items > 9)) {
+ SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playAndGetDigits" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_playAndGetDigits" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_playAndGetDigits" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_playAndGetDigits" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_playAndGetDigits" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = static_cast< int >(val5);
+ res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6);
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_playAndGetDigits" "', argument " "6"" of type '" "char *""'");
+ }
+ arg6 = reinterpret_cast< char * >(buf6);
+ res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7);
+ if (!SWIG_IsOK(res7)) {
+ SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "CoreSession_playAndGetDigits" "', argument " "7"" of type '" "char *""'");
+ }
+ arg7 = reinterpret_cast< char * >(buf7);
+ res8 = SWIG_AsCharPtrAndSize(ST(7), &buf8, NULL, &alloc8);
+ if (!SWIG_IsOK(res8)) {
+ SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
+ }
+ arg8 = reinterpret_cast< char * >(buf8);
+ res9 = SWIG_AsCharPtrAndSize(ST(8), &buf9, NULL, &alloc9);
+ if (!SWIG_IsOK(res9)) {
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
+ }
+ arg9 = reinterpret_cast< char * >(buf9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+
+
+
+
+
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ XSRETURN(argvi);
+ fail:
+
+
+
+
+
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_CoreSession_playAndGetDigits) {
+ dXSARGS;
+
+ {
+ unsigned long _index = 0;
+ SWIG_TypeRank _rank = 0;
+ if (items == 9) {
+ SWIG_TypeRank _ranki = 0;
+ SWIG_TypeRank _rankm = 0;
+ SWIG_TypeRank _pi = 1;
+ int _v = 0;
+ {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(6), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(7), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(8), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ if (!_index || (_ranki < _rank)) {
+ _rank = _ranki; _index = 1;
+ if (_rank == _rankm) goto dispatch;
+ }
+ }
+ check_1:
+
+ if (items == 10) {
+ SWIG_TypeRank _ranki = 0;
+ SWIG_TypeRank _rankm = 0;
+ SWIG_TypeRank _pi = 1;
+ int _v = 0;
+ {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(6), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(7), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(8), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(9), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ if (!_index || (_ranki < _rank)) {
+ _rank = _ranki; _index = 2;
+ if (_rank == _rankm) goto dispatch;
+ }
+ }
+ check_2:
+
+ dispatch:
+ switch(_index) {
+ case 1:
+ ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_playAndGetDigits__SWIG_1); return;
+ case 2:
+ ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_playAndGetDigits__SWIG_0); return;
+ }
+ }
+
+ croak("No matching function for overloaded 'CoreSession_playAndGetDigits'");
+ XSRETURN(0);
+}
+
+
XS(_wrap_CoreSession_streamFile__SWIG_0) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -7783,7 +7783,7 @@
}
-SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -7880,10 +7880,10 @@
arg9 = reinterpret_cast< char * >(buf9);
res10 = SWIG_AsCharPtrAndSize(obj9, &buf10, NULL, &alloc10);
if (!SWIG_IsOK(res10)) {
- SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
+ SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char const *""'");
}
arg10 = reinterpret_cast< char * >(buf10);
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
resultobj = SWIG_FromCharPtr((const char *)result);
if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
@@ -7901,6 +7901,234 @@
}
+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ int res6 ;
+ char *buf6 = 0 ;
+ int alloc6 = 0 ;
+ int res7 ;
+ char *buf7 = 0 ;
+ int alloc7 = 0 ;
+ int res8 ;
+ char *buf8 = 0 ;
+ int alloc8 = 0 ;
+ int res9 ;
+ char *buf9 = 0 ;
+ int alloc9 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+ PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
+ PyObject * obj7 = 0 ;
+ PyObject * obj8 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:CoreSession_playAndGetDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playAndGetDigits" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_playAndGetDigits" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_playAndGetDigits" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_playAndGetDigits" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ ecode5 = SWIG_AsVal_int(obj4, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_playAndGetDigits" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = static_cast< int >(val5);
+ res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6);
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_playAndGetDigits" "', argument " "6"" of type '" "char *""'");
+ }
+ arg6 = reinterpret_cast< char * >(buf6);
+ res7 = SWIG_AsCharPtrAndSize(obj6, &buf7, NULL, &alloc7);
+ if (!SWIG_IsOK(res7)) {
+ SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "CoreSession_playAndGetDigits" "', argument " "7"" of type '" "char *""'");
+ }
+ arg7 = reinterpret_cast< char * >(buf7);
+ res8 = SWIG_AsCharPtrAndSize(obj7, &buf8, NULL, &alloc8);
+ if (!SWIG_IsOK(res8)) {
+ SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
+ }
+ arg8 = reinterpret_cast< char * >(buf8);
+ res9 = SWIG_AsCharPtrAndSize(obj8, &buf9, NULL, &alloc9);
+ if (!SWIG_IsOK(res9)) {
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
+ }
+ arg9 = reinterpret_cast< char * >(buf9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ return resultobj;
+fail:
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *self, PyObject *args) {
+ int argc;
+ PyObject *argv[11];
+ int ii;
+
+ if (!PyTuple_Check(args)) SWIG_fail;
+ argc = (int)PyObject_Length(args);
+ for (ii = 0; (ii < argc) && (ii < 10); ii++) {
+ argv[ii] = PyTuple_GET_ITEM(args,ii);
+ }
+ if (argc == 9) {
+ int _v;
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[2], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[3], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[4], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[6], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[7], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[8], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_1(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 10) {
+ int _v;
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[2], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[3], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[4], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[6], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[7], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[8], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[9], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_0(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+fail:
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_playAndGetDigits'.\n"
+ " Possible C/C++ prototypes are:\n"
+ " playAndGetDigits(CoreSession *,int,int,int,int,char *,char *,char *,char *,char const *)\n"
+ " playAndGetDigits(CoreSession *,int,int,int,int,char *,char *,char *,char *)\n");
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_CoreSession_streamFile__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Thu Jan 15 09:38:32 2009
@@ -749,8 +749,8 @@
char *terminators,
char *audio_files,
char *bad_input_audio_files,
- char *var_name,
- char *digits_regex)
+ char *digits_regex,
+ const char *var_name)
{
switch_status_t status;
sanity_check((char *)"");
1
0
[commit] r11223 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Thu Jan 15 06:54:15 2009
New Revision: 11223
Log:
Fixed a bunch of seg-faults, finished implementing all commands from CLI, API and dialplan.
Still needs some cleanup and consolidation, but functions and seems stable. Tested everything I could :-)
Modified:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
Modified: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
==============================================================================
--- freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c (original)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c Thu Jan 15 06:54:15 2009
@@ -40,14 +40,11 @@
* Thanks go to bandwidth.com for funding this work.
*
*
- * TODO: Create an override flag so you can force a start-time for when billing should count *from*
* TODO: Fix what happens when the DB is not available
* TODO: Fix what happens when the DB queries fail (right now, all are acting like success)
* TODO: Make the actions function for when funds are depleted
- * TODO: Add app and CLI commands (pause, resume, reset, flush, deduct_funds, add_funds)
* TODO: Add buffering abilities
* TODO: Make error handling for database, such that when the database is down (or not installed) we just log to a text file
- * TODO: Make a sample .XML config file!
* FUTURE: Possibly make the hooks not tied per-channel, and instead just do this as a supervision style application with one thread that watches all calls
*/
@@ -274,19 +271,6 @@
}
-static switch_status_t sched_billing(switch_core_session_t *session)
-{
-
- if (globals.global_heartbeat > 0) {
- switch_core_session_enable_heartbeat(session, globals.global_heartbeat);
- }
-
- // Check account balance here
-
- return SWITCH_STATUS_SUCCESS;
-
-}
-
/* At this time, billing never succeeds if you don't have a database. */
static switch_status_t bill_event(float billamount, const char *billaccount)
{
@@ -397,7 +381,6 @@
/* Setup new billing data (based on call answer time, in case this module started late with active calls) */
nibble_data->lastts = profile->times->answered; /* Set the initial answer time to match when the call was really answered */
- nibble_data->pausets = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Beginning new billing on %s\n", uuid);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Last successful billing time was %s\n", date);
@@ -411,7 +394,7 @@
if ((ts - nibble_data->lastts) > 0) {
/* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
- billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts));
+ billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts)) - nibble_data->bill_adjustments;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount, uuid, nibble_data->total);
@@ -420,6 +403,9 @@
/* Increment total cost */
nibble_data->total += billamount;
+ /* Reset manual billing adjustments from pausing */
+ nibble_data->bill_adjustments = 0;
+
/* Update channel variable with current billing */
tmp = switch_mprintf("%f", nibble_data->total);
switch_channel_set_variable(channel, "nibble_total_billed", tmp);
@@ -487,15 +473,14 @@
switch_core_session_rwunlock(session);
}
-
-static float nibblebill_check(switch_core_session_t *session)
+static void nibblebill_pause(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_time_t ts = switch_timestamp_now();
nibble_data_t *nibble_data;
- float amount = 0;
if (!channel) {
- return -99999;
+ return;
}
/* Lock this session's data for this module while we tinker with it */
@@ -506,30 +491,140 @@
/* Get our nibble data var. This will be NULL if it's our first call here for this session */
nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
- amount = nibble_data->total;
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Can't pause - channel is not initialized for billing!\n");
+ return;
+ }
+
+ /* Set pause counter if not already set */
+ if (nibble_data->pausets == 0)
+ nibble_data->pausets = ts;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Paused billing timestamp!\n");
/* Done checking - release lock */
if (globals.mutex) {
switch_mutex_unlock(globals.mutex);
}
- return amount;
}
-static void nibblebill_adjust(switch_core_session_t *session, float amount)
+static void nibblebill_resume(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- char *uuid;
+ switch_time_t ts = switch_timestamp_now();
+ nibble_data_t *nibble_data;
if (!channel) {
return;
}
- uuid = switch_core_session_get_uuid(session);
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
- /* Get channel var */
- if (!uuid || !channel) {
- switch_core_session_rwunlock(session);
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't resume - channel is not initialized for billing (This is expected at hangup time)!\n");
+ return;
+ }
+
+ if (nibble_data->pausets == 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't resume - channel is not paused! (This is expected at hangup time)\n");
+ return;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ const char *billrate = switch_channel_get_variable(channel, "nibble_rate");
+
+ /* Calculate how much was "lost" to billings during pause - we do this here because you never know when the billrate may change during a call */
+ nibble_data->bill_adjustments += (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Resumed billing! Subtracted %f from this billing cycle.\n", (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets)));
+
+ nibble_data->pausets = 0;
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+}
+
+static void nibblebill_reset(switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_time_t ts = switch_timestamp_now();
+ nibble_data_t *nibble_data;
+
+ if (!channel) {
+ return;
+ }
+
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Can't reset - channel is not initialized for billing!\n");
+ return;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ /* Update the last time we billed */
+ nibble_data->lastts = ts;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Reset last billing timestamp marker to right now!\n");
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+}
+
+static float nibblebill_check(switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ nibble_data_t *nibble_data;
+ float amount = 0;
+
+ if (!channel) {
+ return -99999;
+ }
+
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Can't check - channel is not initialized for billing!\n");
+ return -99999;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ amount = nibble_data->total;
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+ return amount;
+}
+
+static void nibblebill_adjust(switch_core_session_t *session, float amount)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
+ if (!channel) {
return;
}
@@ -538,12 +633,11 @@
/* Return if there's no billing information on this session */
if (!billaccount) {
- switch_core_session_rwunlock(session);
return;
}
/* Add or remove amount from adjusted billing here. Note, we bill the OPPOSITE */
- if (bill_event(-amount, billaccount)) {
+ if (bill_event(-amount, billaccount) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recorded adjustment to %s for $%f\n", billaccount, amount);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to record adjustment to %s for $%f\n", billaccount, amount);
@@ -562,14 +656,16 @@
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (!strcasecmp(argv[0], "adjust") && argc == 2) {
nibblebill_adjust(session, atof(argv[1]));
-/* } else if (!strcasecmp(argv[0], "pause")) {
+ } else if (!strcasecmp(argv[0], "flush")) {
+ do_billing(session);
+ } else if (!strcasecmp(argv[0], "pause")) {
nibblebill_pause(session);
} else if (!strcasecmp(argv[0], "resume")) {
- nibblebill_resume(session);*/
+ nibblebill_resume(session);
} else if (!strcasecmp(argv[0], "check")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", nibblebill_check(session));
-/* } else if (!strcasecmp(argv[0], "reset")) {
- nibblebill_reset(session);*/
+ } else if (!strcasecmp(argv[0], "reset")) {
+ nibblebill_reset(session);
} else if (!strcasecmp(argv[0], "heartbeat") && argc == 2) {
switch_core_session_enable_heartbeat(session, atoi(argv[1]));
}
@@ -578,15 +674,74 @@
}
/* We get here from the API only (theoretically) */
-#define CHECK_API_SYNTAX "<uuid>"
-SWITCH_STANDARD_API(nibblebill_check_api_function)
+#define API_SYNTAX "<uuid> [pause | resume | reset | adjust <amount> | heartbeat <seconds> | check]"
+SWITCH_STANDARD_API(nibblebill_api_function)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "We made it!\n");
-
+ switch_core_session_t *psession = NULL;
+ char *mycmd = NULL, *argv[3] = { 0 };
+ int argc = 0;
+
+ if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
+ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+ if ((argc == 2 || argc == 3) && !switch_strlen_zero(argv[0])) {
+ char *uuid = argv[0];
+ if ((psession = switch_core_session_locate(uuid))) {
+ switch_channel_t *channel;
+ channel = switch_core_session_get_channel(psession);
+
+ if (!strcasecmp(argv[1], "adjust") && argc == 3) {
+ nibblebill_adjust(psession, atof(argv[2]));
+ } else if (!strcasecmp(argv[1], "flush")) {
+ do_billing(psession);
+ } else if (!strcasecmp(argv[1], "pause")) {
+ nibblebill_pause(psession);
+ } else if (!strcasecmp(argv[1], "resume")) {
+ nibblebill_resume(psession);
+ } else if (!strcasecmp(argv[1], "check")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", nibblebill_check(psession));
+ } else if (!strcasecmp(argv[1], "reset")) {
+ nibblebill_reset(psession);
+ } else if (!strcasecmp(argv[1], "heartbeat") && argc == 3) {
+ switch_core_session_enable_heartbeat(psession, atoi(argv[2]));
+ }
+
+ switch_core_session_rwunlock(psession);
+ } else {
+ stream->write_function(stream, "-ERR No Such Channel!\n");
+ }
+ } else {
+ stream->write_function(stream, "-USAGE: %s\n", API_SYNTAX);
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
/* Check if session has variable "billrate" set. If it does, activate the heartbeat variable
switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds)
switch_core_session_sched_heartbeat(switch_core_session_t *session, uint32_t seconds)*/
+static switch_status_t sched_billing(switch_core_session_t *session)
+{
+
+ if (globals.global_heartbeat > 0) {
+ switch_core_session_enable_heartbeat(session, globals.global_heartbeat);
+ }
+
+ /* TODO: Check account balance here */
+
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
+static switch_status_t process_hangup(switch_core_session_t *session)
+{
+
+ /* Resume any paused billings, just in case */
+// nibblebill_resume(session);
+
+ /* Now go handle like normal billing */
+ do_billing(session);
return SWITCH_STATUS_SUCCESS;
@@ -597,7 +752,7 @@
/* on_init */ NULL,
/* on_routing */ NULL, /* Need to add a check here for anything in their account before routing */
/* on_execute */ sched_billing, /* Turn on heartbeat for this session and do an initial account check */
- /* on_hangup */ do_billing, /* On hangup - most important place to go bill */
+ /* on_hangup */ process_hangup, /* On hangup - most important place to go bill */
/* on_exch_media */ NULL,
/* on_soft_exec */ NULL,
/* on_consume_med */ NULL,
@@ -621,18 +776,9 @@
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
/* Add API and CLI commands */
-/* SWITCH_ADD_API(api_interface, "pause", "Pause billing on a session", nibblebill_pause_api_function, PAUSE_API_SYNTAX);
- SWITCH_ADD_API(api_interface, "resume", "Resume billing on a session", nibblebill_resume_api_function, RESUME_API_SYNTAX);
- SWITCH_ADD_API(api_interface, "reset", "Reset billing start time to right now - disregard any unbilled time thus far", nibblebill_reset_api_function, RESET_API_SYNTAX);
- SWITCH_ADD_API(api_interface, "adjust", "Add or deduct a dollar amount from a caller's account", nibblebill_adjust_api_function, ADJUST_API_SYNTAX);*/
- SWITCH_ADD_API(api_interface, "check", "Check the balance of a session", nibblebill_check_api_function, CHECK_API_SYNTAX);
+ SWITCH_ADD_API(api_interface, "nibblebill", "Manage billing parameters for a channel/call", nibblebill_api_function, API_SYNTAX);
/* Add dialplan applications */
-/* SWITCH_ADD_APP(app_interface, "nibble_pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);*/
SWITCH_ADD_APP(app_interface, "nibblebill", "Handle billing for the current channel/call", "Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.", nibblebill_app_function, APP_SYNTAX, SAF_NONE);
/* register state handlers for billing */
1
0
[commit] r11222 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Thu Jan 15 05:31:57 2009
New Revision: 11222
Log:
Fixing a nasty bug that was resulting in channels not being released on hangup if no billing cycles had taken place.
Modified:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
Modified: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
==============================================================================
--- freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c (original)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c Thu Jan 15 05:31:57 2009
@@ -71,7 +71,6 @@
switch_time_t pausets; /* Timestamp of when a pause action started. 0 if not paused */
float bill_adjustments; /* Adjustments to make to the next billing, based on pause/resume events */
- float manual_adjustments; /* Manually added/deducted amounts from this account, to be committed at next database query */
} nibble_data_t;
@@ -87,6 +86,9 @@
/* Keep track of our config, event hooks and database connection variables, for this module only */
static struct
{
+ /* Memory */
+ switch_memory_pool_t *pool;
+
/* Event hooks */
switch_event_node_t *node;
@@ -285,6 +287,32 @@
}
+/* At this time, billing never succeeds if you don't have a database. */
+static switch_status_t bill_event(float billamount, const char *billaccount)
+{
+#ifdef SWITCH_HAVE_ODBC
+ char sql[1024] = "";
+ nibblebill_results_t pdata;
+
+ memset(&pdata, 0, sizeof(pdata));
+ snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, billamount, globals.db_column_account, billaccount);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
+
+ if (!(switch_odbc_handle_callback_exec(globals.master_odbc, sql, nibblebill_callback, &pdata) == SWITCH_ODBC_SUCCESS)){
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DB Error while updating cash!\n");
+
+ } else {
+#endif
+ /* TODO: Failover to a flat/text file if DB is unavailable */
+
+ return SWITCH_STATUS_SUCCESS;
+#ifdef SWITCH_HAVE_ODBC
+ }
+#endif
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
/* This is where we actually charge the guy
This can be called anytime a call is in progress or at the end of a call before the session is destroyed */
static switch_status_t do_billing(switch_core_session_t *session)
@@ -297,16 +325,16 @@
nibble_data_t *nibble_data;
switch_time_t ts = switch_timestamp_now();
float billamount;
- float adjustments = 0;
char date[80] = "";
char *tmp;
char *uuid;
switch_size_t retsize;
switch_time_exp_t tm;
+
if (!session) {
/* wtf? Why are we here? */
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
uuid = switch_core_session_get_uuid(session);
@@ -314,16 +342,17 @@
/* Get channel var */
channel = switch_core_session_get_channel(session);
if (!channel) {
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
/* Variables kept in FS but relevant only to this module */
const char *billrate = switch_channel_get_variable(channel, "nibble_rate");
const char *billaccount = switch_channel_get_variable(channel, "nibble_account");
+
/* Return if there's no billing information on this session */
if (!billrate || !billaccount) {
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attempting to bill at $%s per minute to account %s\n", billrate, billaccount);
@@ -333,7 +362,7 @@
if (!profile) {
/* No caller profile (why would this happen?) */
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
if (profile->times->answered < 1) {
@@ -350,7 +379,7 @@
nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
/* Are we in paused mode? If so, we don't do anything here - go back! */
- if (nibble_data->pausets > 0) {
+ if (nibble_data && (nibble_data->pausets > 0)) {
if (globals.mutex) {
switch_mutex_unlock(globals.mutex);
}
@@ -368,6 +397,7 @@
/* Setup new billing data (based on call answer time, in case this module started late with active calls) */
nibble_data->lastts = profile->times->answered; /* Set the initial answer time to match when the call was really answered */
+ nibble_data->pausets = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Beginning new billing on %s\n", uuid);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Last successful billing time was %s\n", date);
@@ -380,46 +410,23 @@
if ((ts - nibble_data->lastts) > 0) {
- /* Convert billrate into microseconds and multiply by # of microseconds that have passed */
+ /* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts));
- adjustments = nibble_data->manual_adjustments + nibble_data->bill_adjustments;
- /* if ODBC call fails, we should return BEFORE updating the timestamp of last success! */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount, uuid, nibble_data->total);
- if (adjustments > 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(Also adjusting the account by $%f)\n", adjustments);
- }
-
- /* DO ODBC BILLING HERE! */
-#ifdef SWITCH_HAVE_ODBC
- char sql[1024] = "";
- nibblebill_results_t pdata;
-
- memset(&pdata, 0, sizeof(pdata));
- snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, (billamount - adjustments), globals.db_column_account, billaccount);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
-
- if (!(switch_odbc_handle_callback_exec(globals.master_odbc, sql, nibblebill_callback, &pdata) == SWITCH_ODBC_SUCCESS)){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DB Error while updating cash!\n");
-
- /* TODO: If this is a hangup event, we should store this billing in a text file while the DB is unavailable */
- } else {
-#endif
+ /* DO ODBC BILLING HERE and reset counters if it's successful! */
+ if (bill_event(billamount, billaccount) == SWITCH_STATUS_SUCCESS) {
/* Increment total cost */
nibble_data->total += billamount;
- /* Get rid of any manual adjustments that were just committed */
- nibble_data->manual_adjustments = 0;
- nibble_data->bill_adjustments = 0;
-
/* Update channel variable with current billing */
tmp = switch_mprintf("%f", nibble_data->total);
switch_channel_set_variable(channel, "nibble_total_billed", tmp);
switch_safe_free(tmp);
-#ifdef SWITCH_HAVE_ODBC
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to log to database!\n");
}
-#endif
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Just tried to bill %s negative minutes! wtf? That should be impossible.\n", uuid);
}
@@ -427,8 +434,10 @@
/* Update the last time we billed */
nibble_data->lastts = ts;
- /* Save everything back */
- switch_channel_set_private(channel, "_nibble_data_", nibble_data);
+ /* Save this location, but only if the channel/session are not hungup (otherwise, we're done) */
+ if (channel && switch_channel_get_state(channel) != CS_HANGUP) {
+ switch_channel_set_private(channel, "_nibble_data_", nibble_data);
+ }
/* Done changing - release lock */
if (globals.mutex) {
@@ -437,9 +446,6 @@
/* Go check if this call is allowed to continue */
- /* Release the session lock */
- switch_core_session_rwunlock(session);
-
return SWITCH_STATUS_SUCCESS;
}
@@ -477,6 +483,7 @@
/* Go bill */
do_billing(session);
+
switch_core_session_rwunlock(session);
}
@@ -512,7 +519,6 @@
static void nibblebill_adjust(switch_core_session_t *session, float amount)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- nibble_data_t *nibble_data;
char *uuid;
if (!channel) {
@@ -521,53 +527,54 @@
uuid = switch_core_session_get_uuid(session);
- /* Lock this session's data for this module while we tinker with it */
- if (globals.mutex) {
- switch_mutex_lock(globals.mutex);
+ /* Get channel var */
+ if (!uuid || !channel) {
+ switch_core_session_rwunlock(session);
+ return;
}
- /* Get our nibble data var. This will be NULL if it's our first call here for this session */
- nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
-
- /*Add or remove amount from adjusted billing here */
- nibble_data->manual_adjustments += amount;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current adjustment for %s is $%f\n", uuid, amount);
+ /* Variables kept in FS but relevant only to this module */
+ const char *billaccount = switch_channel_get_variable(channel, "nibble_account");
- /* Done changing - release lock */
- if (globals.mutex) {
- switch_mutex_unlock(globals.mutex);
+ /* Return if there's no billing information on this session */
+ if (!billaccount) {
+ switch_core_session_rwunlock(session);
+ return;
}
- /* Release the session lock */
- switch_core_session_rwunlock(session);
-}
-
-#define CHECK_APP_SYNTAX ""
-SWITCH_STANDARD_APP(nibblebill_check_app_function)
-{
- float amount;
-
- amount = nibblebill_check(session);
+ /* Add or remove amount from adjusted billing here. Note, we bill the OPPOSITE */
+ if (bill_event(-amount, billaccount)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recorded adjustment to %s for $%f\n", billaccount, amount);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to record adjustment to %s for $%f\n", billaccount, amount);
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", amount);
}
-#define ADJUST_APP_SYNTAX "<amount>"
-SWITCH_STANDARD_APP(nibblebill_adjust_app_function)
+#define APP_SYNTAX "pause | resume | reset | adjust <amount> | heartbeat <seconds> | check"
+SWITCH_STANDARD_APP(nibblebill_app_function)
{
- char *mydata = NULL;
int argc = 0;
- char *argv[4] = { 0 };
- float amount;
-
- if (!(mydata = switch_core_session_strdup(session, data))) {
- return;
- }
-
- if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
- amount = atof(argv[0]);
- nibblebill_adjust(session, amount);
+ char *lbuf = NULL;
+ char *argv[3] = { 0 };
+
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
+ && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+ if (!strcasecmp(argv[0], "adjust") && argc == 2) {
+ nibblebill_adjust(session, atof(argv[1]));
+/* } else if (!strcasecmp(argv[0], "pause")) {
+ nibblebill_pause(session);
+ } else if (!strcasecmp(argv[0], "resume")) {
+ nibblebill_resume(session);*/
+ } else if (!strcasecmp(argv[0], "check")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", nibblebill_check(session));
+/* } else if (!strcasecmp(argv[0], "reset")) {
+ nibblebill_reset(session);*/
+ } else if (!strcasecmp(argv[0], "heartbeat") && argc == 2) {
+ switch_core_session_enable_heartbeat(session, atoi(argv[1]));
+ }
}
+
}
/* We get here from the API only (theoretically) */
@@ -605,6 +612,9 @@
/* Set every byte in this structure to 0 */
memset(&globals, 0, sizeof(globals));
+ globals.pool = pool;
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
+
load_config();
/* connect my internal structure to the blank pointer passed to me */
@@ -618,11 +628,12 @@
SWITCH_ADD_API(api_interface, "check", "Check the balance of a session", nibblebill_check_api_function, CHECK_API_SYNTAX);
/* Add dialplan applications */
-/* SWITCH_ADD_APP(app_interface, "pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);*/
- SWITCH_ADD_APP(app_interface, "adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);
+/* SWITCH_ADD_APP(app_interface, "nibble_pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);*/
+ SWITCH_ADD_APP(app_interface, "nibblebill", "Handle billing for the current channel/call", "Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.", nibblebill_app_function, APP_SYNTAX, SAF_NONE);
/* register state handlers for billing */
switch_core_add_state_handler(&nibble_state_handler);
1
0