snake charming

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8998 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-07-11 19:42:52 +00:00
parent 0f873e692b
commit a3ccefa7e1
23 changed files with 2318 additions and 4906 deletions

View File

@ -331,7 +331,7 @@ libs/openzap/Makefile:
cd libs/openzap && autoconf
cd libs/openzap && ./configure
update-clean: clean modwipe uninstall libs/openzap/Makefile
update-clean: clean modwipe uninstall libs/openzap/Makefile python-reconf
cd libs/sofia-sip && $(MAKE) clean
cd libs/openzap && $(MAKE) clean
cd libs/portaudio && $(MAKE) clean
@ -347,6 +347,10 @@ speedy-sure: update-clean
cd libs/sofia-sip && $(MAKE) -j
$(MAKE) -j modules
python-reconf:
rm -f src/mod/languages/mod_python/Makefile
./config.status
pa-reconf:
cd libs/portaudio && $(MAKE) clean
cd libs/portaudio && sh ./configure.gnu

View File

@ -9,7 +9,8 @@ make mod_perl_wrap.cpp
cd ../../../..
cd src/mod/languages/mod_python
make reswig
make swigclean
make mod_python_wrap.cpp
cd ../../../..
cd src/mod/languages/mod_java

View File

@ -101,6 +101,14 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
S_RDLOCK = (1 << 2)
} session_flag_t;
class DTMF {
public:
char digit;
uint32_t duration;
SWITCH_DECLARE_CONSTRUCTOR DTMF(char idigit, uint32_t iduration = SWITCH_DEFAULT_DTMF_DURATION);
virtual SWITCH_DECLARE_CONSTRUCTOR ~DTMF();
};
class Stream {
protected:
switch_stream_handle_t mystream;
@ -172,7 +180,7 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
SWITCH_DECLARE_CONSTRUCTOR CoreSession();
SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid);
SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session);
SWITCH_DECLARE_CONSTRUCTOR ~ CoreSession();
virtual SWITCH_DECLARE_CONSTRUCTOR ~ CoreSession();
switch_core_session_t *session;
switch_channel_t *channel;
unsigned int flags;

View File

