diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 5e7d8b8194..ed2aa2f72c 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -199,7 +199,7 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg); public: SWITCH_DECLARE_CONSTRUCTOR CoreSession(); - SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *uuid); + SWITCH_DECLARE_CONSTRUCTOR CoreSession(char *nuuid, CoreSession *a_leg = NULL); SWITCH_DECLARE_CONSTRUCTOR CoreSession(switch_core_session_t *new_session); virtual SWITCH_DECLARE_CONSTRUCTOR ~ CoreSession(); switch_core_session_t *session; diff --git a/src/mod/languages/mod_lua/Makefile b/src/mod/languages/mod_lua/Makefile index 5e481099f7..b086108b6d 100644 --- a/src/mod/languages/mod_lua/Makefile +++ b/src/mod/languages/mod_lua/Makefile @@ -13,6 +13,8 @@ local_depend: $(LOCAL_OBJS) $(LIBLUA_A): cd lua && $(MAKE) CC="$(CC)" CFLAGS="$(ALL_CFLAGS) -DLUA_USE_LINUX -w" liblua.a +reswig: swigclean mod_lua_wrap.cpp + luaclean: cd lua && $(MAKE) clean diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index b85a874eca..e33e1eaecf 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -9,7 +9,7 @@ Session::Session():CoreSession() hh = mark = 0; } -Session::Session(char *uuid):CoreSession(uuid) +Session::Session(char *nuuid, CoreSession *a_leg):CoreSession(nuuid, a_leg) { cb_function = cb_arg = hangup_func_str = hangup_func_arg = NULL; hh = mark = 0; diff --git a/src/mod/languages/mod_lua/freeswitch_lua.h b/src/mod/languages/mod_lua/freeswitch_lua.h index c61194e4d3..0b9b6dbbcd 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.h +++ b/src/mod/languages/mod_lua/freeswitch_lua.h @@ -20,7 +20,7 @@ class Session : public CoreSession { int mark; public: Session(); - Session(char *uuid); + Session(char *uuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); ~Session(); diff --git a/src/mod/languages/mod_lua/hack.diff b/src/mod/languages/mod_lua/hack.diff index 8bf3b107fa..afd37b086d 100644 --- a/src/mod/languages/mod_lua/hack.diff +++ b/src/mod/languages/mod_lua/hack.diff @@ -1,6 +1,6 @@ ---- mod_lua_wrap.cpp 2008-05-11 20:03:58.000000000 -0400 -+++ mod_lua_wrap2.cpp 2008-05-11 20:05:08.000000000 -0400 -@@ -5158,7 +5158,7 @@ +--- mod_lua_wrap.cpp 2008-07-16 16:58:58.000000000 -0400 ++++ old.cpp 2008-07-16 16:58:42.000000000 -0400 +@@ -6731,7 +6731,7 @@ SWIG_check_num_args("LUA::Session",0,0) result = (LUA::Session *)new LUA::Session(); SWIG_arg=0; @@ -9,7 +9,16 @@ return SWIG_arg; if(0) SWIG_fail; -@@ -5179,7 +5179,7 @@ +@@ -6759,7 +6759,7 @@ + + result = (LUA::Session *)new LUA::Session(arg1,arg2); + SWIG_arg=0; +- SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; ++ SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L); + return SWIG_arg; + + if(0) SWIG_fail; +@@ -6780,7 +6780,7 @@ arg1 = (char *)lua_tostring(L, 1); result = (LUA::Session *)new LUA::Session(arg1); SWIG_arg=0; @@ -18,7 +27,7 @@ return SWIG_arg; if(0) SWIG_fail; -@@ -5204,7 +5204,7 @@ +@@ -6805,7 +6805,7 @@ result = (LUA::Session *)new LUA::Session(arg1); SWIG_arg=0; diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index 8f9e282356..b8430e5db8 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -6743,6 +6743,34 @@ fail: static int _wrap_new_Session__SWIG_1(lua_State* L) { + int SWIG_arg = -1; + char *arg1 = (char *) 0 ; + CoreSession *arg2 = (CoreSession *) 0 ; + LUA::Session *result = 0 ; + + SWIG_check_num_args("LUA::Session",2,2) + if(!lua_isstring(L,1)) SWIG_fail_arg("LUA::Session",1,"char *"); + if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("LUA::Session",2,"CoreSession *"); + arg1 = (char *)lua_tostring(L, 1); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){ + SWIG_fail_ptr("new_Session",2,SWIGTYPE_p_CoreSession); + } + + result = (LUA::Session *)new LUA::Session(arg1,arg2); + SWIG_arg=0; + SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L); + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_new_Session__SWIG_2(lua_State* L) { int SWIG_arg = -1; char *arg1 = (char *) 0 ; LUA::Session *result = 0 ; @@ -6763,7 +6791,7 @@ fail: } -static int _wrap_new_Session__SWIG_2(lua_State* L) { +static int _wrap_new_Session__SWIG_3(lua_State* L) { int SWIG_arg = -1; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; LUA::Session *result = 0 ; @@ -6790,8 +6818,8 @@ fail: static int _wrap_new_Session(lua_State* L) { int argc; - int argv[2]={ - 1,2 + int argv[3]={ + 1,2,3 }; argc = lua_gettop(L); @@ -6809,7 +6837,7 @@ static int _wrap_new_Session(lua_State* L) { } } if (_v) { - return _wrap_new_Session__SWIG_2(L); + return _wrap_new_Session__SWIG_3(L); } } if (argc == 1) { @@ -6818,7 +6846,26 @@ static int _wrap_new_Session(lua_State* L) { _v = lua_isstring(L,argv[0]); } if (_v) { - return _wrap_new_Session__SWIG_1(L); + return _wrap_new_Session__SWIG_2(L); + } + } + if (argc == 2) { + int _v; + { + _v = lua_isstring(L,argv[0]); + } + if (_v) { + { + void *ptr; + if (SWIG_isptrtype(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) { + _v = 0; + } else { + _v = 1; + } + } + if (_v) { + return _wrap_new_Session__SWIG_1(L); + } } } diff --git a/src/mod/languages/mod_perl/Makefile b/src/mod/languages/mod_perl/Makefile index 75542e2bae..145951576f 100644 --- a/src/mod/languages/mod_perl/Makefile +++ b/src/mod/languages/mod_perl/Makefile @@ -20,7 +20,8 @@ mod_perl_wrap.cpp: echo "#include \"mod_perl_extra.c\"" >> mod_perl_wrap.cpp patch -s -p0 -i hack.diff - +orig: mod_perl_wrap.cpp + patch -R -s -p0 -i hack.diff freeswitch.$(DYNAMIC_LIB_EXTEN): $(LOCAL_OBJS) $(LOCAL_LIBADD) $(LINK) $(SOLINK) -o freeswitch.$(DYNAMIC_LIB_EXTEN) $(LOCAL_OBJS) $(LOCAL_LIBADD) $(LDFLAGS) diff --git a/src/mod/languages/mod_perl/freeswitch_perl.cpp b/src/mod/languages/mod_perl/freeswitch_perl.cpp index 373a0b3873..795aa2bec2 100644 --- a/src/mod/languages/mod_perl/freeswitch_perl.cpp +++ b/src/mod/languages/mod_perl/freeswitch_perl.cpp @@ -13,7 +13,7 @@ Session::Session():CoreSession() init_me(); } -Session::Session(char *uuid):CoreSession(uuid) +Session::Session(char *uuid, CoreSession *a_leg):CoreSession(uuid, a_leg) { init_me(); if (session && allocated) { diff --git a/src/mod/languages/mod_perl/freeswitch_perl.h b/src/mod/languages/mod_perl/freeswitch_perl.h index deef2ecf6f..ccbec939ac 100644 --- a/src/mod/languages/mod_perl/freeswitch_perl.h +++ b/src/mod/languages/mod_perl/freeswitch_perl.h @@ -28,7 +28,7 @@ class Session : public CoreSession { SV *me; public: Session(); - Session(char *uuid); + Session(char *uuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); ~Session(); diff --git a/src/mod/languages/mod_perl/hack.diff b/src/mod/languages/mod_perl/hack.diff index e3f7bb1dc4..91aa2ddf83 100644 --- a/src/mod/languages/mod_perl/hack.diff +++ b/src/mod/languages/mod_perl/hack.diff @@ -1,5 +1,5 @@ ---- mod_perl_wrap.cpp 2008-07-16 13:38:11.000000000 -0500 -+++ old.cpp 2008-07-16 13:37:44.000000000 -0500 +--- mod_perl_wrap.cpp 2008-07-16 16:55:53.000000000 -0400 ++++ old.cpp 2008-07-16 16:55:38.000000000 -0400 @@ -8852,13 +8852,18 @@ { PERL::Session *result = 0 ; @@ -22,7 +22,33 @@ XSRETURN(argvi); fail: SWIG_croak_null(); -@@ -8874,6 +8879,7 @@ +@@ -8877,6 +8882,7 @@ + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; ++ SV *foo; + dXSARGS; + + if ((items < 2) || (items > 2)) { +@@ -8893,7 +8899,16 @@ + } + arg2 = reinterpret_cast< CoreSession * >(argp2); + result = (PERL::Session *)new PERL::Session(arg1,arg2); +- ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ; ++ if (result->allocated) { ++ result->setPERL(my_perl); ++ foo = get_sv(result->suuid, TRUE); ++ SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); ++ result->setME(foo); ++ } else { ++ foo = sv_newmortal(); ++ SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); ++ } ++ ST(argvi) = foo; argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); +@@ -8913,6 +8928,7 @@ char *buf1 = 0 ; int alloc1 = 0 ; int argvi = 0; @@ -30,7 +56,7 @@ dXSARGS; if ((items < 1) || (items > 1)) { -@@ -8884,9 +8890,19 @@ +@@ -8923,9 +8939,19 @@ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'"); } arg1 = reinterpret_cast< char * >(buf1); @@ -52,7 +78,7 @@ XSRETURN(argvi); fail: if (alloc1 == SWIG_NEWOBJ) delete[] buf1; -@@ -8902,6 +8918,7 @@ +@@ -8941,6 +8967,7 @@ void *argp1 = 0 ; int res1 = 0 ; int argvi = 0; @@ -60,7 +86,7 @@ dXSARGS; if ((items < 1) || (items > 1)) { -@@ -8913,8 +8930,18 @@ +@@ -8952,8 +8979,18 @@ } arg1 = reinterpret_cast< switch_core_session_t * >(argp1); result = (PERL::Session *)new PERL::Session(arg1); diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index 72a73c6507..0cecf37103 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -8872,6 +8872,55 @@ XS(_wrap_new_Session__SWIG_0) { XS(_wrap_new_Session__SWIG_1) { + { + char *arg1 = (char *) 0 ; + CoreSession *arg2 = (CoreSession *) 0 ; + PERL::Session *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + SV *foo; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: new_Session(uuid,a_leg);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_CoreSession, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Session" "', argument " "2"" of type '" "CoreSession *""'"); + } + arg2 = reinterpret_cast< CoreSession * >(argp2); + result = (PERL::Session *)new PERL::Session(arg1,arg2); + if (result->allocated) { + result->setPERL(my_perl); + foo = get_sv(result->suuid, TRUE); + SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); + result->setME(foo); + } else { + foo = sv_newmortal(); + SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); + } + ST(argvi) = foo; argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_Session__SWIG_2) { { char *arg1 = (char *) 0 ; PERL::Session *result = 0 ; @@ -8911,7 +8960,7 @@ XS(_wrap_new_Session__SWIG_1) { } -XS(_wrap_new_Session__SWIG_2) { +XS(_wrap_new_Session__SWIG_3) { { switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; PERL::Session *result = 0 ; @@ -9005,13 +9054,44 @@ XS(_wrap_new_Session) { } check_3: + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(1), &vptr, SWIGTYPE_p_CoreSession, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_4; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 4; + if (_rank == _rankm) goto dispatch; + } + } + check_4: + dispatch: switch(_index) { case 1: ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Session__SWIG_0); return; case 2: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Session__SWIG_2); return; + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Session__SWIG_3); return; case 3: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Session__SWIG_2); return; + case 4: ++PL_markstack_ptr; SWIG_CALLXS(_wrap_new_Session__SWIG_1); return; } } diff --git a/src/mod/languages/mod_python/freeswitch_python.cpp b/src/mod/languages/mod_python/freeswitch_python.cpp index 6b9685eeea..df2eb4bfbc 100644 --- a/src/mod/languages/mod_python/freeswitch_python.cpp +++ b/src/mod/languages/mod_python/freeswitch_python.cpp @@ -10,7 +10,7 @@ Session::Session():CoreSession() py_init_vars(); } -Session::Session(char *uuid):CoreSession(uuid) +Session::Session(char *nuuid, CoreSession *a_leg):CoreSession(nuuid, a_leg) { py_init_vars(); } @@ -59,6 +59,9 @@ bool Session::begin_allow_threads() if (!TS) { TS = PyEval_SaveThread(); + if (channel) { + switch_channel_set_private(channel, "SwapInThreadState", TS); + } return true; } @@ -75,6 +78,10 @@ bool Session::end_allow_threads() PyEval_RestoreThread(TS); TS = NULL; + if (channel) { + switch_channel_set_private(channel, "SwapInThreadState", NULL); + } + do_hangup_hook(); return true; diff --git a/src/mod/languages/mod_python/freeswitch_python.h b/src/mod/languages/mod_python/freeswitch_python.h index cb5563e963..8d61407de6 100644 --- a/src/mod/languages/mod_python/freeswitch_python.h +++ b/src/mod/languages/mod_python/freeswitch_python.h @@ -20,7 +20,7 @@ class Session : public CoreSession { PyThreadState *TS; public: Session(); - Session(char *uuid); + Session(char *nuuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); virtual ~Session(); diff --git a/src/mod/languages/mod_python/hack.diff b/src/mod/languages/mod_python/hack.diff index 777f34e435..712171035c 100644 --- a/src/mod/languages/mod_python/hack.diff +++ b/src/mod/languages/mod_python/hack.diff @@ -1,6 +1,6 @@ ---- 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 @@ +--- mod_python_wrap.cpp 2008-07-16 17:05:18.000000000 -0400 ++++ old.cpp 2008-07-16 17:05:07.000000000 -0400 +@@ -8621,20 +8621,20 @@ } @@ -21,10 +21,28 @@ -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 ; + CoreSession *arg2 = (CoreSession *) 0 ; +@@ -8659,7 +8659,7 @@ + } + arg2 = reinterpret_cast< CoreSession * >(argp2); + result = (PYTHON::Session *)new PYTHON::Session(arg1,arg2); +- 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: +@@ -8668,7 +8668,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; char *arg1 = (char *) 0 ; PYTHON::Session *result = 0 ; -@@ -8179,7 +8179,7 @@ +@@ -8684,7 +8684,7 @@ } arg1 = reinterpret_cast< char * >(buf1); result = (PYTHON::Session *)new PYTHON::Session(arg1); @@ -33,16 +51,16 @@ if (alloc1 == SWIG_NEWOBJ) delete[] buf1; return resultobj; fail: -@@ -8188,7 +8188,7 @@ +@@ -8693,7 +8693,7 @@ } --SWIGINTERN PyObject *_wrap_new_Session__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { -+SWIGINTERN PyObject *_wrap_new_Session__SWIG_2(PyObject *self, PyObject *args) { +-SWIGINTERN PyObject *_wrap_new_Session__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { ++SWIGINTERN PyObject *_wrap_new_Session__SWIG_3(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 @@ +@@ -8708,7 +8708,7 @@ } arg1 = reinterpret_cast< switch_core_session_t * >(argp1); result = (PYTHON::Session *)new PYTHON::Session(arg1); diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index f8555dcc30..9b58a3b66a 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -8635,6 +8635,40 @@ fail: SWIGINTERN PyObject *_wrap_new_Session__SWIG_1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + CoreSession *arg2 = (CoreSession *) 0 ; + PYTHON::Session *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_Session",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_CoreSession, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Session" "', argument " "2"" of type '" "CoreSession *""'"); + } + arg2 = reinterpret_cast< CoreSession * >(argp2); + result = (PYTHON::Session *)new PYTHON::Session(arg1,arg2); + 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: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Session__SWIG_2(PyObject *self, PyObject *args) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; PYTHON::Session *result = 0 ; @@ -8659,7 +8693,7 @@ fail: } -SWIGINTERN PyObject *_wrap_new_Session__SWIG_2(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_new_Session__SWIG_3(PyObject *self, PyObject *args) { PyObject *resultobj = 0; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; PYTHON::Session *result = 0 ; @@ -8683,12 +8717,12 @@ fail: SWIGINTERN PyObject *_wrap_new_Session(PyObject *self, PyObject *args) { int argc; - PyObject *argv[2]; + PyObject *argv[3]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = (int)PyObject_Length(args); - for (ii = 0; (ii < argc) && (ii < 1); ii++) { + for (ii = 0; (ii < argc) && (ii < 2); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } if (argc == 0) { @@ -8700,7 +8734,7 @@ SWIGINTERN PyObject *_wrap_new_Session(PyObject *self, PyObject *args) { int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_switch_core_session_t, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_Session__SWIG_2(self, args); + return _wrap_new_Session__SWIG_3(self, args); } } if (argc == 1) { @@ -8708,7 +8742,20 @@ SWIGINTERN PyObject *_wrap_new_Session(PyObject *self, PyObject *args) { int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_Session__SWIG_1(self, args); + return _wrap_new_Session__SWIG_2(self, args); + } + } + if (argc == 2) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_CoreSession, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Session__SWIG_1(self, args); + } } } @@ -8716,6 +8763,7 @@ fail: SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_Session'.\n" " Possible C/C++ prototypes are:\n" " PYTHON::Session()\n" + " PYTHON::Session(char *,CoreSession *)\n" " PYTHON::Session(char *)\n" " PYTHON::Session(switch_core_session_t *)\n"); return NULL; diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index b9694c155e..3a0a4e31d0 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -425,7 +425,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession() init_vars(); } -SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid) +SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid, CoreSession *a_leg) { init_vars(); @@ -435,7 +435,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid) allocated = 1; } else { switch_call_cause_t cause; - if (switch_ivr_originate(NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) { + if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) { channel = switch_core_session_get_channel(session); allocated = 1; switch_set_flag(this, S_HUP); @@ -1081,8 +1081,8 @@ SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b) dtmf_func = args.input_callback; // get the call back function err = NULL; switch_ivr_multi_threaded_bridge(session_a.session, session_b.session, dtmf_func, args.buf, args.buf); - session_a.end_allow_threads(); } + session_a.end_allow_threads(); } }