Freeswitch-svn
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
June 2007
- 10 participants
- 249 discussions
20 Jun '07
Author: mikej
Date: Tue Jun 19 22:19:29 2007
New Revision: 5396
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
Log:
add system app: MODAPP-14
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Jun 19 22:19:29 2007
@@ -667,6 +667,12 @@
switch_ivr_tone_detect_session(session, "fax", "1100.0", "r", 0, NULL, NULL);
}
+static void system_session_function(switch_core_session_t *session, char *data)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n",data);
+ system(data);
+}
+
static void tone_detect_session_function(switch_core_session_t *session, char *data)
{
char *argv[6] = { 0 };
@@ -1072,6 +1078,15 @@
/*.next */ &dptools_api_interface
};
+static switch_application_interface_t system_application_interface = {
+ /*.interface_name */ "system",
+ /*.application_function */ system_session_function,
+ /* long_desc */ "Execute a system command",
+ /* short_desc */ "Execute a system command",
+ /* syntax */ "<command>",
+ /* flags */ SAF_NONE,
+ /*.next */ NULL
+};
static switch_application_interface_t bridge_application_interface = {
/*.interface_name */ "bridge",
@@ -1079,7 +1094,8 @@
/* long_desc */ "Bridge the audio between two sessions",
/* short_desc */ "Bridge Audio",
/* syntax */ "<channel_url>",
- /* flags */ SAF_SUPPORT_NOMEDIA
+ /* flags */ SAF_SUPPORT_NOMEDIA,
+ /* next */ &system_application_interface
};
static switch_application_interface_t speak_application_interface = {
1
0
[commit] r5395 - in freeswitch/branches/greenlizard: . build src src/include src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/endpoints/mod_sofia src/mod/event_handlers/mod_radius_cdr src/mod/languages/mod_spidermonkey
by Freeswitch SVN 19 Jun '07
by Freeswitch SVN 19 Jun '07
19 Jun '07
Author: greenlizard
Date: Tue Jun 19 19:32:04 2007
New Revision: 5395
Modified:
freeswitch/branches/greenlizard/build/modules.conf.in
freeswitch/branches/greenlizard/configure.in
freeswitch/branches/greenlizard/src/include/switch_ivr.h
freeswitch/branches/greenlizard/src/include/switch_stun.h
freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/README
freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
freeswitch/branches/greenlizard/src/switch_core_media_bug.c
freeswitch/branches/greenlizard/src/switch_ivr_async.c
freeswitch/branches/greenlizard/src/switch_ivr_originate.c
freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
Log:
merge trunk version 5382 to 5394
Modified: freeswitch/branches/greenlizard/build/modules.conf.in
==============================================================================
--- freeswitch/branches/greenlizard/build/modules.conf.in (original)
+++ freeswitch/branches/greenlizard/build/modules.conf.in Tue Jun 19 19:32:04 2007
@@ -31,6 +31,7 @@
#event_handlers/mod_cdr
#event_handlers/mod_event_multicast
event_handlers/mod_event_socket
+#event_handlers/mod_radius_cdr
#event_handlers/mod_event_test
#event_handlers/mod_xmpp_event
#event_handlers/mod_zeroconf
Modified: freeswitch/branches/greenlizard/configure.in
==============================================================================
--- freeswitch/branches/greenlizard/configure.in (original)
+++ freeswitch/branches/greenlizard/configure.in Tue Jun 19 19:32:04 2007
@@ -334,6 +334,7 @@
src/mod/Makefile
src/mod/event_handlers/mod_cdr/Makefile
src/mod/endpoints/mod_sofia/Makefile
+ src/mod/event_handlers/mod_radius_cdr/Makefile
src/include/switch_am_config.h
build/getlib.sh
build/modmake.rules])
Modified: freeswitch/branches/greenlizard/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_ivr.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_ivr.h Tue Jun 19 19:32:04 2007
@@ -267,6 +267,7 @@
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, char *file, switch_input_args_t *args);
+SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, char *script, int32_t loops, switch_input_args_t *args);
/*!
\brief record a file from the session to a file
Modified: freeswitch/branches/greenlizard/src/include/switch_stun.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_stun.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_stun.h Tue Jun 19 19:32:04 2007
@@ -106,12 +106,12 @@
typedef struct {
int16_t type;
uint16_t length;
- char value[1];
+ char value[];
} switch_stun_packet_attribute_t;
typedef struct {
switch_stun_packet_header_t header;
- uint8_t first_attribute[1];
+ uint8_t first_attribute[];
} switch_stun_packet_t;
typedef struct {
@@ -228,7 +228,7 @@
\param packet the packet in question
\return the size in bytes (host order) of the entire packet
*/
-#define switch_stun_packet_length(packet) ntohs(packet->header.length) + sizeof(switch_stun_packet_header_t)
+#define switch_stun_packet_length(packet) ntohs(packet->header.length) + (sizeof(switch_stun_packet_header_t))
///\}
SWITCH_END_EXTERN_C
Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c Tue Jun 19 19:32:04 2007
@@ -2118,7 +2118,7 @@
char *dfile = NULL, *expanded = NULL;
if (member != NULL && file != NULL) {
- conference_file_node_t *fnode, *nptr;
+ conference_file_node_t *fnode, *nptr = NULL;
switch_memory_pool_t *pool;
if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
@@ -2128,7 +2128,7 @@
}
if (!strncasecmp(file, "say:", 4)) {
- status = conference_say(member->conference, file + 4, leadin);
+ status = conference_member_say(member, file + 4, leadin);
goto done;
}
@@ -2139,7 +2139,7 @@
}
file = dfile;
} else {
- status = conference_say(member->conference, file, leadin);
+ status = conference_member_say(member, file, leadin);
goto done;
}
}
Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c Tue Jun 19 19:32:04 2007
@@ -820,6 +820,35 @@
}
+static void gentones_function(switch_core_session_t *session, char *data)
+{
+ switch_channel_t *channel;
+ char *tone_script = NULL;
+ switch_input_args_t args = { 0 };
+ char *l;
+ int32_t loops = 0;
+
+ tone_script = switch_core_session_strdup(session, data);
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ switch_channel_pre_answer(channel);
+
+ if ((l = strchr(tone_script, '|'))) {
+ *l++ = '\0';
+ loops = atoi(l);
+
+ if (loops < 0) {
+ loops = -1;
+ }
+ }
+
+ args.input_callback = on_dtmf;
+ switch_ivr_gentones(session, tone_script, loops, &args);
+
+}
+
static void displace_session_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
@@ -1064,7 +1093,7 @@
};
static switch_application_interface_t displace_application_interface = {
- /*.interface_name */ "displace",
+ /*.interface_name */ "displace_session",
/*.application_function */ displace_session_function,
/* long_desc */ "Displace audio from a file to the channels input",
/* short_desc */ "Displace File",
@@ -1074,7 +1103,7 @@
};
static switch_application_interface_t stop_displace_application_interface = {
- /*.interface_name */ "displace",
+ /*.interface_name */ "stop_displace_session",
/*.application_function */ stop_displace_session_function,
/* long_desc */ "Stop Displacing to a file",
/* short_desc */ "Stop Displace File",
@@ -1124,6 +1153,17 @@
/* flags */ SAF_NONE,
/*.next */ &stop_record_session_application_interface
};
+
+static switch_application_interface_t gentones_application_interface = {
+ /*.interface_name */ "gentones",
+ /*.application_function */ gentones_function,
+ /* long_desc */ "Generate tones to the channel",
+ /* short_desc */ "Generate Tones",
+ /* syntax */ "<tgml_script>[|<loops>]",
+ /* flags */ SAF_NONE,
+ /*.next */ &playback_application_interface
+};
+
static switch_application_interface_t park_application_interface = {
/*.interface_name */ "park",
/*.application_function */ park_function,
@@ -1131,7 +1171,7 @@
/* short_desc */ NULL,
/* syntax */ NULL,
/* flags */ SAF_NONE,
- /*.next */ &playback_application_interface
+ /*.next */ &gentones_application_interface
};
static switch_application_interface_t echo_application_interface = {
Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Jun 19 19:32:04 2007
@@ -227,6 +227,8 @@
switch_core_session_rwunlock(a_session);
}
+ switch_mutex_lock(tech_pvt->profile->flag_mutex);
+
if (tech_pvt->nh) {
if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
@@ -241,13 +243,11 @@
nua_cancel(tech_pvt->nh, TAG_END());
}
}
- switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+ switch_set_flag(tech_pvt, TFLAG_BYE);
}
}
- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-
-
+ switch_clear_flag(tech_pvt, TFLAG_IO);
tech_pvt->profile->inuse--;
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
Modified: freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/README
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/README (original)
+++ freeswitch/branches/greenlizard/src/mod/event_handlers/mod_radius_cdr/README Tue Jun 19 19:32:04 2007
@@ -28,17 +28,31 @@
1) Compile and install freeradius-client library.
-2) Edit the top-level 'modules.conf'. Add the following entry:
+2) Edit the top level 'configure.in'. At approx line 336 you need to add:
+
+---
+AC_CONFIG_FILES([Makefile
+ src/Makefile
+ src/mod/Makefile
+ src/mod/event_handlers/mod_cdr/Makefile
++ src/mod/event_handlers/mod_radius_cdr/Makefile
+ src/mod/endpoints/mod_sofia/Makefile
+ src/include/switch_am_config.h
+ build/getlib.sh
+ build/modmake.rules])
+---
+
+3) Rerun bootstrap, re-run configure
+
+4) Edit the top-level 'modules.conf'. Add the following entry:
...
event_handlers/mod_radius_cdr
...
-3) Re-run configure ??? ( does this need to be done???)
-
-4) Run make, and make install. Make sure the module is built and installed.
+5) Run make, and make install. Make sure the module is built and installed.
-5) Configure FreeSWITCH to load it
+6) Configure FreeSWITCH to load mod_radius_cdr
- Copy the 'mod_radius_cdr.conf.xml' file to the FreeSWITCH conf directory
- Copy the 'radius/' directory to the FreeSWITCH conf directory
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Tue Jun 19 19:32:04 2007
@@ -63,6 +63,7 @@
static void session_destroy(JSContext * cx, JSObject * obj);
static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
+static JSBool session_set_callerdata(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
static switch_api_interface_t js_run_interface;
static switch_api_interface_t jsapi_interface;
@@ -80,7 +81,7 @@
static JSClass global_class = {
"Global", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, DEFAULT_SET_PROPERTY,
+ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
@@ -1994,6 +1995,7 @@
static JSFunctionSpec session_methods[] = {
{"originate", session_originate, 2},
+ {"setCallerData", session_set_callerdata, 2},
{"setHangupHook", session_hanguphook, 1},
{"setAutoHangup", session_autohangup, 1},
{"sayPhrase", session_sayphrase, 1},
@@ -2173,6 +2175,51 @@
return JS_TRUE;
}
+static JSBool session_set_callerdata(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+{
+ struct js_session *jss = NULL;
+ jss = JS_GetPrivate(cx, obj);
+ *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+
+ if (argc > 1) {
+ char *var, *val, **toset = NULL;
+ var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+ val = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+
+ if (!strcasecmp(var, "dialplan")) {
+ toset = &jss->dialplan;
+ } else if (!strcasecmp(var, "username")) {
+ toset = &jss->username;
+ } else if (!strcasecmp(var, "caller_id_name")) {
+ toset = &jss->caller_id_name;
+ } else if (!strcasecmp(var, "ani")) {
+ toset = &jss->ani;
+ } else if (!strcasecmp(var, "aniii")) {
+ toset = &jss->aniii;
+ } else if (!strcasecmp(var, "caller_id_number")) {
+ toset = &jss->caller_id_number;
+ } else if (!strcasecmp(var, "network_addr")) {
+ toset = &jss->network_addr;
+ } else if (!strcasecmp(var, "rdnis")) {
+ toset = &jss->rdnis;
+ } else if (!strcasecmp(var, "destination_number")) {
+ toset = &jss->destination_number;
+ } else if (!strcasecmp(var, "context")) {
+ toset = &jss->context;
+ }
+
+ if (toset) {
+ switch_safe_free(*toset);
+ *toset = strdup(val);
+ }
+
+ }
+
+ return JS_TRUE;
+
+}
+
+
static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = NULL;
@@ -2196,7 +2243,8 @@
char *context = "";
char *username = NULL;
char *to = NULL;
-
+ char *tmp;
+
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
@@ -2215,6 +2263,15 @@
}
}
+ if (!switch_strlen_zero(jss->dialplan)) dialplan = jss->dialplan;
+ if (!switch_strlen_zero(jss->caller_id_name)) cid_name = jss->caller_id_name;
+ if (!switch_strlen_zero(jss->caller_id_number)) cid_num = jss->caller_id_number;
+ if (!switch_strlen_zero(jss->ani)) ani = jss->ani;
+ if (!switch_strlen_zero(jss->aniii)) aniii = jss->aniii;
+ if (!switch_strlen_zero(jss->rdnis)) rdnis = jss->rdnis;
+ if (!switch_strlen_zero(jss->context)) context = jss->context;
+ if (!switch_strlen_zero(jss->username)) username = jss->username;
+
dest = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
if (!strchr(dest, '/')) {
@@ -2223,36 +2280,12 @@
}
if (argc > 2) {
- dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+ if (!switch_strlen_zero(tmp)) {
+ to = tmp;
+ }
}
- if (argc > 3) {
- context = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
- }
- if (argc > 4) {
- cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
- }
- if (argc > 5) {
- cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
- }
- if (argc > 6) {
- network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
- }
- if (argc > 7) {
- ani = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
- }
- if (argc > 8) {
- aniii = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
- }
- if (argc > 9) {
- rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
- }
- if (argc > 10) {
- username = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
- }
- if (argc > 11) {
- to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
- }
-
+
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
return JS_FALSE;
@@ -2293,18 +2326,28 @@
if (jss->session) {
channel = switch_core_session_get_channel(jss->session);
switch_channel_set_private(channel, "jss", NULL);
- }
+ switch_core_event_hook_remove_state_change(jss->session, hanguphook);
- switch_core_event_hook_remove_state_change(jss->session, hanguphook);
-
- if (channel && switch_test_flag(jss, S_HUP)) {
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- }
+ if (switch_test_flag(jss, S_HUP)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ }
+
+ if (switch_test_flag(jss, S_RDLOCK)) {
+ switch_core_session_rwunlock(jss->session);
+ }
- if (jss->session && switch_test_flag(jss, S_RDLOCK)) {
- switch_core_session_rwunlock(jss->session);
+ switch_safe_free(jss->dialplan);
+ switch_safe_free(jss->username);
+ switch_safe_free(jss->caller_id_name);
+ switch_safe_free(jss->ani);
+ switch_safe_free(jss->aniii);
+ switch_safe_free(jss->caller_id_number);
+ switch_safe_free(jss->network_addr);
+ switch_safe_free(jss->rdnis);
+ switch_safe_free(jss->destination_number);
+ switch_safe_free(jss->context);
}
-
+
if (switch_test_flag(jss, S_FREE)) {
free(jss);
}
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Tue Jun 19 19:32:04 2007
@@ -131,6 +131,16 @@
JSFunction *on_hangup;
int stack_depth;
switch_channel_state_t hook_state;
+ char *destination_number;
+ char *dialplan;
+ char *caller_id_name;
+ char *caller_id_number;
+ char *network_addr;
+ char *ani;
+ char *aniii;
+ char *rdnis;
+ char *context;
+ char *username;
};
JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)
Modified: freeswitch/branches/greenlizard/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_media_bug.c (original)
+++ freeswitch/branches/greenlizard/src/switch_core_media_bug.c Tue Jun 19 19:32:04 2007
@@ -156,10 +156,11 @@
switch_media_bug_callback_t callback,
void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
{
- switch_media_bug_t *bug, *bp;
+ switch_media_bug_t *bug;//, *bp;
switch_size_t bytes;
if (flags & SMBF_WRITE_REPLACE) {
+#if 0
switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
@@ -169,9 +170,11 @@
}
}
switch_thread_rwlock_unlock(session->bug_rwlock);
+#endif
}
if (flags & SMBF_READ_REPLACE) {
+#if 0
switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
if (switch_test_flag(bp, SMBF_READ_REPLACE)) {
@@ -181,6 +184,7 @@
}
}
switch_thread_rwlock_unlock(session->bug_rwlock);
+#endif
}
if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) {
Modified: freeswitch/branches/greenlizard/src/switch_ivr_async.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_async.c (original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_async.c Tue Jun 19 19:32:04 2007
@@ -605,7 +605,7 @@
}
for(i = 0; i < cont->index; i++) {
- if (!strcasecmp(key, cont->list[cont->index].key )) {
+ if (!switch_strlen_zero(cont->list[cont->index].key) && !strcasecmp(key, cont->list[cont->index].key)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Renabling %s\n", key);
cont->list[cont->index].up = 1;
teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
@@ -663,7 +663,7 @@
teletone_multi_tone_init(&cont->list[cont->index].mt, &cont->list[cont->index].map);
cont->session = session;
- switch_channel_answer(channel);
+ switch_channel_pre_answer(channel);
if (switch_strlen_zero(flags)) {
bflags = SMBF_READ_REPLACE;
Modified: freeswitch/branches/greenlizard/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_originate.c (original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_originate.c Tue Jun 19 19:32:04 2007
@@ -663,6 +663,7 @@
} else {
teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
+ ringback.ts.rate = read_codec->implementation->samples_per_second;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
//ringback.ts.debug = 1;
//ringback.ts.debug_stream = switch_core_get_console();
Modified: freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_play_say.c (original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_play_say.c Tue Jun 19 19:32:04 2007
@@ -477,6 +477,94 @@
return status;
}
+static int teletone_handler(teletone_generation_session_t * ts, teletone_tone_map_t * map)
+{
+ switch_buffer_t *audio_buffer = ts->user_data;
+ int wrote;
+
+ if (!audio_buffer) {
+ return -1;
+ }
+
+ wrote = teletone_mux_tones(ts, map);
+ switch_buffer_write(audio_buffer, ts->buffer, wrote * 2);
+
+ return 0;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, char *script, int32_t loops, switch_input_args_t *args)
+{
+ teletone_generation_session_t ts;
+ switch_buffer_t *audio_buffer;
+ switch_frame_t *read_frame = NULL;
+ switch_codec_t *read_codec = NULL, write_codec;
+ switch_frame_t write_frame;
+ switch_byte_t data[1024];
+ switch_channel_t *channel;
+
+ assert(session != NULL);
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ switch_channel_pre_answer(channel);
+ read_codec = switch_core_session_get_read_codec(session);
+
+ if (switch_core_codec_init(&write_codec,
+ "L16",
+ NULL,
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+
+ return SWITCH_STATUS_FALSE;
+ }
+
+ write_frame.codec = &write_codec;
+ write_frame.data = data;
+
+ switch_buffer_create_dynamic(&audio_buffer, 512, 1024, 0);
+ teletone_init_session(&ts, 0, teletone_handler, audio_buffer);
+ ts.rate = read_codec->implementation->samples_per_second;
+
+ teletone_run(&ts, script);
+
+ if (loops) {
+ switch_buffer_set_loops(audio_buffer, loops);
+ }
+
+ while(switch_channel_ready(channel)) {
+ switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
+
+ if (read_frame->datalen < 2 || switch_test_flag(read_frame, SFF_CNG)) {
+ continue;
+ }
+
+ if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data,
+ read_frame->codec->implementation->bytes_per_frame)) <= 0) {
+ break;
+ }
+
+ write_frame.samples = write_frame.datalen / 2;
+
+ if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
+ break;
+ }
+ }
+
+ switch_core_codec_destroy(&write_codec);
+ switch_buffer_destroy(&audio_buffer);
+ teletone_destroy_session(&ts);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
#define FILE_STARTSAMPLES 1024 * 32
#define FILE_BLOCKSIZE 1024 * 8
#define FILE_BUFSIZE 1024 * 64
1
0
19 Jun '07
Author: mikej
Date: Tue Jun 19 19:04:31 2007
New Revision: 5394
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
play only to member
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Tue Jun 19 19:04:31 2007
@@ -2118,7 +2118,7 @@
char *dfile = NULL, *expanded = NULL;
if (member != NULL && file != NULL) {
- conference_file_node_t *fnode, *nptr;
+ conference_file_node_t *fnode, *nptr = NULL;
switch_memory_pool_t *pool;
if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
@@ -2128,7 +2128,7 @@
}
if (!strncasecmp(file, "say:", 4)) {
- status = conference_say(member->conference, file + 4, leadin);
+ status = conference_member_say(member, file + 4, leadin);
goto done;
}
@@ -2139,7 +2139,7 @@
}
file = dfile;
} else {
- status = conference_say(member->conference, file, leadin);
+ status = conference_member_say(member, file, leadin);
goto done;
}
}
1
0
[commit] r5393 - in freeswitch/branches/greenlizard/src: . include mod/languages/mod_python
by Freeswitch SVN 19 Jun '07
by Freeswitch SVN 19 Jun '07
19 Jun '07
Author: greenlizard
Date: Tue Jun 19 19:01:33 2007
New Revision: 5393
Modified:
freeswitch/branches/greenlizard/src/include/switch_cpp.h
freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py
freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp
freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h
freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i
freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
freeswitch/branches/greenlizard/src/switch_cpp.cpp
Log:
implement originate() and bridge() methods. api changes for originate() per anthony's request: no longer passes 11 arguments
Modified: freeswitch/branches/greenlizard/src/include/switch_cpp.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_cpp.h (original)
+++ freeswitch/branches/greenlizard/src/include/switch_cpp.h Tue Jun 19 19:01:33 2007
@@ -16,6 +16,16 @@
void console_clean_log(char *msg);
char *api_execute(char *cmd, char *arg);
void api_reply_delete(char *reply);
+
+
+/**
+ * \brief - process language specific callback results
+ *
+ * First the actual callback is called, (in the case of python,
+ * PythonDTMFCallback), it then calls the language specific callback defined
+ * by the user (eg, some python method), and then _this_ function is called
+ * with the results of the language specific callback.
+ */
switch_status_t process_callback_result(char *raw_result,
struct input_callback_state *cb_state,
switch_core_session_t *session);
@@ -28,30 +38,55 @@
// eg, PyThreadState *threadState
void *extra; // currently used to store a switch_file_handle_t
char *funcargs; // extra string that will be passed to callback function
-} input_callback_state;
+} input_callback_state_t;
class CoreSession {
protected:
- switch_input_args_t args;
- switch_input_args_t *ap;
+ switch_input_args_t args; // holds ptr to cb function and input_callback_state struct
+ // which has a language specific callback function
+ switch_input_args_t *ap; // ptr to args .. (is this really needed?)
+ switch_caller_profile_t caller_profile; // avoid passing so many args to originate,
+ // instead set them here first
char *uuid;
char *tts_name;
char *voice_name;
void store_file_handle(switch_file_handle_t *fh);
public:
+ CoreSession();
CoreSession(char *uuid);
CoreSession(switch_core_session_t *new_session);
virtual ~CoreSession();
switch_core_session_t *session;
switch_channel_t *channel;
- input_callback_state cb_state;
+ input_callback_state cb_state; // callback state, always pointed to by the buf
+ // field in this->args
+
int answer();
int preAnswer();
void hangup(char *cause);
void setVariable(char *var, char *val);
char *getVariable(char *var);
+ /** \brief Set attributes of caller data for purposes of outgoing calls
+ * \param var - the variable name, eg, "caller_id_name"
+ * \param val - the data to set, eg, "bob"
+ */
+ void setCallerData(char *var, char *val);
+
+ /** \brief Originate a call to a destination
+ *
+ * \param old_session - the session where the call is originating from
+ * and also the session in which _this_ session was
+ * created
+ * \param dest - a string representing destination, eg, sofia/mydomain.com/foo@bar.com
+ * \return an int status code indicating success or failure
+ *
+ */
+ int originate(CoreSession *aleg_session,
+ char *dest,
+ int timeout=60);
+
/** \brief Play a file that resides on disk into the channel
*
* \param file - the path to the .wav/.mp3 to be played
@@ -125,10 +160,35 @@
virtual void begin_allow_threads();
virtual void end_allow_threads();
+ /** \brief Get the uuid of this session
+ * \return the uuid of this session
+ */
+ char* get_uuid() const { return uuid; };
+
+ /** \brief Get the callback function arguments associated with this session
+ * \return a const reference to the callback function arguments
+ */
+ const switch_input_args_t& get_cb_args() const { return args; };
+
};
+/* ---- functions not bound to CoreSession instance ----- */
+
+void console_log(char *level_str, char *msg);
+void console_clean_log(char *msg);
+char *api_execute(char *cmd, char *arg);
+void api_reply_delete(char *reply);
+
+/** \brief bridge the audio of session_b into session_a
+ *
+ * NOTE: the stuff regarding the dtmf callback might be completely
+ * wrong and has not been reviewed or tested
+ */
+void bridge(CoreSession &session_a, CoreSession &session_b);
+
+
#ifdef __cplusplus
}
#endif
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py Tue Jun 19 19:01:33 2007
@@ -53,32 +53,32 @@
api_execute = _freeswitch.api_execute
api_reply_delete = _freeswitch.api_reply_delete
process_callback_result = _freeswitch.process_callback_result
-class input_callback_state(_object):
+class input_callback_state_t(_object):
__swig_setmethods__ = {}
- __setattr__ = lambda self, name, value: _swig_setattr(self, input_callback_state, name, value)
+ __setattr__ = lambda self, name, value: _swig_setattr(self, input_callback_state_t, name, value)
__swig_getmethods__ = {}
- __getattr__ = lambda self, name: _swig_getattr(self, input_callback_state, name)
+ __getattr__ = lambda self, name: _swig_getattr(self, input_callback_state_t, name)
__repr__ = _swig_repr
- __swig_setmethods__["function"] = _freeswitch.input_callback_state_function_set
- __swig_getmethods__["function"] = _freeswitch.input_callback_state_function_get
- if _newclass:function = _swig_property(_freeswitch.input_callback_state_function_get, _freeswitch.input_callback_state_function_set)
- __swig_setmethods__["threadState"] = _freeswitch.input_callback_state_threadState_set
- __swig_getmethods__["threadState"] = _freeswitch.input_callback_state_threadState_get
- if _newclass:threadState = _swig_property(_freeswitch.input_callback_state_threadState_get, _freeswitch.input_callback_state_threadState_set)
- __swig_setmethods__["extra"] = _freeswitch.input_callback_state_extra_set
- __swig_getmethods__["extra"] = _freeswitch.input_callback_state_extra_get
- if _newclass:extra = _swig_property(_freeswitch.input_callback_state_extra_get, _freeswitch.input_callback_state_extra_set)
- __swig_setmethods__["funcargs"] = _freeswitch.input_callback_state_funcargs_set
- __swig_getmethods__["funcargs"] = _freeswitch.input_callback_state_funcargs_get
- if _newclass:funcargs = _swig_property(_freeswitch.input_callback_state_funcargs_get, _freeswitch.input_callback_state_funcargs_set)
+ __swig_setmethods__["function"] = _freeswitch.input_callback_state_t_function_set
+ __swig_getmethods__["function"] = _freeswitch.input_callback_state_t_function_get
+ if _newclass:function = _swig_property(_freeswitch.input_callback_state_t_function_get, _freeswitch.input_callback_state_t_function_set)
+ __swig_setmethods__["threadState"] = _freeswitch.input_callback_state_t_threadState_set
+ __swig_getmethods__["threadState"] = _freeswitch.input_callback_state_t_threadState_get
+ if _newclass:threadState = _swig_property(_freeswitch.input_callback_state_t_threadState_get, _freeswitch.input_callback_state_t_threadState_set)
+ __swig_setmethods__["extra"] = _freeswitch.input_callback_state_t_extra_set
+ __swig_getmethods__["extra"] = _freeswitch.input_callback_state_t_extra_get
+ if _newclass:extra = _swig_property(_freeswitch.input_callback_state_t_extra_get, _freeswitch.input_callback_state_t_extra_set)
+ __swig_setmethods__["funcargs"] = _freeswitch.input_callback_state_t_funcargs_set
+ __swig_getmethods__["funcargs"] = _freeswitch.input_callback_state_t_funcargs_get
+ if _newclass:funcargs = _swig_property(_freeswitch.input_callback_state_t_funcargs_get, _freeswitch.input_callback_state_t_funcargs_set)
def __init__(self, *args):
- this = _freeswitch.new_input_callback_state(*args)
+ this = _freeswitch.new_input_callback_state_t(*args)
try: self.this.append(this)
except: self.this = this
- __swig_destroy__ = _freeswitch.delete_input_callback_state
+ __swig_destroy__ = _freeswitch.delete_input_callback_state_t
__del__ = lambda self : None;
-input_callback_state_swigregister = _freeswitch.input_callback_state_swigregister
-input_callback_state_swigregister(input_callback_state)
+input_callback_state_t_swigregister = _freeswitch.input_callback_state_t_swigregister
+input_callback_state_t_swigregister(input_callback_state_t)
class CoreSession(_object):
__swig_setmethods__ = {}
@@ -106,6 +106,8 @@
def hangup(*args): return _freeswitch.CoreSession_hangup(*args)
def setVariable(*args): return _freeswitch.CoreSession_setVariable(*args)
def getVariable(*args): return _freeswitch.CoreSession_getVariable(*args)
+ def setCallerData(*args): return _freeswitch.CoreSession_setCallerData(*args)
+ def originate(*args): return _freeswitch.CoreSession_originate(*args)
def playFile(*args): return _freeswitch.CoreSession_playFile(*args)
def setDTMFCallback(*args): return _freeswitch.CoreSession_setDTMFCallback(*args)
def speak(*args): return _freeswitch.CoreSession_speak(*args)
@@ -118,9 +120,12 @@
def execute(*args): return _freeswitch.CoreSession_execute(*args)
def begin_allow_threads(*args): return _freeswitch.CoreSession_begin_allow_threads(*args)
def end_allow_threads(*args): return _freeswitch.CoreSession_end_allow_threads(*args)
+ def get_uuid(*args): return _freeswitch.CoreSession_get_uuid(*args)
+ def get_cb_args(*args): return _freeswitch.CoreSession_get_cb_args(*args)
CoreSession_swigregister = _freeswitch.CoreSession_swigregister
CoreSession_swigregister(CoreSession)
+bridge = _freeswitch.bridge
PythonDTMFCallback = _freeswitch.PythonDTMFCallback
class PySession(CoreSession):
__swig_setmethods__ = {}
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp Tue Jun 19 19:01:33 2007
@@ -1,6 +1,22 @@
#include "freeswitch_python.h"
#define sanity_check(x) do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
+#define init_vars() do { caller_profile.source = "mod_python"; } while(0)
+
+PySession::PySession() : CoreSession()
+{
+ init_vars();
+}
+
+PySession::PySession(char *uuid) : CoreSession(uuid)
+{
+ init_vars();
+}
+
+PySession::PySession(switch_core_session_t *new_session) : CoreSession(new_session)
+{
+ init_vars();
+}
void PySession::setDTMFCallback(PyObject *pyfunc, char *funcargs)
@@ -34,15 +50,16 @@
void PySession::begin_allow_threads(void) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::begin_allow_threads() called\n");
+ // swap out threadstate and store in instance variable
threadState = (void *) PyEval_SaveThread();
cb_state.threadState = threadState;
- // cb_state.extra = &fh;
args.buf = &cb_state;
ap = &args;
}
void PySession::end_allow_threads(void) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::end_allow_threads() called\n");
+ // swap in threadstate from instance variable saved earlier
PyEval_RestoreThread(((PyThreadState *)threadState));
}
@@ -52,4 +69,88 @@
}
+/* ----- functions not bound to PySession instance ------ */
+
+
+switch_status_t PythonDTMFCallback(switch_core_session_t *session,
+ void *input,
+ switch_input_type_t itype,
+ void *buf,
+ unsigned int buflen)
+{
+ PyObject *func, *arglist;
+ PyObject *result;
+ char *resultStr;
+ char *funcargs;
+ input_callback_state_t *cb_state;
+ switch_file_handle_t *fh = NULL;
+ PyThreadState *threadState = NULL;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PythonDTMFCallback\n");
+
+ if (!buf) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ cb_state = (input_callback_state *) buf;
+
+ func = (PyObject *) cb_state->function;
+ if (!func) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+ else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cb_state->function is NOT null\n");
+ }
+ if (!PyCallable_Check(func)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ funcargs = (char *) cb_state->funcargs;
+
+ arglist = Py_BuildValue("(sis)", input, itype, funcargs);
+ if (!arglist) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error building arglist");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ threadState = (PyThreadState *) cb_state->threadState;
+ if (!threadState) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate\n");
+ return SWITCH_STATUS_FALSE;
+ }
+ else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "restoring threadstate: %p\n", threadState);
+ }
+
+ PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "restored threadstate, calling python function: %p\n", func);
+
+ result = PyEval_CallObject(func, arglist);
+
+ threadState = PyEval_SaveThread();
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "called python function\n");
+
+ Py_DECREF(arglist); // Trash arglist
+ if (result && result != Py_None) {
+ resultStr = (char *) PyString_AsString(result);
+ Py_XDECREF(result);
+ return process_callback_result(resultStr, cb_state, session);
+ }
+ else {
+ return SWITCH_STATUS_FALSE;
+ }
+
+
+}
+
+
+
+
+
+
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h Tue Jun 19 19:01:33 2007
@@ -14,12 +14,12 @@
-// declaration for function that is defined in mod_python.i
-extern switch_status_t PythonDTMFCallback(switch_core_session *session,
- void *input,
- switch_input_type_t itype,
- void *buf,
- unsigned int buflen);
+switch_status_t PythonDTMFCallback(switch_core_session *session,
+ void *input,
+ switch_input_type_t itype,
+ void *buf,
+ unsigned int buflen);
+
void console_log(char *level_str, char *msg);
void console_clean_log(char *msg);
@@ -30,8 +30,9 @@
private:
void *threadState;
public:
- PySession(char *uuid) : CoreSession(uuid) {}
- PySession(switch_core_session_t *session) : CoreSession(session) {}
+ PySession();
+ PySession(char *uuid);
+ PySession(switch_core_session_t *session);
~PySession();
void setDTMFCallback(PyObject *pyfunc, char *funcargs);
void begin_allow_threads();
@@ -39,6 +40,7 @@
};
+
#ifdef __cplusplus
}
#endif
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python.i Tue Jun 19 19:01:33 2007
@@ -1,218 +1,21 @@
%module freeswitch
%include "cstring.i"
-%cstring_bounded_mutable(char *dtmf_buf, 128);
-%cstring_bounded_mutable(char *terminator, 8);
-
+/** insert the following includes into generated code so it compiles */
%{
#include "switch_cpp.h"
#include "freeswitch_python.h"
%}
+/**
+ * tell swig to grok everything defined in these header files and
+ * build all sorts of c wrappers and python shadows of the c wrappers.
+ */
%include switch_cpp.h
%include freeswitch_python.h
-%{
-
-
-
-switch_status_t PythonDTMFCallback(switch_core_session_t *session,
- void *input,
- switch_input_type_t itype,
- void *buf,
- unsigned int buflen)
-{
- PyObject *func, *arglist;
- PyObject *result;
- char *resultStr;
- char *funcargs;
- struct input_callback_state *cb_state;
- switch_file_handle_t *fh = NULL;
- PyThreadState *threadState = NULL;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "PythonDTMFCallback\n");
-
- if (!buf) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
- return SWITCH_STATUS_FALSE;
- }
-
- cb_state = (input_callback_state *) buf;
-
- func = (PyObject *) cb_state->function;
- if (!func) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null\n");
- return SWITCH_STATUS_FALSE;
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "cb_state->function is NOT null\n");
- }
- if (!PyCallable_Check(func)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
- return SWITCH_STATUS_FALSE;
- }
-
- funcargs = (char *) cb_state->funcargs;
-
- arglist = Py_BuildValue("(sis)", input, itype, funcargs);
- if (!arglist) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error building arglist");
- return SWITCH_STATUS_FALSE;
- }
-
- threadState = (PyThreadState *) cb_state->threadState;
- if (!threadState) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate\n");
- return SWITCH_STATUS_FALSE;
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "restoring threadstate: %p\n", threadState);
- }
-
- PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "restored threadstate, calling python function: %p\n", func);
-
- result = PyEval_CallObject(func, arglist);
-
- threadState = PyEval_SaveThread();
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "called python function\n");
-
- Py_DECREF(arglist); // Trash arglist
- if (result && result != Py_None) {
- resultStr = (char *) PyString_AsString(result);
- Py_XDECREF(result);
- return process_callback_result(resultStr, cb_state, session);
- }
- else {
- return SWITCH_STATUS_FALSE;
- }
-
-
-}
-
-
-switch_status_t process_callback_result(char *ret,
- struct input_callback_state *cb_state,
- switch_core_session_t *session)
-{
-
- switch_file_handle_t *fh = NULL;
- fh = (switch_file_handle_t *) cb_state->extra;
-
- if (!fh) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (!ret) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (!strncasecmp(ret, "speed", 4)) {
- char *p;
-
- if ((p = strchr(ret, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1;
- }
- fh->speed += step;
- } else {
- int speed = atoi(p);
- fh->speed = speed;
- }
- return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_FALSE;
-
- } else if (!strcasecmp(ret, "pause")) {
- if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
- switch_clear_flag(fh, SWITCH_FILE_PAUSE);
- } else {
- switch_set_flag(fh, SWITCH_FILE_PAUSE);
- }
- return SWITCH_STATUS_SUCCESS;
- } else if (!strcasecmp(ret, "stop")) {
- return SWITCH_STATUS_FALSE;
- } else if (!strcasecmp(ret, "restart")) {
- unsigned int pos = 0;
- fh->speed = 0;
- switch_core_file_seek(fh, &pos, 0, SEEK_SET);
- return SWITCH_STATUS_SUCCESS;
- } else if (!strncasecmp(ret, "seek", 4)) {
- switch_codec_t *codec;
- unsigned int samps = 0;
- unsigned int pos = 0;
- char *p;
- codec = switch_core_session_get_read_codec(session);
-
- if ((p = strchr(ret, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1000;
- }
- if (step > 0) {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
- } else {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
- }
- } else {
- samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, samps, SEEK_SET);
- }
- }
-
- return SWITCH_STATUS_SUCCESS;
- }
-
- if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
- return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_FALSE;
-
-
-}
-
-
-void console_log(char *level_str, char *msg)
-{
- switch_log_level_t level = SWITCH_LOG_DEBUG;
- if (level_str) {
- level = switch_log_str2level(level_str);
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
-}
-
-void console_clean_log(char *msg)
-{
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
-}
-
-
- char *api_execute(char *cmd, char *arg)
- {
- switch_stream_handle_t stream = { 0 };
- SWITCH_STANDARD_STREAM(stream);
- switch_api_execute(cmd, arg, NULL, &stream);
- return (char *) stream.data;
- }
-
- void api_reply_delete(char *reply)
- {
- if (!switch_strlen_zero(reply)) {
- free(reply);
- }
- }
-
+/** hmm .. dunno why this is here */
+%cstring_bounded_mutable(char *dtmf_buf, 128);
+%cstring_bounded_mutable(char *terminator, 8);
-%}
Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp Tue Jun 19 19:01:33 2007
@@ -2472,13 +2472,14 @@
#define SWIGTYPE_p_switch_channel_t swig_types[4]
#define SWIGTYPE_p_switch_core_session swig_types[5]
#define SWIGTYPE_p_switch_core_session_t swig_types[6]
-#define SWIGTYPE_p_switch_input_callback_function_t swig_types[7]
-#define SWIGTYPE_p_switch_input_type_t swig_types[8]
-#define SWIGTYPE_p_switch_status_t swig_types[9]
-#define SWIGTYPE_p_uint32_t swig_types[10]
-#define SWIGTYPE_p_void swig_types[11]
-static swig_type_info *swig_types[13];
-static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0};
+#define SWIGTYPE_p_switch_input_args_t swig_types[7]
+#define SWIGTYPE_p_switch_input_callback_function_t swig_types[8]
+#define SWIGTYPE_p_switch_input_type_t swig_types[9]
+#define SWIGTYPE_p_switch_status_t swig_types[10]
+#define SWIGTYPE_p_uint32_t swig_types[11]
+#define SWIGTYPE_p_void swig_types[12]
+static swig_type_info *swig_types[14];
+static swig_module_info swig_module = {swig_types, 13, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2887,209 +2888,6 @@
return res;
}
-
-
-
-
-switch_status_t PythonDTMFCallback(switch_core_session_t *session,
- void *input,
- switch_input_type_t itype,
- void *buf,
- unsigned int buflen)
-{
- PyObject *func, *arglist;
- PyObject *result;
- char *resultStr;
- char *funcargs;
- struct input_callback_state *cb_state;
- switch_file_handle_t *fh = NULL;
- PyThreadState *threadState = NULL;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "PythonDTMFCallback\n");
-
- if (!buf) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
- return SWITCH_STATUS_FALSE;
- }
-
- cb_state = (input_callback_state *) buf;
-
- func = (PyObject *) cb_state->function;
- if (!func) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null\n");
- return SWITCH_STATUS_FALSE;
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "cb_state->function is NOT null\n");
- }
- if (!PyCallable_Check(func)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
- return SWITCH_STATUS_FALSE;
- }
-
- funcargs = (char *) cb_state->funcargs;
-
- arglist = Py_BuildValue("(sis)", input, itype, funcargs);
- if (!arglist) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error building arglist");
- return SWITCH_STATUS_FALSE;
- }
-
- threadState = (PyThreadState *) cb_state->threadState;
- if (!threadState) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate\n");
- return SWITCH_STATUS_FALSE;
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "restoring threadstate: %p\n", threadState);
- }
-
- PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "restored threadstate, calling python function: %p\n", func);
-
- result = PyEval_CallObject(func, arglist);
-
- threadState = PyEval_SaveThread();
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "called python function\n");
-
- Py_DECREF(arglist); // Trash arglist
- if (result && result != Py_None) {
- resultStr = (char *) PyString_AsString(result);
- Py_XDECREF(result);
- return process_callback_result(resultStr, cb_state, session);
- }
- else {
- return SWITCH_STATUS_FALSE;
- }
-
-
-}
-
-
-switch_status_t process_callback_result(char *ret,
- struct input_callback_state *cb_state,
- switch_core_session_t *session)
-{
-
- switch_file_handle_t *fh = NULL;
- fh = (switch_file_handle_t *) cb_state->extra;
-
- if (!fh) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (!ret) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (!strncasecmp(ret, "speed", 4)) {
- char *p;
-
- if ((p = strchr(ret, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1;
- }
- fh->speed += step;
- } else {
- int speed = atoi(p);
- fh->speed = speed;
- }
- return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_FALSE;
-
- } else if (!strcasecmp(ret, "pause")) {
- if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
- switch_clear_flag(fh, SWITCH_FILE_PAUSE);
- } else {
- switch_set_flag(fh, SWITCH_FILE_PAUSE);
- }
- return SWITCH_STATUS_SUCCESS;
- } else if (!strcasecmp(ret, "stop")) {
- return SWITCH_STATUS_FALSE;
- } else if (!strcasecmp(ret, "restart")) {
- unsigned int pos = 0;
- fh->speed = 0;
- switch_core_file_seek(fh, &pos, 0, SEEK_SET);
- return SWITCH_STATUS_SUCCESS;
- } else if (!strncasecmp(ret, "seek", 4)) {
- switch_codec_t *codec;
- unsigned int samps = 0;
- unsigned int pos = 0;
- char *p;
- codec = switch_core_session_get_read_codec(session);
-
- if ((p = strchr(ret, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1000;
- }
- if (step > 0) {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
- } else {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
- }
- } else {
- samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, samps, SEEK_SET);
- }
- }
-
- return SWITCH_STATUS_SUCCESS;
- }
-
- if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
- return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_FALSE;
-
-
-}
-
-
-void console_log(char *level_str, char *msg)
-{
- switch_log_level_t level = SWITCH_LOG_DEBUG;
- if (level_str) {
- level = switch_log_str2level(level_str);
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
-}
-
-void console_clean_log(char *msg)
-{
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
-}
-
-
- char *api_execute(char *cmd, char *arg)
- {
- switch_stream_handle_t stream = { 0 };
- SWITCH_STANDARD_STREAM(stream);
- switch_api_execute(cmd, arg, NULL, &stream);
- return (char *) stream.data;
- }
-
- void api_reply_delete(char *reply)
- {
- if (!switch_strlen_zero(reply)) {
- free(reply);
- }
- }
-
-
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -3257,9 +3055,9 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_function_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_function_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *arg2 = (void *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3267,15 +3065,15 @@
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_function_set",&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_t_function_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_function_set" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_function_set" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, SWIG_POINTER_DISOWN);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_function_set" "', argument " "2"" of type '" "void *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_t_function_set" "', argument " "2"" of type '" "void *""'");
}
if (arg1) (arg1)->function = arg2;
@@ -3286,20 +3084,20 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_function_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_function_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_function_get",&obj0)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_t_function_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_function_get" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_function_get" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
result = (void *) ((arg1)->function);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 );
return resultobj;
@@ -3308,9 +3106,9 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_threadState_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_threadState_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *arg2 = (void *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3318,15 +3116,15 @@
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_threadState_set",&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_t_threadState_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_threadState_set" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_threadState_set" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, SWIG_POINTER_DISOWN);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_threadState_set" "', argument " "2"" of type '" "void *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_t_threadState_set" "', argument " "2"" of type '" "void *""'");
}
if (arg1) (arg1)->threadState = arg2;
@@ -3337,20 +3135,20 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_threadState_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_threadState_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_threadState_get",&obj0)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_t_threadState_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_threadState_get" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_threadState_get" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
result = (void *) ((arg1)->threadState);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 );
return resultobj;
@@ -3359,9 +3157,9 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_extra_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_extra_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *arg2 = (void *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3369,15 +3167,15 @@
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_extra_set",&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_t_extra_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_extra_set" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_extra_set" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, SWIG_POINTER_DISOWN);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_extra_set" "', argument " "2"" of type '" "void *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_t_extra_set" "', argument " "2"" of type '" "void *""'");
}
if (arg1) (arg1)->extra = arg2;
@@ -3388,20 +3186,20 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_extra_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_extra_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_extra_get",&obj0)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_t_extra_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_extra_get" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_extra_get" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
result = (void *) ((arg1)->extra);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 );
return resultobj;
@@ -3410,9 +3208,9 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_funcargs_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_funcargs_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
char *arg2 = (char *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3422,15 +3220,15 @@
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_funcargs_set",&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OO:input_callback_state_t_funcargs_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_funcargs_set" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_funcargs_set" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_funcargs_set" "', argument " "2"" of type '" "char *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "input_callback_state_t_funcargs_set" "', argument " "2"" of type '" "char *""'");
}
arg2 = reinterpret_cast< char * >(buf2);
if (arg1->funcargs) delete[] arg1->funcargs;
@@ -3449,20 +3247,20 @@
}
-SWIGINTERN PyObject *_wrap_input_callback_state_funcargs_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_input_callback_state_t_funcargs_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_funcargs_get",&obj0)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"O:input_callback_state_t_funcargs_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_funcargs_get" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "input_callback_state_t_funcargs_get" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
result = (char *) ((arg1)->funcargs);
resultobj = SWIG_FromCharPtr((const char *)result);
return resultobj;
@@ -3471,12 +3269,12 @@
}
-SWIGINTERN PyObject *_wrap_new_input_callback_state(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_input_callback_state_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *result = 0 ;
+ input_callback_state_t *result = 0 ;
- if (!PyArg_ParseTuple(args,(char *)":new_input_callback_state")) SWIG_fail;
- result = (input_callback_state *)new input_callback_state();
+ if (!PyArg_ParseTuple(args,(char *)":new_input_callback_state_t")) SWIG_fail;
+ result = (input_callback_state_t *)new input_callback_state_t();
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_input_callback_state, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -3484,19 +3282,19 @@
}
-SWIGINTERN PyObject *_wrap_delete_input_callback_state(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_input_callback_state_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- input_callback_state *arg1 = (input_callback_state *) 0 ;
+ input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"O:delete_input_callback_state",&obj0)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_input_callback_state_t",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_input_callback_state, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_input_callback_state" "', argument " "1"" of type '" "input_callback_state *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_input_callback_state_t" "', argument " "1"" of type '" "input_callback_state_t *""'");
}
- arg1 = reinterpret_cast< input_callback_state * >(argp1);
+ arg1 = reinterpret_cast< input_callback_state_t * >(argp1);
delete arg1;
resultobj = SWIG_Py_Void();
@@ -3506,7 +3304,7 @@
}
-SWIGINTERN PyObject *input_callback_state_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *input_callback_state_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_input_callback_state, SWIG_NewClientData(obj));
@@ -3515,6 +3313,19 @@
SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
+ CoreSession *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_CoreSession")) SWIG_fail;
+ result = (CoreSession *)new CoreSession();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoreSession, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
CoreSession *result = 0 ;
int res1 ;
@@ -3538,7 +3349,7 @@
}
-SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
CoreSession *result = 0 ;
@@ -3570,13 +3381,16 @@
for (ii = 0; (ii < argc) && (ii < 1); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
+ if (argc == 0) {
+ return _wrap_new_CoreSession__SWIG_0(self, args);
+ }
if (argc == 1) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_switch_core_session_t, 0);
_v = SWIG_CheckState(res);
if (_v) {
- return _wrap_new_CoreSession__SWIG_1(self, args);
+ return _wrap_new_CoreSession__SWIG_2(self, args);
}
}
if (argc == 1) {
@@ -3584,12 +3398,12 @@
int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
_v = SWIG_CheckState(res);
if (_v) {
- return _wrap_new_CoreSession__SWIG_0(self, args);
+ return _wrap_new_CoreSession__SWIG_1(self, args);
}
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CoreSession'.\n Possible C/C++ prototypes are:\n CoreSession(char *)\n CoreSession(switch_core_session_t *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CoreSession'.\n Possible C/C++ prototypes are:\n CoreSession()\n CoreSession(char *)\n CoreSession(switch_core_session_t *)\n");
return NULL;
}
@@ -3931,6 +3745,105 @@
}
+SWIGINTERN PyObject *_wrap_CoreSession_setCallerData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_setCallerData",&obj0,&obj1,&obj2)) 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_setCallerData" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_setCallerData" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_setCallerData" "', argument " "3"" of type '" "char *""'");
+ }
+ arg3 = reinterpret_cast< char * >(buf3);
+ (arg1)->setCallerData(arg2,arg3);
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_originate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ CoreSession *arg2 = (CoreSession *) 0 ;
+ char *arg3 = (char *) 0 ;
+ int arg4 = (int) 60 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO|O:CoreSession_originate",&obj0,&obj1,&obj2,&obj3)) 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_originate" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_CoreSession, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_originate" "', argument " "2"" of type '" "CoreSession *""'");
+ }
+ arg2 = reinterpret_cast< CoreSession * >(argp2);
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_originate" "', argument " "3"" of type '" "char *""'");
+ }
+ arg3 = reinterpret_cast< char * >(buf3);
+ if (obj3) {
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_originate" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ }
+ result = (int)(arg1)->originate(arg2,arg3,arg4);
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ return resultobj;
+fail:
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_CoreSession_playFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
@@ -4130,9 +4043,7 @@
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
- char temp2[128+1] ;
- char *t2 = 0 ;
- size_t n2 = 0 ;
+ char *buf2 = 0 ;
int alloc2 = 0 ;
int val3 ;
int ecode3 = 0 ;
@@ -4140,9 +4051,7 @@
char *buf4 = 0 ;
int alloc4 = 0 ;
int res5 ;
- char temp5[8+1] ;
- char *t5 = 0 ;
- size_t n5 = 0 ;
+ char *buf5 = 0 ;
int alloc5 = 0 ;
int val6 ;
int ecode6 = 0 ;
@@ -4159,15 +4068,11 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- res2 = SWIG_AsCharPtrAndSize(obj1, &t2, &n2, &alloc2);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "char *dtmf_buf""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "char *""'");
}
- if ( n2 > (size_t) 128 ) n2 = (size_t) 128;
- memcpy(temp2, t2, sizeof(char)*n2);
- if (alloc2 == SWIG_NEWOBJ) delete[] t2;
- temp2[n2 - 1] = 0;
- arg2 = (char *) temp2;
+ arg2 = reinterpret_cast< char * >(buf2);
ecode3 = SWIG_AsVal_int(obj2, &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "int""'");
@@ -4178,15 +4083,11 @@
SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *""'");
}
arg4 = reinterpret_cast< char * >(buf4);
- res5 = SWIG_AsCharPtrAndSize(obj4, &t5, &n5, &alloc5);
+ res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5);
if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *terminator""'");
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *""'");
}
- if ( n5 > (size_t) 8 ) n5 = (size_t) 8;
- memcpy(temp5, t5, sizeof(char)*n5);
- if (alloc5 == SWIG_NEWOBJ) delete[] t5;
- temp5[n5 - 1] = 0;
- arg5 = (char *) temp5;
+ arg5 = reinterpret_cast< char * >(buf5);
ecode6 = SWIG_AsVal_int(obj5, &val6);
if (!SWIG_IsOK(ecode6)) {
SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "int""'");
@@ -4194,14 +4095,14 @@
arg6 = static_cast< int >(val6);
result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6);
resultobj = SWIG_From_int(static_cast< int >(result));
- arg2[128] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg2));
- arg5[8] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg5));
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
return resultobj;
fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
return NULL;
}
@@ -4297,9 +4198,7 @@
char *buf8 = 0 ;
int alloc8 = 0 ;
int res9 ;
- char temp9[128+1] ;
- char *t9 = 0 ;
- size_t n9 = 0 ;
+ char *buf9 = 0 ;
int alloc9 = 0 ;
int res10 ;
char *buf10 = 0 ;
@@ -4356,15 +4255,11 @@
SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
}
arg8 = reinterpret_cast< char * >(buf8);
- res9 = SWIG_AsCharPtrAndSize(obj8, &t9, &n9, &alloc9);
+ 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 *dtmf_buf""'");
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
}
- if ( n9 > (size_t) 128 ) n9 = (size_t) 128;
- memcpy(temp9, t9, sizeof(char)*n9);
- if (alloc9 == SWIG_NEWOBJ) delete[] t9;
- temp9[n9 - 1] = 0;
- arg9 = (char *) temp9;
+ 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 *""'");
@@ -4372,17 +4267,17 @@
arg10 = reinterpret_cast< char * >(buf10);
result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
resultobj = SWIG_From_int(static_cast< int >(result));
- arg9[128] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg9));
if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
if (alloc10 == SWIG_NEWOBJ) delete[] buf10;
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;
if (alloc10 == SWIG_NEWOBJ) delete[] buf10;
return NULL;
}
@@ -4540,6 +4435,53 @@
}
+SWIGINTERN PyObject *_wrap_CoreSession_get_uuid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_get_uuid",&obj0)) 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_get_uuid" "', argument " "1"" of type '" "CoreSession const *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ result = (char *)((CoreSession const *)arg1)->get_uuid();
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_get_cb_args(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ switch_input_args_t *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_get_cb_args",&obj0)) 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_get_cb_args" "', argument " "1"" of type '" "CoreSession const *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ {
+ switch_input_args_t const &_result_ref = ((CoreSession const *)arg1)->get_cb_args();
+ result = (switch_input_args_t *) &_result_ref;
+ }
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_switch_input_args_t, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *CoreSession_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
@@ -4547,6 +4489,42 @@
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *_wrap_bridge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = 0 ;
+ CoreSession *arg2 = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:bridge",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_CoreSession, 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bridge" "', argument " "1"" of type '" "CoreSession &""'");
+ }
+ if (!argp1) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "bridge" "', argument " "1"" of type '" "CoreSession &""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_CoreSession, 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bridge" "', argument " "2"" of type '" "CoreSession &""'");
+ }
+ if (!argp2) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "bridge" "', argument " "2"" of type '" "CoreSession &""'");
+ }
+ arg2 = reinterpret_cast< CoreSession * >(argp2);
+ bridge(*arg1,*arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_PythonDTMFCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
switch_core_session *arg1 = (switch_core_session *) 0 ;
@@ -4611,6 +4589,19 @@
SWIGINTERN PyObject *_wrap_new_PySession__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
+ PySession *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_PySession")) SWIG_fail;
+ result = (PySession *)new PySession();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PySession, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_PySession__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
PySession *result = 0 ;
int res1 ;
@@ -4634,7 +4625,7 @@
}
-SWIGINTERN PyObject *_wrap_new_PySession__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_PySession__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
PySession *result = 0 ;
@@ -4666,13 +4657,16 @@
for (ii = 0; (ii < argc) && (ii < 1); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
+ if (argc == 0) {
+ return _wrap_new_PySession__SWIG_0(self, args);
+ }
if (argc == 1) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_switch_core_session_t, 0);
_v = SWIG_CheckState(res);
if (_v) {
- return _wrap_new_PySession__SWIG_1(self, args);
+ return _wrap_new_PySession__SWIG_2(self, args);
}
}
if (argc == 1) {
@@ -4680,12 +4674,12 @@
int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
_v = SWIG_CheckState(res);
if (_v) {
- return _wrap_new_PySession__SWIG_0(self, args);
+ return _wrap_new_PySession__SWIG_1(self, args);
}
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_PySession'.\n Possible C/C++ prototypes are:\n PySession(char *)\n PySession(switch_core_session_t *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_PySession'.\n Possible C/C++ prototypes are:\n PySession()\n PySession(char *)\n PySession(switch_core_session_t *)\n");
return NULL;
}
@@ -4803,17 +4797,17 @@
{ (char *)"api_execute", _wrap_api_execute, METH_VARARGS, NULL},
{ (char *)"api_reply_delete", _wrap_api_reply_delete, METH_VARARGS, NULL},
{ (char *)"process_callback_result", _wrap_process_callback_result, METH_VARARGS, NULL},
- { (char *)"input_callback_state_function_set", _wrap_input_callback_state_function_set, METH_VARARGS, NULL},
- { (char *)"input_callback_state_function_get", _wrap_input_callback_state_function_get, METH_VARARGS, NULL},
- { (char *)"input_callback_state_threadState_set", _wrap_input_callback_state_threadState_set, METH_VARARGS, NULL},
- { (char *)"input_callback_state_threadState_get", _wrap_input_callback_state_threadState_get, METH_VARARGS, NULL},
- { (char *)"input_callback_state_extra_set", _wrap_input_callback_state_extra_set, METH_VARARGS, NULL},
- { (char *)"input_callback_state_extra_get", _wrap_input_callback_state_extra_get, METH_VARARGS, NULL},
- { (char *)"input_callback_state_funcargs_set", _wrap_input_callback_state_funcargs_set, METH_VARARGS, NULL},
- { (char *)"input_callback_state_funcargs_get", _wrap_input_callback_state_funcargs_get, METH_VARARGS, NULL},
- { (char *)"new_input_callback_state", _wrap_new_input_callback_state, METH_VARARGS, NULL},
- { (char *)"delete_input_callback_state", _wrap_delete_input_callback_state, METH_VARARGS, NULL},
- { (char *)"input_callback_state_swigregister", input_callback_state_swigregister, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_function_set", _wrap_input_callback_state_t_function_set, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_function_get", _wrap_input_callback_state_t_function_get, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_threadState_set", _wrap_input_callback_state_t_threadState_set, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_threadState_get", _wrap_input_callback_state_t_threadState_get, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_extra_set", _wrap_input_callback_state_t_extra_set, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_extra_get", _wrap_input_callback_state_t_extra_get, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_funcargs_set", _wrap_input_callback_state_t_funcargs_set, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_funcargs_get", _wrap_input_callback_state_t_funcargs_get, METH_VARARGS, NULL},
+ { (char *)"new_input_callback_state_t", _wrap_new_input_callback_state_t, METH_VARARGS, NULL},
+ { (char *)"delete_input_callback_state_t", _wrap_delete_input_callback_state_t, METH_VARARGS, NULL},
+ { (char *)"input_callback_state_t_swigregister", input_callback_state_t_swigregister, METH_VARARGS, NULL},
{ (char *)"new_CoreSession", _wrap_new_CoreSession, METH_VARARGS, NULL},
{ (char *)"delete_CoreSession", _wrap_delete_CoreSession, METH_VARARGS, NULL},
{ (char *)"CoreSession_session_set", _wrap_CoreSession_session_set, METH_VARARGS, NULL},
@@ -4827,6 +4821,8 @@
{ (char *)"CoreSession_hangup", _wrap_CoreSession_hangup, METH_VARARGS, NULL},
{ (char *)"CoreSession_setVariable", _wrap_CoreSession_setVariable, METH_VARARGS, NULL},
{ (char *)"CoreSession_getVariable", _wrap_CoreSession_getVariable, METH_VARARGS, NULL},
+ { (char *)"CoreSession_setCallerData", _wrap_CoreSession_setCallerData, METH_VARARGS, NULL},
+ { (char *)"CoreSession_originate", _wrap_CoreSession_originate, METH_VARARGS, NULL},
{ (char *)"CoreSession_playFile", _wrap_CoreSession_playFile, METH_VARARGS, NULL},
{ (char *)"CoreSession_setDTMFCallback", _wrap_CoreSession_setDTMFCallback, METH_VARARGS, NULL},
{ (char *)"CoreSession_speak", _wrap_CoreSession_speak, METH_VARARGS, NULL},
@@ -4839,7 +4835,10 @@
{ (char *)"CoreSession_execute", _wrap_CoreSession_execute, METH_VARARGS, NULL},
{ (char *)"CoreSession_begin_allow_threads", _wrap_CoreSession_begin_allow_threads, METH_VARARGS, NULL},
{ (char *)"CoreSession_end_allow_threads", _wrap_CoreSession_end_allow_threads, METH_VARARGS, NULL},
+ { (char *)"CoreSession_get_uuid", _wrap_CoreSession_get_uuid, METH_VARARGS, NULL},
+ { (char *)"CoreSession_get_cb_args", _wrap_CoreSession_get_cb_args, METH_VARARGS, NULL},
{ (char *)"CoreSession_swigregister", CoreSession_swigregister, METH_VARARGS, NULL},
+ { (char *)"bridge", _wrap_bridge, METH_VARARGS, NULL},
{ (char *)"PythonDTMFCallback", _wrap_PythonDTMFCallback, METH_VARARGS, NULL},
{ (char *)"new_PySession", _wrap_new_PySession, METH_VARARGS, NULL},
{ (char *)"delete_PySession", _wrap_delete_PySession, METH_VARARGS, NULL},
@@ -4863,6 +4862,7 @@
static swig_type_info _swigt__p_switch_channel_t = {"_p_switch_channel_t", "switch_channel_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_core_session = {"_p_switch_core_session", "switch_core_session *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_core_session_t = {"_p_switch_core_session_t", "switch_core_session_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_callback_function_t = {"_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
@@ -4877,6 +4877,7 @@
&_swigt__p_switch_channel_t,
&_swigt__p_switch_core_session,
&_swigt__p_switch_core_session_t,
+ &_swigt__p_switch_input_args_t,
&_swigt__p_switch_input_callback_function_t,
&_swigt__p_switch_input_type_t,
&_swigt__p_switch_status_t,
@@ -4891,6 +4892,7 @@
static swig_cast_info _swigc__p_switch_channel_t[] = { {&_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_core_session[] = { {&_swigt__p_switch_core_session, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_core_session_t[] = { {&_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_input_args_t[] = { {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_callback_function_t[] = { {&_swigt__p_switch_input_callback_function_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = { {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = { {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -4905,6 +4907,7 @@
_swigc__p_switch_channel_t,
_swigc__p_switch_core_session,
_swigc__p_switch_core_session_t,
+ _swigc__p_switch_input_args_t,
_swigc__p_switch_input_callback_function_t,
_swigc__p_switch_input_type_t,
_swigc__p_switch_status_t,
Modified: freeswitch/branches/greenlizard/src/switch_cpp.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_cpp.cpp (original)
+++ freeswitch/branches/greenlizard/src/switch_cpp.cpp Tue Jun 19 19:01:33 2007
@@ -7,7 +7,14 @@
#define sanity_check(x) do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
#define sanity_check_noreturn do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
-#define init_vars() do { session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; memset(&args, 0, sizeof(args)); ap = NULL;} while(0)
+#define init_vars() do { session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown"; caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = ""; caller_profile.username = ""; } while(0)
+
+
+
+CoreSession::CoreSession()
+{
+ init_vars();
+}
CoreSession::CoreSession(char *nuuid)
{
@@ -177,7 +184,9 @@
{
switch_status_t status;
sanity_check(-1);
+ begin_allow_threads();
status = switch_ivr_session_transfer(session, extension, dialplan, context);
+ end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
@@ -251,6 +260,83 @@
}
+int CoreSession::originate(CoreSession *aleg_session,
+ char *dest,
+ int timeout)
+{
+
+ switch_memory_pool_t *pool = NULL;
+ switch_core_session_t *aleg_core_session = NULL;
+ switch_call_cause_t cause;
+
+ cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+
+ if (aleg_session != NULL) {
+ aleg_core_session = aleg_session->session;
+ }
+
+ begin_allow_threads();
+
+ if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
+ goto failed;
+ }
+
+ if (switch_ivr_originate(aleg_core_session,
+ &session,
+ &cause,
+ dest,
+ timeout,
+ NULL,
+ NULL,
+ NULL,
+ &caller_profile) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
+ goto failed;
+
+ }
+
+ end_allow_threads();
+ return SWITCH_STATUS_SUCCESS;
+
+ failed:
+ end_allow_threads();
+ return SWITCH_STATUS_FALSE;
+}
+
+
+void CoreSession::setCallerData(char *var, char *val) {
+
+ if (strcmp(var, "dialplan") == 0) {
+ caller_profile.dialplan = val;
+ }
+ if (strcmp(var, "context") == 0) {
+ caller_profile.context = val;
+ }
+ if (strcmp(var, "caller_id_name") == 0) {
+ caller_profile.caller_id_name = val;
+ }
+ if (strcmp(var, "caller_id_number") == 0) {
+ caller_profile.caller_id_number = val;
+ }
+ if (strcmp(var, "network_addr") == 0) {
+ caller_profile.network_addr = val;
+ }
+ if (strcmp(var, "ani") == 0) {
+ caller_profile.ani = val;
+ }
+ if (strcmp(var, "aniii") == 0) {
+ caller_profile.aniii = val;
+ }
+ if (strcmp(var, "rdnis") == 0) {
+ caller_profile.rdnis = val;
+ }
+ if (strcmp(var, "username") == 0) {
+ caller_profile.username = val;
+ }
+
+}
+
void CoreSession::begin_allow_threads() {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::begin_allow_threads() called and does nothing\n");
}
@@ -275,6 +361,147 @@
}
+/* ---- methods not bound to CoreSession instance ---- */
+
+
+void console_log(char *level_str, char *msg)
+{
+ switch_log_level_t level = SWITCH_LOG_DEBUG;
+ if (level_str) {
+ level = switch_log_str2level(level_str);
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
+ fflush(stdout); // TEMP ONLY!! SHOULD NOT BE CHECKED IN!!
+}
+
+void console_clean_log(char *msg)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
+}
+
+
+char *api_execute(char *cmd, char *arg)
+{
+ switch_stream_handle_t stream = { 0 };
+ SWITCH_STANDARD_STREAM(stream);
+ switch_api_execute(cmd, arg, NULL, &stream);
+ return (char *) stream.data;
+}
+
+void api_reply_delete(char *reply)
+{
+ if (!switch_strlen_zero(reply)) {
+ free(reply);
+ }
+}
+
+
+void bridge(CoreSession &session_a, CoreSession &session_b)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "bridge called, session_a uuid: %s\n", session_a.get_uuid());
+ switch_input_callback_function_t dtmf_func = NULL;
+ switch_input_args_t args;
+
+ session_a.begin_allow_threads();
+ args = session_a.get_cb_args(); // get the cb_args data structure for session a
+ dtmf_func = args.input_callback; // get the call back function
+ switch_ivr_multi_threaded_bridge(session_a.session, session_b.session, dtmf_func, args.buf, args.buf);
+ session_a.end_allow_threads();
+
+}
+
+
+
+switch_status_t process_callback_result(char *ret,
+ struct input_callback_state *cb_state,
+ switch_core_session_t *session)
+{
+
+ switch_file_handle_t *fh = NULL;
+ fh = (switch_file_handle_t *) cb_state->extra;
+
+ if (!fh) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!ret) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!strncasecmp(ret, "speed", 4)) {
+ char *p;
+
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1;
+ }
+ fh->speed += step;
+ } else {
+ int speed = atoi(p);
+ fh->speed = speed;
+ }
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+
+ } else if (!strcasecmp(ret, "pause")) {
+ if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(fh, SWITCH_FILE_PAUSE);
+ } else {
+ switch_set_flag(fh, SWITCH_FILE_PAUSE);
+ }
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strcasecmp(ret, "stop")) {
+ return SWITCH_STATUS_FALSE;
+ } else if (!strcasecmp(ret, "restart")) {
+ unsigned int pos = 0;
+ fh->speed = 0;
+ switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strncasecmp(ret, "seek", 4)) {
+ switch_codec_t *codec;
+ unsigned int samps = 0;
+ unsigned int pos = 0;
+ char *p;
+ codec = switch_core_session_get_read_codec(session);
+
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1000;
+ }
+ if (step > 0) {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ } else {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ }
+ } else {
+ samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_SET);
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+
+
+}
+
+
/* For Emacs:
* Local Variables:
* mode:c
1
0
Author: anthm
Date: Tue Jun 19 18:31:50 2007
New Revision: 5392
Modified:
freeswitch/trunk/src/switch_ivr_async.c
Log:
tweak
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Tue Jun 19 18:31:50 2007
@@ -663,7 +663,7 @@
teletone_multi_tone_init(&cont->list[cont->index].mt, &cont->list[cont->index].map);
cont->session = session;
- switch_channel_answer(channel);
+ switch_channel_pre_answer(channel);
if (switch_strlen_zero(flags)) {
bflags = SMBF_READ_REPLACE;
1
0
Author: anthm
Date: Tue Jun 19 14:25:17 2007
New Revision: 5391
Modified:
freeswitch/trunk/src/switch_core_media_bug.c
freeswitch/trunk/src/switch_ivr_async.c
Log:
testing a media bug change
Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c (original)
+++ freeswitch/trunk/src/switch_core_media_bug.c Tue Jun 19 14:25:17 2007
@@ -156,10 +156,11 @@
switch_media_bug_callback_t callback,
void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
{
- switch_media_bug_t *bug, *bp;
+ switch_media_bug_t *bug;//, *bp;
switch_size_t bytes;
if (flags & SMBF_WRITE_REPLACE) {
+#if 0
switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
@@ -169,9 +170,11 @@
}
}
switch_thread_rwlock_unlock(session->bug_rwlock);
+#endif
}
if (flags & SMBF_READ_REPLACE) {
+#if 0
switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
if (switch_test_flag(bp, SMBF_READ_REPLACE)) {
@@ -181,6 +184,7 @@
}
}
switch_thread_rwlock_unlock(session->bug_rwlock);
+#endif
}
if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) {
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Tue Jun 19 14:25:17 2007
@@ -605,7 +605,7 @@
}
for(i = 0; i < cont->index; i++) {
- if (!strcasecmp(key, cont->list[cont->index].key )) {
+ if (!switch_strlen_zero(cont->list[cont->index].key) && !strcasecmp(key, cont->list[cont->index].key)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Renabling %s\n", key);
cont->list[cont->index].up = 1;
teletone_multi_tone_init(&cont->list[i].mt, &cont->list[i].map);
1
0
19 Jun '07
Author: anthm
Date: Tue Jun 19 12:29:59 2007
New Revision: 5390
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
wtf was that?
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Jun 19 12:29:59 2007
@@ -227,6 +227,8 @@
switch_core_session_rwunlock(a_session);
}
+ switch_mutex_lock(tech_pvt->profile->flag_mutex);
+
if (tech_pvt->nh) {
if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
@@ -241,13 +243,11 @@
nua_cancel(tech_pvt->nh, TAG_END());
}
}
- switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+ switch_set_flag(tech_pvt, TFLAG_BYE);
}
}
- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-
-
+ switch_clear_flag(tech_pvt, TFLAG_IO);
tech_pvt->profile->inuse--;
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
1
0
19 Jun '07
Author: anthm
Date: Tue Jun 19 01:54:16 2007
New Revision: 5389
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
Log:
adjust api for session creation as planned
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Tue Jun 19 01:54:16 2007
@@ -63,6 +63,7 @@
static void session_destroy(JSContext * cx, JSObject * obj);
static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
+static JSBool session_set_callerdata(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval);
static switch_api_interface_t js_run_interface;
static switch_api_interface_t jsapi_interface;
@@ -1994,6 +1995,7 @@
static JSFunctionSpec session_methods[] = {
{"originate", session_originate, 2},
+ {"setCallerData", session_set_callerdata, 2},
{"setHangupHook", session_hanguphook, 1},
{"setAutoHangup", session_autohangup, 1},
{"sayPhrase", session_sayphrase, 1},
@@ -2173,6 +2175,51 @@
return JS_TRUE;
}
+static JSBool session_set_callerdata(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+{
+ struct js_session *jss = NULL;
+ jss = JS_GetPrivate(cx, obj);
+ *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+
+ if (argc > 1) {
+ char *var, *val, **toset = NULL;
+ var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+ val = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+
+ if (!strcasecmp(var, "dialplan")) {
+ toset = &jss->dialplan;
+ } else if (!strcasecmp(var, "username")) {
+ toset = &jss->username;
+ } else if (!strcasecmp(var, "caller_id_name")) {
+ toset = &jss->caller_id_name;
+ } else if (!strcasecmp(var, "ani")) {
+ toset = &jss->ani;
+ } else if (!strcasecmp(var, "aniii")) {
+ toset = &jss->aniii;
+ } else if (!strcasecmp(var, "caller_id_number")) {
+ toset = &jss->caller_id_number;
+ } else if (!strcasecmp(var, "network_addr")) {
+ toset = &jss->network_addr;
+ } else if (!strcasecmp(var, "rdnis")) {
+ toset = &jss->rdnis;
+ } else if (!strcasecmp(var, "destination_number")) {
+ toset = &jss->destination_number;
+ } else if (!strcasecmp(var, "context")) {
+ toset = &jss->context;
+ }
+
+ if (toset) {
+ switch_safe_free(*toset);
+ *toset = strdup(val);
+ }
+
+ }
+
+ return JS_TRUE;
+
+}
+
+
static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = NULL;
@@ -2216,6 +2263,15 @@
}
}
+ if (!switch_strlen_zero(jss->dialplan)) dialplan = jss->dialplan;
+ if (!switch_strlen_zero(jss->caller_id_name)) cid_name = jss->caller_id_name;
+ if (!switch_strlen_zero(jss->caller_id_number)) cid_num = jss->caller_id_number;
+ if (!switch_strlen_zero(jss->ani)) ani = jss->ani;
+ if (!switch_strlen_zero(jss->aniii)) aniii = jss->aniii;
+ if (!switch_strlen_zero(jss->rdnis)) rdnis = jss->rdnis;
+ if (!switch_strlen_zero(jss->context)) context = jss->context;
+ if (!switch_strlen_zero(jss->username)) username = jss->username;
+
dest = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
if (!strchr(dest, '/')) {
@@ -2226,60 +2282,10 @@
if (argc > 2) {
tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
if (!switch_strlen_zero(tmp)) {
- dialplan = tmp;
- }
- }
- if (argc > 3) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
- if (!switch_strlen_zero(tmp)) {
- context = tmp;
- }
- }
- if (argc > 4) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
- if (!switch_strlen_zero(tmp)) {
- cid_name = tmp;
- }
- }
- if (argc > 5) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
- if (!switch_strlen_zero(tmp)) {
- cid_num = tmp;
- }
- }
- if (argc > 6) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
- if (!switch_strlen_zero(tmp)) {
- network_addr = tmp;
- }
- }
- if (argc > 7) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
- if (!switch_strlen_zero(tmp)) {
- ani = tmp;
- } }
- if (argc > 8) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
- if (!switch_strlen_zero(tmp)) {
- aniii = tmp;
- } }
- if (argc > 9) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
- if (!switch_strlen_zero(tmp)) {
- rdnis = tmp;
- } }
- if (argc > 10) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
- if (!switch_strlen_zero(tmp)) {
- username = tmp;
- } }
- if (argc > 11) {
- tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
- if (!switch_strlen_zero(tmp)) {
to = tmp;
}
}
-
+
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
return JS_FALSE;
@@ -2330,8 +2336,18 @@
switch_core_session_rwunlock(jss->session);
}
+ switch_safe_free(jss->dialplan);
+ switch_safe_free(jss->username);
+ switch_safe_free(jss->caller_id_name);
+ switch_safe_free(jss->ani);
+ switch_safe_free(jss->aniii);
+ switch_safe_free(jss->caller_id_number);
+ switch_safe_free(jss->network_addr);
+ switch_safe_free(jss->rdnis);
+ switch_safe_free(jss->destination_number);
+ switch_safe_free(jss->context);
}
-
+
if (switch_test_flag(jss, S_FREE)) {
free(jss);
}
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Tue Jun 19 01:54:16 2007
@@ -131,6 +131,16 @@
JSFunction *on_hangup;
int stack_depth;
switch_channel_state_t hook_state;
+ char *destination_number;
+ char *dialplan;
+ char *caller_id_name;
+ char *caller_id_number;
+ char *network_addr;
+ char *ani;
+ char *aniii;
+ char *rdnis;
+ char *context;
+ char *username;
};
JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)
1
0
Author: anthm
Date: Mon Jun 18 13:37:29 2007
New Revision: 5388
Modified:
freeswitch/trunk/src/include/switch_stun.h
Log:
sigh
Modified: freeswitch/trunk/src/include/switch_stun.h
==============================================================================
--- freeswitch/trunk/src/include/switch_stun.h (original)
+++ freeswitch/trunk/src/include/switch_stun.h Mon Jun 18 13:37:29 2007
@@ -106,12 +106,12 @@
typedef struct {
int16_t type;
uint16_t length;
- char value[1];
+ char value[];
} switch_stun_packet_attribute_t;
typedef struct {
switch_stun_packet_header_t header;
- uint8_t first_attribute[1];
+ uint8_t first_attribute[];
} switch_stun_packet_t;
typedef struct {
@@ -228,7 +228,7 @@
\param packet the packet in question
\return the size in bytes (host order) of the entire packet
*/
-#define switch_stun_packet_length(packet) ntohs(packet->header.length) + sizeof(switch_stun_packet_header_t)
+#define switch_stun_packet_length(packet) ntohs(packet->header.length) + (sizeof(switch_stun_packet_header_t))
///\}
SWITCH_END_EXTERN_C
1
0
18 Jun '07
Author: anthm
Date: Mon Jun 18 11:44:28 2007
New Revision: 5387
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
Log:
js tweaks
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Mon Jun 18 11:44:28 2007
@@ -80,7 +80,7 @@
static JSClass global_class = {
"Global", JSCLASS_HAS_PRIVATE,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, DEFAULT_SET_PROPERTY,
+ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
@@ -2196,7 +2196,8 @@
char *context = "";
char *username = NULL;
char *to = NULL;
-
+ char *tmp;
+
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
@@ -2223,34 +2224,60 @@
}
if (argc > 2) {
- dialplan = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+ if (!switch_strlen_zero(tmp)) {
+ dialplan = tmp;
+ }
}
if (argc > 3) {
- context = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[3]));
+ if (!switch_strlen_zero(tmp)) {
+ context = tmp;
+ }
}
if (argc > 4) {
- cid_name = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[4]));
+ if (!switch_strlen_zero(tmp)) {
+ cid_name = tmp;
+ }
}
if (argc > 5) {
- cid_num = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[5]));
+ if (!switch_strlen_zero(tmp)) {
+ cid_num = tmp;
+ }
}
if (argc > 6) {
- network_addr = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[6]));
+ if (!switch_strlen_zero(tmp)) {
+ network_addr = tmp;
+ }
}
if (argc > 7) {
- ani = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
- }
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[7]));
+ if (!switch_strlen_zero(tmp)) {
+ ani = tmp;
+ } }
if (argc > 8) {
- aniii = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
- }
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[8]));
+ if (!switch_strlen_zero(tmp)) {
+ aniii = tmp;
+ } }
if (argc > 9) {
- rdnis = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
- }
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[9]));
+ if (!switch_strlen_zero(tmp)) {
+ rdnis = tmp;
+ } }
if (argc > 10) {
- username = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
- }
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[10]));
+ if (!switch_strlen_zero(tmp)) {
+ username = tmp;
+ } }
if (argc > 11) {
- to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
+ tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
+ if (!switch_strlen_zero(tmp)) {
+ to = tmp;
+ }
}
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
@@ -2293,16 +2320,16 @@
if (jss->session) {
channel = switch_core_session_get_channel(jss->session);
switch_channel_set_private(channel, "jss", NULL);
- }
+ switch_core_event_hook_remove_state_change(jss->session, hanguphook);
- switch_core_event_hook_remove_state_change(jss->session, hanguphook);
-
- if (channel && switch_test_flag(jss, S_HUP)) {
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- }
+ if (switch_test_flag(jss, S_HUP)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ }
+
+ if (switch_test_flag(jss, S_RDLOCK)) {
+ switch_core_session_rwunlock(jss->session);
+ }
- if (jss->session && switch_test_flag(jss, S_RDLOCK)) {
- switch_core_session_rwunlock(jss->session);
}
if (switch_test_flag(jss, S_FREE)) {
1
0