@ -0,0 +1,60 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
package org.freeswitch.swig;
public class DTMF {
private long swigCPtr;
protected boolean swigCMemOwn;
protected DTMF(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
protected static long getCPtr(DTMF obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
protected void finalize() {
delete();
}
public synchronized void delete() {
if(swigCPtr != 0 && swigCMemOwn) {
swigCMemOwn = false;
freeswitchJNI.delete_DTMF(swigCPtr);
}
swigCPtr = 0;
}
public void setDigit(char value) {
freeswitchJNI.DTMF_digit_set(swigCPtr, this, value);
}
public char getDigit() {
return freeswitchJNI.DTMF_digit_get(swigCPtr, this);
}
public void setDuration(SWIGTYPE_p_uint32_t value) {
freeswitchJNI.DTMF_duration_set(swigCPtr, this, SWIGTYPE_p_uint32_t.getCPtr(value));
}
public SWIGTYPE_p_uint32_t getDuration() {
return new SWIGTYPE_p_uint32_t(freeswitchJNI.DTMF_duration_get(swigCPtr, this), true);
}
public DTMF(char idigit, SWIGTYPE_p_uint32_t iduration) {
this(freeswitchJNI.new_DTMF__SWIG_0(idigit, SWIGTYPE_p_uint32_t.getCPtr(iduration)), true);
}
public DTMF(char idigit) {
this(freeswitchJNI.new_DTMF__SWIG_1(idigit), true);
}
}

View File

@ -0,0 +1,26 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.35
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
package org.freeswitch.swig;
public class SWIGTYPE_p_uint32_t {
private long swigCPtr;
protected SWIGTYPE_p_uint32_t(long cPtr, boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_uint32_t() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_uint32_t obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}

View File

@ -32,6 +32,13 @@ class freeswitchJNI {
public final static native int S_HUP_get();
public final static native int S_FREE_get();
public final static native int S_RDLOCK_get();
public final static native void DTMF_digit_set(long jarg1, DTMF jarg1_, char jarg2);
public final static native char DTMF_digit_get(long jarg1, DTMF jarg1_);
public final static native void DTMF_duration_set(long jarg1, DTMF jarg1_, long jarg2);
public final static native long DTMF_duration_get(long jarg1, DTMF jarg1_);
public final static native long new_DTMF__SWIG_0(char jarg1, long jarg2);
public final static native long new_DTMF__SWIG_1(char jarg1);
public final static native void delete_DTMF(long jarg1);
public final static native long new_Stream__SWIG_0();
public final static native long new_Stream__SWIG_1(long jarg1);
public final static native void delete_Stream(long jarg1);

View File

@ -643,6 +643,117 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_S_1RDLOCK_1get(JN
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_DTMF_1digit_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jchar jarg2) {
DTMF *arg1 = (DTMF *) 0 ;
char arg2 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(DTMF **)&jarg1;
arg2 = (char)jarg2;
if (arg1) (arg1)->digit = arg2;
}
SWIGEXPORT jchar JNICALL Java_org_freeswitch_swig_freeswitchJNI_DTMF_1digit_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jchar jresult = 0 ;
DTMF *arg1 = (DTMF *) 0 ;
char result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(DTMF **)&jarg1;
result = (char) ((arg1)->digit);
jresult = (jchar)result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_DTMF_1duration_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
DTMF *arg1 = (DTMF *) 0 ;
uint32_t arg2 ;
uint32_t *argp2 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(DTMF **)&jarg1;
argp2 = *(uint32_t **)&jarg2;
if (!argp2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null uint32_t");
return ;
}
arg2 = *argp2;
if (arg1) (arg1)->duration = arg2;
}
SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_DTMF_1duration_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
DTMF *arg1 = (DTMF *) 0 ;
uint32_t result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(DTMF **)&jarg1;
result = ((arg1)->duration);
*(uint32_t **)&jresult = new uint32_t((uint32_t &)result);
return jresult;
}
SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1DTMF_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jchar jarg1, jlong jarg2) {
jlong jresult = 0 ;
char arg1 ;
uint32_t arg2 ;
DTMF *result = 0 ;
uint32_t *argp2 ;
(void)jenv;
(void)jcls;
arg1 = (char)jarg1;
argp2 = *(uint32_t **)&jarg2;
if (!argp2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null uint32_t");
return 0;
}
arg2 = *argp2;
result = (DTMF *)new DTMF(arg1,arg2);
*(DTMF **)&jresult = result;
return jresult;
}
SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1DTMF_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jchar jarg1) {
jlong jresult = 0 ;
char arg1 ;
DTMF *result = 0 ;
(void)jenv;
(void)jcls;
arg1 = (char)jarg1;
result = (DTMF *)new DTMF(arg1);
*(DTMF **)&jresult = result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1DTMF(JNIEnv *jenv, jclass jcls, jlong jarg1) {
DTMF *arg1 = (DTMF *) 0 ;
(void)jenv;
(void)jcls;
arg1 = *(DTMF **)&jarg1;
delete arg1;
}
SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1Stream_1_1SWIG_10(JNIEnv *jenv, jclass jcls) {
jlong jresult = 0 ;
Stream *result = 0 ;

View File

@ -1486,29 +1486,31 @@ SWIG_Lua_dostring(lua_State *L, const char* str) {
#define SWIGTYPE_p_API swig_types[0]
#define SWIGTYPE_p_CoreSession swig_types[1]
#define SWIGTYPE_p_Event swig_types[2]
#define SWIGTYPE_p_EventConsumer swig_types[3]
#define SWIGTYPE_p_IVRMenu swig_types[4]
#define SWIGTYPE_p_LUA__Session swig_types[5]
#define SWIGTYPE_p_Stream swig_types[6]
#define SWIGTYPE_p_input_callback_state swig_types[7]
#define SWIGTYPE_p_lua_State swig_types[8]
#define SWIGTYPE_p_session_flag_t swig_types[9]
#define SWIGTYPE_p_switch_channel_state_t swig_types[10]
#define SWIGTYPE_p_switch_channel_t swig_types[11]
#define SWIGTYPE_p_switch_core_session_t swig_types[12]
#define SWIGTYPE_p_switch_event_node_t swig_types[13]
#define SWIGTYPE_p_switch_event_t swig_types[14]
#define SWIGTYPE_p_switch_event_types_t swig_types[15]
#define SWIGTYPE_p_switch_input_args_t swig_types[16]
#define SWIGTYPE_p_switch_input_type_t swig_types[17]
#define SWIGTYPE_p_switch_priority_t swig_types[18]
#define SWIGTYPE_p_switch_queue_t swig_types[19]
#define SWIGTYPE_p_switch_status_t swig_types[20]
#define SWIGTYPE_p_switch_stream_handle_t swig_types[21]
#define SWIGTYPE_p_void swig_types[22]
static swig_type_info *swig_types[24];
static swig_module_info swig_module = {swig_types, 23, 0, 0, 0, 0};
#define SWIGTYPE_p_DTMF swig_types[2]
#define SWIGTYPE_p_Event swig_types[3]
#define SWIGTYPE_p_EventConsumer swig_types[4]
#define SWIGTYPE_p_IVRMenu swig_types[5]
#define SWIGTYPE_p_LUA__Session swig_types[6]
#define SWIGTYPE_p_Stream swig_types[7]
#define SWIGTYPE_p_input_callback_state swig_types[8]
#define SWIGTYPE_p_lua_State swig_types[9]
#define SWIGTYPE_p_session_flag_t swig_types[10]
#define SWIGTYPE_p_switch_channel_state_t swig_types[11]
#define SWIGTYPE_p_switch_channel_t swig_types[12]
#define SWIGTYPE_p_switch_core_session_t swig_types[13]
#define SWIGTYPE_p_switch_event_node_t swig_types[14]
#define SWIGTYPE_p_switch_event_t swig_types[15]
#define SWIGTYPE_p_switch_event_types_t swig_types[16]
#define SWIGTYPE_p_switch_input_args_t swig_types[17]
#define SWIGTYPE_p_switch_input_type_t swig_types[18]
#define SWIGTYPE_p_switch_priority_t swig_types[19]
#define SWIGTYPE_p_switch_queue_t swig_types[20]
#define SWIGTYPE_p_switch_status_t swig_types[21]
#define SWIGTYPE_p_switch_stream_handle_t swig_types[22]
#define SWIGTYPE_p_uint32_t swig_types[23]
#define SWIGTYPE_p_void swig_types[24]
static swig_type_info *swig_types[26];
static swig_module_info swig_module = {swig_types, 25, 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)
@ -2143,6 +2145,254 @@ static swig_lua_class *swig_input_callback_state_t_bases[] = {0};
static const char *swig_input_callback_state_t_base_names[] = {0};
static swig_lua_class _wrap_class_input_callback_state_t = { "input_callback_state_t", &SWIGTYPE_p_input_callback_state,_wrap_new_input_callback_state_t, swig_delete_input_callback_state_t, swig_input_callback_state_t_methods, swig_input_callback_state_t_attributes, swig_input_callback_state_t_bases, swig_input_callback_state_t_base_names };
static int _wrap_DTMF_digit_set(lua_State* L) {
int SWIG_arg = -1;
DTMF *arg1 = (DTMF *) 0 ;
char arg2 ;
SWIG_check_num_args("digit",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("digit",1,"DTMF *");
if(!lua_isstring(L,2)) SWIG_fail_arg("digit",2,"char");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
SWIG_fail_ptr("DTMF_digit_set",1,SWIGTYPE_p_DTMF);
}
arg2 = (lua_tostring(L, 2))[0];
if (arg1) (arg1)->digit = arg2;
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_DTMF_digit_get(lua_State* L) {
int SWIG_arg = -1;
DTMF *arg1 = (DTMF *) 0 ;
char result;
SWIG_check_num_args("digit",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("digit",1,"DTMF *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
SWIG_fail_ptr("DTMF_digit_get",1,SWIGTYPE_p_DTMF);
}
result = (char) ((arg1)->digit);
SWIG_arg=0;
lua_pushfstring(L,"%c",result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_DTMF_duration_set(lua_State* L) {
int SWIG_arg = -1;
DTMF *arg1 = (DTMF *) 0 ;
uint32_t arg2 ;
uint32_t *argp2 ;
SWIG_check_num_args("duration",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("duration",1,"DTMF *");
if(!lua_isuserdata(L,2)) SWIG_fail_arg("duration",2,"uint32_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
SWIG_fail_ptr("DTMF_duration_set",1,SWIGTYPE_p_DTMF);
}
if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_uint32_t,0))){
SWIG_fail_ptr("DTMF_duration_set",2,SWIGTYPE_p_uint32_t);
}
arg2 = *argp2;
if (arg1) (arg1)->duration = arg2;
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_DTMF_duration_get(lua_State* L) {
int SWIG_arg = -1;
DTMF *arg1 = (DTMF *) 0 ;
uint32_t result;
SWIG_check_num_args("duration",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("duration",1,"DTMF *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
SWIG_fail_ptr("DTMF_duration_get",1,SWIGTYPE_p_DTMF);
}
result = ((arg1)->duration);
SWIG_arg=0;
{
uint32_t * resultptr = new uint32_t((uint32_t &) result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_uint32_t,1); SWIG_arg++;
}
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_new_DTMF__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
char arg1 ;
uint32_t arg2 ;
DTMF *result = 0 ;
uint32_t *argp2 ;
SWIG_check_num_args("DTMF",2,2)
if(!lua_isstring(L,1)) SWIG_fail_arg("DTMF",1,"char");
if(!lua_isuserdata(L,2)) SWIG_fail_arg("DTMF",2,"uint32_t");
arg1 = (lua_tostring(L, 1))[0];
if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_uint32_t,0))){
SWIG_fail_ptr("new_DTMF",2,SWIGTYPE_p_uint32_t);
}
arg2 = *argp2;
result = (DTMF *)new DTMF(arg1,arg2);
SWIG_arg=0;
SWIG_NewPointerObj(L,result,SWIGTYPE_p_DTMF,1); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_new_DTMF__SWIG_1(lua_State* L) {
int SWIG_arg = -1;
char arg1 ;
DTMF *result = 0 ;
SWIG_check_num_args("DTMF",1,1)
if(!lua_isstring(L,1)) SWIG_fail_arg("DTMF",1,"char");
arg1 = (lua_tostring(L, 1))[0];
result = (DTMF *)new DTMF(arg1);
SWIG_arg=0;
SWIG_NewPointerObj(L,result,SWIGTYPE_p_DTMF,1); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_new_DTMF(lua_State* L) {
int argc;
int argv[3]={
1,2,3
};
argc = lua_gettop(L);
if (argc == 1) {
int _v;
{
_v = lua_isstring(L,argv[0]) && (lua_strlen(L,argv[0])==1);
}
if (_v) {
return _wrap_new_DTMF__SWIG_1(L);
}
}
if (argc == 2) {
int _v;
{
_v = lua_isstring(L,argv[0]) && (lua_strlen(L,argv[0])==1);
}
if (_v) {
{
void *ptr;
if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_uint32_t, 0)) {
_v = 0;
} else {
_v = 1;
}
}
if (_v) {
return _wrap_new_DTMF__SWIG_0(L);
}
}
}
lua_pushstring(L,"No matching function for overloaded 'new_DTMF'");
lua_error(L);return 0;
}
static int _wrap_delete_DTMF(lua_State* L) {
int SWIG_arg = -1;
DTMF *arg1 = (DTMF *) 0 ;
SWIG_check_num_args("DTMF",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("DTMF",1,"DTMF *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,SWIG_POINTER_DISOWN))){
SWIG_fail_ptr("delete_DTMF",1,SWIGTYPE_p_DTMF);
}
delete arg1;
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static void swig_delete_DTMF(void *obj) {
DTMF *arg1 = (DTMF *) obj;
delete arg1;
}
static swig_lua_method swig_DTMF_methods[] = {
{0,0}
};
static swig_lua_attribute swig_DTMF_attributes[] = {
{ "digit", _wrap_DTMF_digit_get, _wrap_DTMF_digit_set},
{ "duration", _wrap_DTMF_duration_get, _wrap_DTMF_duration_set},
{0,0,0}
};
static swig_lua_class *swig_DTMF_bases[] = {0};
static const char *swig_DTMF_base_names[] = {0};
static swig_lua_class _wrap_class_DTMF = { "DTMF", &SWIGTYPE_p_DTMF,_wrap_new_DTMF, swig_delete_DTMF, swig_DTMF_methods, swig_DTMF_attributes, swig_DTMF_bases, swig_DTMF_base_names };
static int _wrap_new_Stream__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
Stream *result = 0 ;
@ -7029,6 +7279,7 @@ static void *_p_LUA__SessionTo_p_CoreSession(void *x, int *newmemory) {
}
static swig_type_info _swigt__p_API = {"_p_API", "API *", 0, 0, (void*)&_wrap_class_API, 0};
static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)&_wrap_class_CoreSession, 0};
static swig_type_info _swigt__p_DTMF = {"_p_DTMF", "DTMF *", 0, 0, (void*)&_wrap_class_DTMF, 0};
static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)&_wrap_class_Event, 0};
static swig_type_info _swigt__p_EventConsumer = {"_p_EventConsumer", "EventConsumer *", 0, 0, (void*)&_wrap_class_EventConsumer, 0};
static swig_type_info _swigt__p_IVRMenu = {"_p_IVRMenu", "IVRMenu *", 0, 0, (void*)&_wrap_class_IVRMenu, 0};
@ -7049,11 +7300,13 @@ static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "sw
static swig_type_info _swigt__p_switch_queue_t = {"_p_switch_queue_t", "switch_queue_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};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = {
&_swigt__p_API,
&_swigt__p_CoreSession,
&_swigt__p_DTMF,
&_swigt__p_Event,
&_swigt__p_EventConsumer,
&_swigt__p_IVRMenu,
@ -7074,11 +7327,13 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_switch_queue_t,
&_swigt__p_switch_status_t,
&_swigt__p_switch_stream_handle_t,
&_swigt__p_uint32_t,
&_swigt__p_void,
};
static swig_cast_info _swigc__p_API[] = { {&_swigt__p_API, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_CoreSession[] = { {&_swigt__p_CoreSession, 0, 0, 0}, {&_swigt__p_LUA__Session, _p_LUA__SessionTo_p_CoreSession, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_DTMF[] = { {&_swigt__p_DTMF, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Event[] = { {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_EventConsumer[] = { {&_swigt__p_EventConsumer, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_IVRMenu[] = { {&_swigt__p_IVRMenu, 0, 0, 0},{0, 0, 0, 0}};
@ -7099,11 +7354,13 @@ static swig_cast_info _swigc__p_switch_priority_t[] = { {&_swigt__p_switch_prio
static swig_cast_info _swigc__p_switch_queue_t[] = { {&_swigt__p_switch_queue_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}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_uint32_t[] = { {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = {
_swigc__p_API,
_swigc__p_CoreSession,
_swigc__p_DTMF,
_swigc__p_Event,
_swigc__p_EventConsumer,
_swigc__p_IVRMenu,
@ -7124,6 +7381,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_switch_queue_t,
_swigc__p_switch_status_t,
_swigc__p_switch_stream_handle_t,
_swigc__p_uint32_t,
_swigc__p_void,
};

View File

@ -179,6 +179,47 @@ sub ACQUIRE {
}
############# Class : freeswitch::DTMF ##############
package freeswitch::DTMF;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch );
%OWNER = ();
%ITERATORS = ();
*swig_digit_get = *freeswitchc::DTMF_digit_get;
*swig_digit_set = *freeswitchc::DTMF_digit_set;
*swig_duration_get = *freeswitchc::DTMF_duration_get;
*swig_duration_set = *freeswitchc::DTMF_duration_set;
sub new {
my $pkg = shift;
my $self = freeswitchc::new_DTMF(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_DTMF($self);
delete $OWNER{$self};
}
}
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : freeswitch::Stream ##############
package freeswitch::Stream;

View File

@ -1448,30 +1448,32 @@ SWIG_Perl_SetModule(swig_module_info *module) {
#define SWIGTYPE_p_API swig_types[0]
#define SWIGTYPE_p_CoreSession swig_types[1]
#define SWIGTYPE_p_Event swig_types[2]
#define SWIGTYPE_p_EventConsumer swig_types[3]
#define SWIGTYPE_p_IVRMenu swig_types[4]
#define SWIGTYPE_p_PERL__Session swig_types[5]
#define SWIGTYPE_p_PerlInterpreter swig_types[6]
#define SWIGTYPE_p_Stream swig_types[7]
#define SWIGTYPE_p_char swig_types[8]
#define SWIGTYPE_p_input_callback_state swig_types[9]
#define SWIGTYPE_p_session_flag_t swig_types[10]
#define SWIGTYPE_p_switch_channel_state_t swig_types[11]
#define SWIGTYPE_p_switch_channel_t swig_types[12]
#define SWIGTYPE_p_switch_core_session_t swig_types[13]
#define SWIGTYPE_p_switch_event_node_t swig_types[14]
#define SWIGTYPE_p_switch_event_t swig_types[15]
#define SWIGTYPE_p_switch_event_types_t swig_types[16]
#define SWIGTYPE_p_switch_input_args_t swig_types[17]
#define SWIGTYPE_p_switch_input_type_t swig_types[18]
#define SWIGTYPE_p_switch_priority_t swig_types[19]
#define SWIGTYPE_p_switch_queue_t swig_types[20]
#define SWIGTYPE_p_switch_status_t swig_types[21]
#define SWIGTYPE_p_switch_stream_handle_t swig_types[22]
#define SWIGTYPE_p_void swig_types[23]
static swig_type_info *swig_types[25];
static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0};
#define SWIGTYPE_p_DTMF swig_types[2]
#define SWIGTYPE_p_Event swig_types[3]
#define SWIGTYPE_p_EventConsumer swig_types[4]
#define SWIGTYPE_p_IVRMenu swig_types[5]
#define SWIGTYPE_p_PERL__Session swig_types[6]
#define SWIGTYPE_p_PerlInterpreter swig_types[7]
#define SWIGTYPE_p_Stream swig_types[8]
#define SWIGTYPE_p_char swig_types[9]
#define SWIGTYPE_p_input_callback_state swig_types[10]
#define SWIGTYPE_p_session_flag_t swig_types[11]
#define SWIGTYPE_p_switch_channel_state_t swig_types[12]
#define SWIGTYPE_p_switch_channel_t swig_types[13]
#define SWIGTYPE_p_switch_core_session_t swig_types[14]
#define SWIGTYPE_p_switch_event_node_t swig_types[15]
#define SWIGTYPE_p_switch_event_t swig_types[16]
#define SWIGTYPE_p_switch_event_types_t swig_types[17]
#define SWIGTYPE_p_switch_input_args_t swig_types[18]
#define SWIGTYPE_p_switch_input_type_t swig_types[19]
#define SWIGTYPE_p_switch_priority_t swig_types[20]
#define SWIGTYPE_p_switch_queue_t swig_types[21]
#define SWIGTYPE_p_switch_status_t swig_types[22]
#define SWIGTYPE_p_switch_stream_handle_t swig_types[23]
#define SWIGTYPE_p_uint32_t swig_types[24]
#define SWIGTYPE_p_void swig_types[25]
static swig_type_info *swig_types[27];
static swig_module_info swig_module = {swig_types, 26, 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)
@ -1726,6 +1728,56 @@ SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value)
}
SWIGINTERN int
SWIG_AsCharArray(SV * obj, char *val, size_t size)
{
char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ;
int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc);
if (SWIG_IsOK(res)) {
if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize;
if (csize <= size) {
if (val) {
if (csize) memcpy(val, cptr, csize*sizeof(char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char));
}
if (alloc == SWIG_NEWOBJ) {
delete[] cptr;
res = SWIG_DelNewMask(res);
}
return res;
}
if (alloc == SWIG_NEWOBJ) delete[] cptr;
}
return SWIG_TypeError;
}
SWIGINTERN int
SWIG_AsVal_char SWIG_PERL_DECL_ARGS_2(SV * obj, char *val)
{
int res = SWIG_AsCharArray(obj, val, 1);
if (!SWIG_IsOK(res)) {
long v;
res = SWIG_AddCast(SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v));
if (SWIG_IsOK(res)) {
if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) {
if (val) *val = static_cast< char >(v);
} else {
res = SWIG_OverflowError;
}
}
}
return res;
}
SWIGINTERNINLINE SV *
SWIG_From_char SWIG_PERL_DECL_ARGS_1(char c)
{
return SWIG_FromCharPtrAndSize(&c,1);
}
SWIGINTERNINLINE SV *
SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value)
{
@ -2664,6 +2716,313 @@ XS(_wrap_delete_input_callback_state_t) {
}
XS(_wrap_DTMF_digit_set) {
{
DTMF *arg1 = (DTMF *) 0 ;
char arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
char val2 ;
int ecode2 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: DTMF_digit_set(self,digit);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_DTMF, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DTMF_digit_set" "', argument " "1"" of type '" "DTMF *""'");
}
arg1 = reinterpret_cast< DTMF * >(argp1);
ecode2 = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DTMF_digit_set" "', argument " "2"" of type '" "char""'");
}
arg2 = static_cast< char >(val2);
if (arg1) (arg1)->digit = arg2;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_DTMF_digit_get) {
{
DTMF *arg1 = (DTMF *) 0 ;
char result;
void *argp1 = 0 ;
int res1 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: DTMF_digit_get(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_DTMF, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DTMF_digit_get" "', argument " "1"" of type '" "DTMF *""'");
}
arg1 = reinterpret_cast< DTMF * >(argp1);
result = (char) ((arg1)->digit);
ST(argvi) = SWIG_From_char SWIG_PERL_CALL_ARGS_1(static_cast< char >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_DTMF_duration_set) {
{
DTMF *arg1 = (DTMF *) 0 ;
uint32_t arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 ;
int res2 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: DTMF_duration_set(self,duration);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_DTMF, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DTMF_duration_set" "', argument " "1"" of type '" "DTMF *""'");
}
arg1 = reinterpret_cast< DTMF * >(argp1);
{
res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_uint32_t, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DTMF_duration_set" "', argument " "2"" of type '" "uint32_t""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DTMF_duration_set" "', argument " "2"" of type '" "uint32_t""'");
} else {
arg2 = *(reinterpret_cast< uint32_t * >(argp2));
}
}
if (arg1) (arg1)->duration = arg2;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_DTMF_duration_get) {
{
DTMF *arg1 = (DTMF *) 0 ;
uint32_t result;
void *argp1 = 0 ;
int res1 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: DTMF_duration_get(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_DTMF, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DTMF_duration_get" "', argument " "1"" of type '" "DTMF *""'");
}
arg1 = reinterpret_cast< DTMF * >(argp1);
result = ((arg1)->duration);
ST(argvi) = SWIG_NewPointerObj((new uint32_t(static_cast< const uint32_t& >(result))), SWIGTYPE_p_uint32_t, SWIG_POINTER_OWN | 0); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_new_DTMF__SWIG_0) {
{
char arg1 ;
uint32_t arg2 ;
DTMF *result = 0 ;
char val1 ;
int ecode1 = 0 ;
void *argp2 ;
int res2 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: new_DTMF(idigit,iduration);");
}
ecode1 = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DTMF" "', argument " "1"" of type '" "char""'");
}
arg1 = static_cast< char >(val1);
{
res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_uint32_t, 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_DTMF" "', argument " "2"" of type '" "uint32_t""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DTMF" "', argument " "2"" of type '" "uint32_t""'");
} else {
arg2 = *(reinterpret_cast< uint32_t * >(argp2));
}
}
result = (DTMF *)new DTMF(arg1,arg2);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DTMF, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_new_DTMF__SWIG_1) {
{
char arg1 ;
DTMF *result = 0 ;
char val1 ;
int ecode1 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: new_DTMF(idigit);");
}
ecode1 = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DTMF" "', argument " "1"" of type '" "char""'");
}
arg1 = static_cast< char >(val1);
result = (DTMF *)new DTMF(arg1);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DTMF, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_new_DTMF) {
dXSARGS;
{
unsigned long _index = 0;
SWIG_TypeRank _rank = 0;
if (items == 1) {
SWIG_TypeRank _ranki = 0;
SWIG_TypeRank _rankm = 0;
SWIG_TypeRank _pi = 1;
int _v = 0;
{
{
int res = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), NULL);
_v = SWIG_CheckState(res);
}
}
if (!_v) goto check_1;
_ranki += _v*_pi;
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
if (!_index || (_ranki < _rank)) {
_rank = _ranki; _index = 1;
if (_rank == _rankm) goto dispatch;
}
}
check_1:
if (items == 2) {
SWIG_TypeRank _ranki = 0;
SWIG_TypeRank _rankm = 0;
SWIG_TypeRank _pi = 1;
int _v = 0;
{
{
int res = SWIG_AsVal_char SWIG_PERL_CALL_ARGS_2(ST(0), NULL);
_v = SWIG_CheckState(res);
}
}
if (!_v) goto check_2;
_ranki += _v*_pi;
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
{
void *vptr = 0;
int res = SWIG_ConvertPtr(ST(1), &vptr, SWIGTYPE_p_uint32_t, 0);
_v = SWIG_CheckState(res);
}
if (!_v) goto check_2;
_ranki += _v*_pi;
_rankm += _pi;
_pi *= SWIG_MAXCASTRANK;
if (!_index || (_ranki < _rank)) {
_rank = _ranki; _index = 2;
if (_rank == _rankm) goto dispatch;
}
}
check_2:
dispatch:
switch(_index) {
case 1:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_DTMF__SWIG_1); return;
case 2:
++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_DTMF__SWIG_0); return;
}
}
croak("No matching function for overloaded 'new_DTMF'");
XSRETURN(0);
}
XS(_wrap_delete_DTMF) {
{
DTMF *arg1 = (DTMF *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: delete_DTMF(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_DTMF, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DTMF" "', argument " "1"" of type '" "DTMF *""'");
}
arg1 = reinterpret_cast< DTMF * >(argp1);
delete arg1;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_new_Stream__SWIG_0) {
{
Stream *result = 0 ;
@ -9174,6 +9533,7 @@ static void *_p_PERL__SessionTo_p_CoreSession(void *x, int *newmemory) {
}
static swig_type_info _swigt__p_API = {"_p_API", "API *", 0, 0, (void*)"freeswitch::API", 0};
static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)"freeswitch::CoreSession", 0};
static swig_type_info _swigt__p_DTMF = {"_p_DTMF", "DTMF *", 0, 0, (void*)"freeswitch::DTMF", 0};
static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)"freeswitch::Event", 0};
static swig_type_info _swigt__p_EventConsumer = {"_p_EventConsumer", "EventConsumer *", 0, 0, (void*)"freeswitch::EventConsumer", 0};
static swig_type_info _swigt__p_IVRMenu = {"_p_IVRMenu", "IVRMenu *", 0, 0, (void*)"freeswitch::IVRMenu", 0};
@ -9195,11 +9555,13 @@ static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "sw
static swig_type_info _swigt__p_switch_queue_t = {"_p_switch_queue_t", "switch_queue_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};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = {
&_swigt__p_API,
&_swigt__p_CoreSession,
&_swigt__p_DTMF,
&_swigt__p_Event,
&_swigt__p_EventConsumer,
&_swigt__p_IVRMenu,
@ -9221,11 +9583,13 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_switch_queue_t,
&_swigt__p_switch_status_t,
&_swigt__p_switch_stream_handle_t,
&_swigt__p_uint32_t,
&_swigt__p_void,
};
static swig_cast_info _swigc__p_API[] = { {&_swigt__p_API, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_CoreSession[] = { {&_swigt__p_CoreSession, 0, 0, 0}, {&_swigt__p_PERL__Session, _p_PERL__SessionTo_p_CoreSession, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_DTMF[] = { {&_swigt__p_DTMF, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Event[] = { {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_EventConsumer[] = { {&_swigt__p_EventConsumer, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_IVRMenu[] = { {&_swigt__p_IVRMenu, 0, 0, 0},{0, 0, 0, 0}};
@ -9247,11 +9611,13 @@ static swig_cast_info _swigc__p_switch_priority_t[] = { {&_swigt__p_switch_prio
static swig_cast_info _swigc__p_switch_queue_t[] = { {&_swigt__p_switch_queue_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}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_uint32_t[] = { {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = {
_swigc__p_API,
_swigc__p_CoreSession,
_swigc__p_DTMF,
_swigc__p_Event,
_swigc__p_EventConsumer,
_swigc__p_IVRMenu,
@ -9273,6 +9639,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_switch_queue_t,
_swigc__p_switch_status_t,
_swigc__p_switch_stream_handle_t,
_swigc__p_uint32_t,
_swigc__p_void,
};
@ -9309,6 +9676,12 @@ static swig_command_info swig_commands[] = {
{"freeswitchc::input_callback_state_t_funcargs_get", _wrap_input_callback_state_t_funcargs_get},
{"freeswitchc::new_input_callback_state_t", _wrap_new_input_callback_state_t},
{"freeswitchc::delete_input_callback_state_t", _wrap_delete_input_callback_state_t},
{"freeswitchc::DTMF_digit_set", _wrap_DTMF_digit_set},
{"freeswitchc::DTMF_digit_get", _wrap_DTMF_digit_get},
{"freeswitchc::DTMF_duration_set", _wrap_DTMF_duration_set},
{"freeswitchc::DTMF_duration_get", _wrap_DTMF_duration_get},
{"freeswitchc::new_DTMF", _wrap_new_DTMF},
{"freeswitchc::delete_DTMF", _wrap_delete_DTMF},
{"freeswitchc::new_Stream", _wrap_new_Stream},
{"freeswitchc::delete_Stream", _wrap_delete_Stream},
{"freeswitchc::Stream_write", _wrap_Stream_write},
@ -9734,6 +10107,7 @@ XS(SWIG_init) {
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK)));
SvREADONLY_on(sv);
} while(0) /*@SWIG@*/;
SWIG_TypeClientData(SWIGTYPE_p_DTMF, (void*) "freeswitch::DTMF");
SWIG_TypeClientData(SWIGTYPE_p_Stream, (void*) "freeswitch::Stream");
SWIG_TypeClientData(SWIGTYPE_p_Event, (void*) "freeswitch::Event");
SWIG_TypeClientData(SWIGTYPE_p_EventConsumer, (void*) "freeswitch::EventConsumer");

View File

@ -11,19 +11,20 @@ include ../../../../build/modmake.rules
LINK=$(CXXLINK)
PYMOD=freeswitch
PYTHON_SITE_DIR=@PYTHON_SITE_DIR@
PYTHON_SITE_DIR=/usr/lib/python2.4/site-packages
SWIGCFILE=../../../switch_swig.c
SWIGIFILE=../../../switch_swig.i
reswig:
swig -python -shadow -c++ -I../../../../src/include -o mod_python_wrap.cpp mod_python.i
reswig: swigclean mod_python_wrap.cpp
switch_swig_wrap.o: switch_swig_wrap.c Makefile
$(CC) -w $(CFLAGS) -c $< -o $@
swigclean: clean
rm -f mod_python_wrap.* freeswitch.py
switch_swig.o: $(SWIGCFILE) Makefile
$(CC) -w $(CFLAGS) -c $< -o $@
mod_python_wrap.cpp: mod_python_extra.c
swig -python -c++ -I../../../../src/include -oh mod_python_wrap.h -o mod_python_wrap.cpp mod_python.i
echo "#include \"mod_python_extra.c\"" >> mod_python_wrap.cpp
patch -s -p0 -i hack.diff
local_install:
mkdir -m755 -p $(DESTDIR)$(PYTHON_SITE_DIR)

View File

@ -114,6 +114,27 @@ input_callback_state_t_swigregister(input_callback_state_t)
S_HUP = _freeswitch.S_HUP
S_FREE = _freeswitch.S_FREE
S_RDLOCK = _freeswitch.S_RDLOCK
class DTMF(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, DTMF, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, DTMF, name)
__repr__ = _swig_repr
__swig_setmethods__["digit"] = _freeswitch.DTMF_digit_set
__swig_getmethods__["digit"] = _freeswitch.DTMF_digit_get
if _newclass:digit = _swig_property(_freeswitch.DTMF_digit_get, _freeswitch.DTMF_digit_set)
__swig_setmethods__["duration"] = _freeswitch.DTMF_duration_set
__swig_getmethods__["duration"] = _freeswitch.DTMF_duration_get
if _newclass:duration = _swig_property(_freeswitch.DTMF_duration_get, _freeswitch.DTMF_duration_set)
def __init__(self, *args):
this = _freeswitch.new_DTMF(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _freeswitch.delete_DTMF
__del__ = lambda self : None;
DTMF_swigregister = _freeswitch.DTMF_swigregister
DTMF_swigregister(DTMF)
class Stream(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Stream, name, value)
@ -274,31 +295,43 @@ console_clean_log = _freeswitch.console_clean_log
bridge = _freeswitch.bridge
hanguphook = _freeswitch.hanguphook
dtmf_callback = _freeswitch.dtmf_callback
S_SWAPPED_IN = _freeswitch.S_SWAPPED_IN
S_SWAPPED_OUT = _freeswitch.S_SWAPPED_OUT
class PySession(CoreSession):
class Session(CoreSession):
__swig_setmethods__ = {}
for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, PySession, name, value)
__setattr__ = lambda self, name, value: _swig_setattr(self, Session, name, value)
__swig_getmethods__ = {}
for _s in [CoreSession]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, PySession, name)
__getattr__ = lambda self, name: _swig_getattr(self, Session, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _freeswitch.new_PySession(*args)
this = _freeswitch.new_Session(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _freeswitch.delete_PySession
__swig_destroy__ = _freeswitch.delete_Session
__del__ = lambda self : None;
def setDTMFCallback(*args): return _freeswitch.PySession_setDTMFCallback(*args)
def setHangupHook(*args): return _freeswitch.PySession_setHangupHook(*args)
def check_hangup_hook(*args): return _freeswitch.PySession_check_hangup_hook(*args)
def hangup(*args): return _freeswitch.PySession_hangup(*args)
def begin_allow_threads(*args): return _freeswitch.PySession_begin_allow_threads(*args)
def end_allow_threads(*args): return _freeswitch.PySession_end_allow_threads(*args)
def run_dtmf_callback(*args): return _freeswitch.PySession_run_dtmf_callback(*args)
PySession_swigregister = _freeswitch.PySession_swigregister
PySession_swigregister(PySession)
def begin_allow_threads(*args): return _freeswitch.Session_begin_allow_threads(*args)
def end_allow_threads(*args): return _freeswitch.Session_end_allow_threads(*args)
def check_hangup_hook(*args): return _freeswitch.Session_check_hangup_hook(*args)
def run_dtmf_callback(*args): return _freeswitch.Session_run_dtmf_callback(*args)
def setInputCallback(*args): return _freeswitch.Session_setInputCallback(*args)
def setHangupHook(*args): return _freeswitch.Session_setHangupHook(*args)
def ready(*args): return _freeswitch.Session_ready(*args)
__swig_setmethods__["cb_function"] = _freeswitch.Session_cb_function_set
__swig_getmethods__["cb_function"] = _freeswitch.Session_cb_function_get
if _newclass:cb_function = _swig_property(_freeswitch.Session_cb_function_get, _freeswitch.Session_cb_function_set)
__swig_setmethods__["cb_arg"] = _freeswitch.Session_cb_arg_set
__swig_getmethods__["cb_arg"] = _freeswitch.Session_cb_arg_get
if _newclass:cb_arg = _swig_property(_freeswitch.Session_cb_arg_get, _freeswitch.Session_cb_arg_set)
__swig_setmethods__["hangup_func"] = _freeswitch.Session_hangup_func_set
__swig_getmethods__["hangup_func"] = _freeswitch.Session_hangup_func_get
if _newclass:hangup_func = _swig_property(_freeswitch.Session_hangup_func_get, _freeswitch.Session_hangup_func_set)
__swig_setmethods__["hangup_func_arg"] = _freeswitch.Session_hangup_func_arg_set
__swig_getmethods__["hangup_func_arg"] = _freeswitch.Session_hangup_func_arg_get
if _newclass:hangup_func_arg = _swig_property(_freeswitch.Session_hangup_func_arg_get, _freeswitch.Session_hangup_func_arg_set)
def setPython(*args): return _freeswitch.Session_setPython(*args)
def setSelf(*args): return _freeswitch.Session_setSelf(*args)
Session_swigregister = _freeswitch.Session_swigregister
Session_swigregister(Session)

View File

@ -1,320 +1,301 @@
#include <switch.h>
#include "freeswitch_python.h"
using namespace PYTHON;
#define py_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 py_init_vars() do { caller_profile.source = "mod_python"; swapstate = S_SWAPPED_IN; } while(0)
#define py_init_vars() cb_function = cb_arg = hangup_func = hangup_func_arg = NULL; hh = mark = 0; TS = NULL
PySession::PySession():CoreSession()
Session::Session():CoreSession()
{
py_init_vars();
}
PySession::PySession(char *uuid):CoreSession(uuid)
Session::Session(char *uuid):CoreSession(uuid)
{
py_init_vars();
}
PySession::PySession(switch_core_session_t *new_session):CoreSession(new_session)
Session::Session(switch_core_session_t *new_session):CoreSession(new_session)
{
py_init_vars();
}
static switch_status_t python_hanguphook(switch_core_session_t *session_hungup);
void PySession::setDTMFCallback(PyObject * pyfunc, char *funcargs)
Session::~Session()
{
py_sanity_check();
if (!PyCallable_Check(pyfunc)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "DTMF function is not a python function.\n");
return;
if (hangup_func) {
if (session) {
switch_core_event_hook_remove_state_change(session, python_hanguphook);
}
Py_XDECREF(hangup_func);
hangup_func = NULL;
}
if (hangup_func_arg) {
Py_XDECREF(hangup_func_arg);
hangup_func_arg = NULL;
}
Py_XINCREF(pyfunc);
CoreSession::setDTMFCallback((void *) pyfunc, funcargs);
if (cb_function) {
Py_XDECREF(cb_function);
cb_function = NULL;
}
if (cb_arg) {
Py_XDECREF(cb_arg);
cb_arg = NULL;
}
if (Self) {
Py_XDECREF(Self);
}
}
bool Session::begin_allow_threads()
{
do_hangup_hook();
if (!TS) {
TS = PyEval_SaveThread();
return true;
}
return false;
}
bool Session::end_allow_threads()
{
if (!TS) {
return false;
}
PyEval_RestoreThread(TS);
TS = NULL;
do_hangup_hook();
return true;
}
void Session::setPython(PyObject *state)
{
Py = state;
}
void Session::setSelf(PyObject *state)
{
Self = state;
}
PyObject *Session::getPython()
{
return Py;
}
bool Session::ready()
{
bool r;
sanity_check(false);
r = switch_channel_ready(channel) != 0;
do_hangup_hook();
return r;
}
void Session::check_hangup_hook()
{
if (hangup_func && (hook_state == CS_HANGUP || hook_state == CS_ROUTING)) {
hh++;
}
}
void Session::do_hangup_hook()
{
PyObject *result, *arglist;
const char *what = hook_state == CS_HANGUP ? "hangup" : "transfer";
if (hh && !mark) {
mark++;
if (hangup_func) {
if (!PyCallable_Check(hangup_func)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
return;
}
if (!Self) {
mod_python_conjure_session(NULL, session, NULL);
}
if (hangup_func_arg) {
arglist = Py_BuildValue("(OsO)", Self, what, hangup_func_arg);
} else {
arglist = Py_BuildValue("(Os)", Self, what);
}
if (!(result = PyEval_CallObject(hangup_func, arglist))) {
PyErr_Print();
}
Py_XDECREF(arglist);
Py_XDECREF(hangup_func_arg);
}
}
}
void PySession::setHangupHook(PyObject * pyfunc)
static switch_status_t python_hanguphook(switch_core_session_t *session_hungup)
{
switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
CoreSession *coresession = NULL;
switch_channel_state_t state = switch_channel_get_state(channel);
if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
if (coresession->hook_state != state) {
coresession->hook_state = state;
coresession->check_hangup_hook();
}
}
return SWITCH_STATUS_SUCCESS;
}
void Session::setHangupHook(PyObject *pyfunc, PyObject *arg)
{
if (!PyCallable_Check(pyfunc)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Hangup hook is not a python function.\n");
return;
}
// without this Py_XINCREF, there will be segfaults. basically the python
// interpreter will not know that it should not GC this object.
// callback example: http://docs.python.org/ext/callingPython.html
Py_XINCREF(pyfunc);
CoreSession::setHangupHook((void *) pyfunc);
if (hangup_func) {
if (session) {
switch_core_event_hook_remove_state_change(session, python_hanguphook);
}
Py_XDECREF(hangup_func);
hangup_func = NULL;
}
if (hangup_func_arg) {
Py_XDECREF(hangup_func_arg);
hangup_func_arg = NULL;
}
hangup_func = pyfunc;
hangup_func_arg = arg;
Py_XINCREF(hangup_func);
if (hangup_func_arg) {
Py_XINCREF(hangup_func_arg);
}
switch_channel_set_private(channel, "CoreSession", this);
hook_state = switch_channel_get_state(channel);
switch_core_event_hook_add_state_change(session, python_hanguphook);
}
void PySession::check_hangup_hook()
void Session::setInputCallback(PyObject *cbfunc, PyObject *funcargs)
{
#if 0
PyObject *func;
PyObject *result;
char *resultStr;
bool did_swap_in = false;
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"check_hangup_hook has been DISABLED, please do not use hangup hooks in python code until further notice!\n");
if (!session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
if (!PyCallable_Check(cbfunc)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Hangup hook is not a python function.\n");
return;
}
return;
if (cb_function) {
Py_XDECREF(cb_function);
cb_function = NULL;
}
/*! NEEDS TO BE FIXED:
if (cb_arg) {
Py_XDECREF(cb_arg);
cb_arg = NULL;
}
// The did_swap_in boolean was added to fix the following problem:
// Design flaw - we swap in threadstate based on the assumption that thread state
// is currently _swapped out_ when this hangup hook is called. However, nothing known to
// guarantee that, and if thread state is already swapped in when this is invoked,
// bad things will happen.
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "check hangup hook end_allow_threads\n");
did_swap_in = end_allow_threads();
cb_function = cbfunc;
cb_arg = funcargs;
args.buf = this;
switch_channel_set_private(channel, "CoreSession", this);
if (on_hangup == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "on_hangup is null\n");
return;
}
Py_XINCREF(cb_function);
func = (PyObject *) on_hangup;
if (cb_arg) {
Py_XINCREF(cb_arg);
}
// TODO: to match js implementation, should pass the _python_ PySession
// object instance wrapping this C++ PySession instance. but how do we do that?
// for now, pass the uuid since its better than nothing
PyObject* func_arg = Py_BuildValue("(s)", uuid);
args.input_callback = dtmf_callback;
ap = &args;
result = PyEval_CallObject(func, func_arg);
Py_XDECREF(func_arg);
if (result) {
resultStr = (char *) PyString_AsString(result);
// currently just ignore the result
}
else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to call python hangup callback\n");
PyErr_Print();
PyErr_Clear();
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "check hangup hook begin_allow_threads\n");
if (did_swap_in) {
begin_allow_threads();
}
Py_XDECREF(result);
*/
}
switch_status_t PySession::run_dtmf_callback(void *input, switch_input_type_t itype)
switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t itype)
{
PyObject *func, *arglist;
PyObject *pyresult;
PyObject *headerdict;
PyObject *pyresult, *arglist, *io = NULL;
int ts = 0;
char *str = NULL, *what = "";
char *resultStr;
char *funcargs;
bool did_swap_in = false;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "run_dtmf_callback\n");
if (!cb_state.function) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "cb_state->function is null\n");
return SWITCH_STATUS_FALSE;
if (TS) {
ts++;
end_allow_threads();
}
func = (PyObject *) cb_state.function;
if (!func) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "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)) {
if (!PyCallable_Check(cb_function)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
return SWITCH_STATUS_FALSE;
}
funcargs = (char *) cb_state.funcargs;
if (itype == SWITCH_INPUT_TYPE_DTMF) {
arglist = Py_BuildValue("(sis)", input, itype, funcargs);
} else if (itype == SWITCH_INPUT_TYPE_EVENT) {
// DUNNO if this is correct in the case we have an event
// will be of type switch_event_t *event;
// http://www.freeswitch.org/docs/structswitch__event.html
switch_event_t *event = (switch_event_t *) input;
arglist = Py_BuildValue("({s:s}is)", "body", event->body, itype, funcargs);
// build a dictionary with all the headers
switch_event_header_t *hp;
headerdict = PyDict_New();
for (hp = event->headers; hp; hp = hp->next) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding event header to result");
// TODO: create PyObject pointers for name and value
// and explicitly decref them. all ref counting stuff is
// a mess and needs to be tested and looked at closer.
PyDict_SetItem(headerdict, Py_BuildValue("s", hp->name), Py_BuildValue("s", hp->value));
}
// add it to the main event dictionary (first arg in list)
// under key 'headers'
PyObject *dict = PyTuple_GetItem(arglist, 0);
PyDict_SetItemString(dict, "headers", headerdict);
Py_XDECREF(headerdict);
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
io = mod_python_conjure_DTMF(dtmf->digit, dtmf->duration);
what = "dtmf";
} else if (itype == SWITCH_INPUT_TYPE_EVENT){
what = "event";
io = mod_python_conjure_event(NULL, (switch_event_t *) input, NULL);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown input type: %d\n", itype);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unsupported type!\n");
return SWITCH_STATUS_FALSE;
}
if (!arglist) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error building arglist");
return SWITCH_STATUS_FALSE;
if (!Self) {
mod_python_conjure_session(NULL, session, NULL);
}
if (cb_arg) {
arglist = Py_BuildValue("(OsOO)", Self, what, io, cb_arg);
} else {
arglist = Py_BuildValue("(OsO)", Self, what, io);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "run_dtmf_callback end_allow_threads\n");
did_swap_in = end_allow_threads();
pyresult = PyEval_CallObject(func, arglist);
Py_XDECREF(arglist); // Trash arglist
if (pyresult && pyresult != Py_None) {
resultStr = (char *) PyString_AsString(pyresult);
switch_status_t cbresult = process_callback_result(resultStr);
return cbresult;
if ((pyresult = PyEval_CallObject(cb_function, arglist))) {
str = (char *) PyString_AsString(pyresult);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Python callback\n returned None");
PyErr_Print();
PyErr_Clear();
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "run_dtmf_callback begin_allow_threads\n");
if (did_swap_in) {
Py_XDECREF(arglist);
Py_XDECREF(io);
if (cb_arg) {
Py_XDECREF(cb_arg);
}
if (ts) {
begin_allow_threads();
}
Py_XDECREF(pyresult);
return SWITCH_STATUS_SUCCESS;
}
bool PySession::begin_allow_threads(void)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::begin_allow_threads() called\n");
if (!session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
return false;
}
// swap out threadstate and store in instance variable
switch_channel_t *channel = switch_core_session_get_channel(session);
PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
// so lets assume the thread state was swapped in when the python script was started,
// therefore swapin_tstate will be NULL (because there is nothing to swap in, since its
// _already_ swapped in.)
if (swapin_tstate == NULL) {
// currently swapped in
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Threadstate swap-out!\n");
swapin_tstate = PyEval_SaveThread();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "swapin_tstate: %p\n", swapin_tstate);
// give future swapper-inners something to actually swap in
switch_channel_set_private(channel, "SwapInThreadState", (void *) swapin_tstate);
cb_state.threadState = threadState; // TODO: get rid of this
args.buf = &cb_state;
ap = &args;
return true;
} else {
// currently swapped out
return false;
}
}
bool 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
if (!session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
return false;
}
switch_channel_t *channel = switch_core_session_get_channel(session);
PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
if (swapin_tstate == NULL) {
// currently swapped in
return false;
} else {
// currently swapped out
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Threadstate swap-in!\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "swapin_tstate: %p\n", swapin_tstate);
PyEval_RestoreThread(swapin_tstate);
// dont give any swapper-inners the opportunity to do a double swap
switch_channel_set_private(channel, "SwapInThreadState", NULL);
return true;
}
}
void PySession::hangup(char *cause)
{
// since we INCREF'd this function pointer earlier (so the py gc didnt reclaim it)
// we have to DECREF it, or else the PySession dtor will never get called and
// a zombie channel will be left over using up resources
if (cb_state.function != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "xdecref on cb_state_function\n");
PyObject *func = (PyObject *) cb_state.function;
Py_XDECREF(func);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cb_state.function is null\n");
}
CoreSession::hangup(cause);
}
PySession::~PySession()
{
// Should we do any cleanup here?
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::~PySession started\n");
if (on_hangup) {
PyObject *func = (PyObject *) on_hangup;
Py_XDECREF(func);
}
if (cb_state.function != NULL) {
PyObject *func = (PyObject *) cb_state.function;
Py_XDECREF(func);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::~PySession finished\n");
if (str) {
return process_callback_result(str);
}
return SWITCH_STATUS_FALSE;
}

View File

@ -1,61 +1,45 @@
#ifndef FREESWITCH_PYTHON_H
#define FREESWITCH_PYTHON_H
#include <Python.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DOH
#include <Python.h>
#include "mod_python_extra.h"
}
#endif
#include <switch_cpp.h>
typedef enum {
S_SWAPPED_IN = (1 << 0),
S_SWAPPED_OUT = (1 << 1)
} swap_state_t;
void console_log(char *level_str, char *msg);
void console_clean_log(char *msg);
class PySession : public CoreSession {
namespace PYTHON {
class Session : public CoreSession {
private:
void *threadState;
int swapstate;
virtual void do_hangup_hook();
PyObject *getPython();
PyObject *Py;
PyObject *Self;
int hh;
int mark;
PyThreadState *TS;
public:
PySession();
PySession(char *uuid);
PySession(switch_core_session_t *session);
~PySession();
void setDTMFCallback(PyObject *pyfunc, char *funcargs);
void setHangupHook(PyObject *pyfunc);
void check_hangup_hook();
void hangup(char *cause);
bool begin_allow_threads();
bool end_allow_threads();
Session();
Session(char *uuid);
Session(switch_core_session_t *session);
virtual ~Session();
virtual bool begin_allow_threads();
virtual bool end_allow_threads();
virtual void check_hangup_hook();
/**
* Run DTMF callback
*
* A static method in CoreSession is the first thing called
* upon receving a dtmf/event callback from fs engine, and then
* it gets the PySession instance and calls this method with
* dtmf/event object.
*
* @param input - a dtmf char buffer, or an event 'object' (not sure..)
* @param itype - a SWITCH_INPUT_TYPE_DTMF or a SWITCH_INPUT_TYPE_EVENT
*/
switch_status_t run_dtmf_callback(void *input,
switch_input_type_t itype);
virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
void setInputCallback(PyObject *cbfunc, PyObject *funcargs = NULL);
void setHangupHook(PyObject *pyfunc, PyObject *arg = NULL);
bool ready();
PyObject *cb_function;
PyObject *cb_arg;
PyObject *hangup_func;
PyObject *hangup_func_arg;
void setPython(PyObject *state);
void setSelf(PyObject *state);
};
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,53 @@
--- mod_python_wrap.cpp 2008-07-10 13:14:21.000000000 -0500
+++ old.cpp 2008-07-10 13:13:57.000000000 -0500
@@ -8150,20 +8150,20 @@
}
-SWIGINTERN PyObject *_wrap_new_Session__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_Session__SWIG_0(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
PYTHON::Session *result = 0 ;
if (!PyArg_ParseTuple(args,(char *)":new_Session")) SWIG_fail;
result = (PYTHON::Session *)new PYTHON::Session();
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_NEW | 0 );
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_NEW | 0 ); result->setPython(self);
return resultobj;
fail:
return NULL;
}
-SWIGINTERN PyObject *_wrap_new_Session__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_Session__SWIG_1(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
PYTHON::Session *result = 0 ;
@@ -8179,7 +8179,7 @@
}
arg1 = reinterpret_cast< char * >(buf1);
result = (PYTHON::Session *)new PYTHON::Session(arg1);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_NEW | 0 );
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_NEW | 0 ); result->setPython(self);
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
return resultobj;
fail:
@@ -8188,7 +8188,7 @@
}
-SWIGINTERN PyObject *_wrap_new_Session__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_Session__SWIG_2(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
PYTHON::Session *result = 0 ;
@@ -8203,7 +8203,7 @@
}
arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
result = (PYTHON::Session *)new PYTHON::Session(arg1);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_NEW | 0 );
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_NEW | 0 ); result->setPython(self);
return resultobj;
fail:
return NULL;

View File

@ -42,7 +42,7 @@
#endif
#include <switch.h>
#include "mod_python_extra.h"
PyThreadState *mainThreadState = NULL;
@ -62,7 +62,7 @@ static void eval_some_python(char *uuid, char *args, switch_core_session_t *sess
int argc;
int lead = 0;
char *script = NULL;
PyObject *module = NULL;
PyObject *module = NULL, *sp = NULL;
PyObject *function = NULL;
PyObject *arg = NULL;
PyObject *result = NULL;
@ -139,6 +139,10 @@ static void eval_some_python(char *uuid, char *args, switch_core_session_t *sess
PyTuple_SetItem(arg, 0, nada);
}
if (session) {
sp = mod_python_conjure_session(module, session, "session");
}
// invoke the handler
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call python script \n");
result = PyEval_CallObjectWithKeywords(function, arg, (PyObject *) NULL);
@ -150,21 +154,26 @@ static void eval_some_python(char *uuid, char *args, switch_core_session_t *sess
PyErr_Print();
PyErr_Clear();
}
goto done_swap_out;
done:
switch_safe_free(dupargs);
if (sp) {
Py_XDECREF(sp);
}
done_swap_out:
// decrement ref counts
Py_XDECREF(module);
Py_XDECREF(function);
Py_XDECREF(arg);
Py_XDECREF(result);
// swap out thread state
if (session) {
//switch_core_session_rwunlock(session);
// record the fact that thread state is swapped in
switch_channel_t *channel = switch_core_session_get_channel(session);
PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
@ -189,7 +198,7 @@ static void eval_some_python(char *uuid, char *args, switch_core_session_t *sess
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No session: Threadstate mod_python.c swap-out! \n");
PyEval_ReleaseThread(tstate);
}
switch_safe_free(dupargs);

View File

@ -26,5 +26,3 @@
%include switch_swigable_cpp.h
%include freeswitch_python.h

View File

@ -0,0 +1,65 @@
SWITCH_BEGIN_EXTERN_C
PyObject *mod_python_conjure_event(PyObject *module, switch_event_t *event, const char *name)
{
PyObject *obj;
Event *result = new Event(event, 0);
obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN );
if (module && name) {
PyDict_SetItem(PyModule_GetDict(module), Py_BuildValue("s", name), obj);
Py_DECREF(obj);
}
return obj;
}
PyObject *mod_python_conjure_stream(PyObject *module, switch_stream_handle_t *stream, const char *name)
{
PyObject *obj;
Stream *result = new Stream(stream);
obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Stream, SWIG_POINTER_OWN );
if (module && name) {
PyDict_SetItem(PyModule_GetDict(module), Py_BuildValue("s", name), obj);
Py_DECREF(obj);
}
return obj;
}
PyObject *mod_python_conjure_session(PyObject *module, switch_core_session_t *session, const char *name)
{
PyObject *obj;
PYTHON::Session *result = new PYTHON::Session(session);
obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_OWN);
result->setPython(module);
result->setSelf(obj);
if (module && name) {
PyDict_SetItem(PyModule_GetDict(module), Py_BuildValue("s", name), obj);
Py_DECREF(obj);
}
return obj;
}
PyObject *mod_python_conjure_DTMF(char digit, int32_t duration)
{
PyObject *obj;
DTMF *result = new DTMF(digit, duration);
obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DTMF, SWIG_POINTER_OWN);
return obj;
}
SWITCH_END_EXTERN_C

View File

@ -0,0 +1,11 @@
#ifndef MOD_PYTHON_EXTRA
#define MOD_PYTHON_EXTRA
SWITCH_BEGIN_EXTERN_C
PyObject *mod_python_conjure_event(PyObject *module, switch_event_t *event, const char *name);
PyObject *mod_python_conjure_stream(PyObject *module, switch_stream_handle_t *stream, const char *name);
PyObject *mod_python_conjure_session(PyObject *module, switch_core_session_t *session, const char *name);
PyObject *mod_python_conjure_DTMF(char digit, int32_t duration);
SWITCH_END_EXTERN_C
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -367,6 +367,24 @@ SWITCH_DECLARE(const char *)Event::getType(void)
return (char *) "invalid";
}
SWITCH_DECLARE_CONSTRUCTOR DTMF::DTMF(char idigit, uint32_t iduration)
{
digit = idigit;
if (iduration == 0) {
iduration == SWITCH_DEFAULT_DTMF_DURATION;
}
duration = iduration;
}
SWITCH_DECLARE_CONSTRUCTOR DTMF::~DTMF()
{
}
SWITCH_DECLARE_CONSTRUCTOR Stream::Stream()
{
SWITCH_STANDARD_STREAM(mystream);
@ -457,8 +475,6 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession()
}
switch_core_session_rwunlock(session);
}
}
SWITCH_DECLARE(char *) CoreSession::getXMLCDR()
@ -602,11 +618,6 @@ SWITCH_DECLARE(int) CoreSession::speak(char *text)
this_check(-1);
sanity_check(-1);
// create and store an empty filehandle in callback args
// to workaround a bug in the presumptuous process_callback_result()
switch_file_handle_t fh = { 0 };
store_file_handle(&fh);
if (!tts_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine specified\n");
return SWITCH_STATUS_FALSE;
@ -793,13 +804,12 @@ SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_coun
}
}
store_file_handle(&local_fh);
begin_allow_threads();
status = switch_ivr_play_file(session, fhp, file, ap);
end_allow_threads();
fhp = NULL;
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
@ -895,18 +905,22 @@ SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *des
SWITCH_DECLARE(int) CoreSession::recordFile(char *file_name, int max_len, int silence_threshold, int silence_secs)
{
switch_file_handle_t fh = { 0 };
switch_status_t status;
this_check(-1);
sanity_check(-1);
fh.thresh = silence_threshold;
fh.silence_hits = silence_secs;
store_file_handle(&fh);
memset(&local_fh, 0, sizeof(local_fh));
fhp = &local_fh;
local_fh.thresh = silence_threshold;
local_fh.silence_hits = silence_secs;
begin_allow_threads();
status = switch_ivr_record_file(session, &fh, file_name, &args, max_len);
status = switch_ivr_record_file(session, &local_fh, file_name, &args, max_len);
end_allow_threads();
fhp = NULL;
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
@ -1012,22 +1026,6 @@ SWITCH_DECLARE(void) CoreSession::setHangupHook(void *hangup_func) {
switch_core_event_hook_add_state_change(session, hanguphook);
}
/** \brief Store a file handle in the callback args
*
* In a few of the methods like playFile and streamfile,
* an empty switch_file_handle_t is created and passed
* to core, and stored in callback args so that the callback
* handler can retrieve it for pausing, ff, rewinding file ptr.
*
* \param fh - a switch_file_handle_t
*/
void CoreSession::store_file_handle(switch_file_handle_t *fh) {
cb_state.extra = fh; // set a file handle so callback handler can pause
args.buf = &cb_state;
ap = &args;
}
/* ---- methods not bound to CoreSession instance ---- */
SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg)
@ -1137,13 +1135,6 @@ SWITCH_DECLARE(switch_status_t) CoreSession::process_callback_result(char *resul
if (fhp) {
fh = fhp;
} else {
if (!cb_state.extra) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because cb_state.extra is null\n");
return SWITCH_STATUS_FALSE;
}
fh = (switch_file_handle_t *) cb_state.extra;
}