]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
lang stuff
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 16 Jul 2008 20:19:11 +0000 (20:19 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 16 Jul 2008 20:19:11 +0000 (20:19 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9062 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_cpp.h
src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
src/mod/languages/mod_java/switch_swig_wrap.cpp
src/mod/languages/mod_lua/freeswitch_lua.cpp
src/mod/languages/mod_lua/mod_lua_wrap.cpp
src/mod/languages/mod_perl/freeswitch_perl.cpp
src/mod/languages/mod_perl/hack.diff
src/mod/languages/mod_perl/mod_perl_wrap.cpp
src/switch_cpp.cpp

index a87ad4ff2fef7bf4ef1a730d1dfa3b6bbca425ad..5e7d8b81941ca7fda78b887a0e928110b8b4c623 100644 (file)
@@ -346,7 +346,7 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
         * \return the uuid of this session
         */
                 char *get_uuid() const {
-                        return uuid;
+                        return uuid ? uuid : (char *) "uninitialized";
                 };
 
        /** \brief Get the callback function arguments associated with this session
index b4bb25cd86155260ce513b59c32dd28852521826..f30ff8008b6473cb473a2ccd5ca45b14ae811e97 100644 (file)
@@ -84,6 +84,30 @@ public class CoreSession {
     return new SWIGTYPE_p_switch_channel_state_t(freeswitchJNI.CoreSession_hook_state_get(swigCPtr, this), true);
   }
 
+  public void setUuid(String value) {
+    freeswitchJNI.CoreSession_uuid_set(swigCPtr, this, value);
+  }
+
+  public String getUuid() {
+    return freeswitchJNI.CoreSession_uuid_get(swigCPtr, this);
+  }
+
+  public void setTts_name(String value) {
+    freeswitchJNI.CoreSession_tts_name_set(swigCPtr, this, value);
+  }
+
+  public String getTts_name() {
+    return freeswitchJNI.CoreSession_tts_name_get(swigCPtr, this);
+  }
+
+  public void setVoice_name(String value) {
+    freeswitchJNI.CoreSession_voice_name_set(swigCPtr, this, value);
+  }
+
+  public String getVoice_name() {
+    return freeswitchJNI.CoreSession_voice_name_get(swigCPtr, this);
+  }
+
   public int answer() {
     return freeswitchJNI.CoreSession_answer(swigCPtr, this);
   }
index 138195c9e4fbd5747825d703d3d55e43e7ef3e7e..d34efb518ad8ac3654dde607e0720e9b6903ae76 100644 (file)
@@ -96,6 +96,12 @@ class freeswitchJNI {
   public final static native long CoreSession_cb_state_get(long jarg1, CoreSession jarg1_);
   public final static native void CoreSession_hook_state_set(long jarg1, CoreSession jarg1_, long jarg2);
   public final static native long CoreSession_hook_state_get(long jarg1, CoreSession jarg1_);
+  public final static native void CoreSession_uuid_set(long jarg1, CoreSession jarg1_, String jarg2);
+  public final static native String CoreSession_uuid_get(long jarg1, CoreSession jarg1_);
+  public final static native void CoreSession_tts_name_set(long jarg1, CoreSession jarg1_, String jarg2);
+  public final static native String CoreSession_tts_name_get(long jarg1, CoreSession jarg1_);
+  public final static native void CoreSession_voice_name_set(long jarg1, CoreSession jarg1_, String jarg2);
+  public final static native String CoreSession_voice_name_get(long jarg1, CoreSession jarg1_);
   public final static native int CoreSession_answer(long jarg1, CoreSession jarg1_);
   public final static native int CoreSession_preAnswer(long jarg1, CoreSession jarg1_);
   public final static native void CoreSession_hangup__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2);
index 8fb22e2bb3c63c8b87d938a13adc452516ca84bf..c3933dd9fdbbd2570f1416cd7cbc42857041345c 100644 (file)
@@ -1720,6 +1720,129 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1hoo
 }
 
 
+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1uuid_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return ;
+  }
+  {
+    if (arg1->uuid) delete [] arg1->uuid;
+    if (arg2) {
+      arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->uuid, (const char *)arg2);
+    } else {
+      arg1->uuid = 0;
+    }
+  }
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1uuid_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jstring jresult = 0 ;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  result = (char *) ((arg1)->uuid);
+  if(result) jresult = jenv->NewStringUTF((const char *)result);
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1tts_1name_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return ;
+  }
+  {
+    if (arg1->tts_name) delete [] arg1->tts_name;
+    if (arg2) {
+      arg1->tts_name = (char *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->tts_name, (const char *)arg2);
+    } else {
+      arg1->tts_name = 0;
+    }
+  }
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1tts_1name_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jstring jresult = 0 ;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  result = (char *) ((arg1)->tts_name);
+  if(result) jresult = jenv->NewStringUTF((const char *)result);
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1voice_1name_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return ;
+  }
+  {
+    if (arg1->voice_name) delete [] arg1->voice_name;
+    if (arg2) {
+      arg1->voice_name = (char *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->voice_name, (const char *)arg2);
+    } else {
+      arg1->voice_name = 0;
+    }
+  }
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1voice_1name_1get(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  jstring jresult = 0 ;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  result = (char *) ((arg1)->voice_name);
+  if(result) jresult = jenv->NewStringUTF((const char *)result);
+  return jresult;
+}
+
+
 SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1answer(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
   jint jresult = 0 ;
   CoreSession *arg1 = (CoreSession *) 0 ;
index 6a45242947a0e8b3b4dba570c030bcc1e3693458..b85a874ecaa5054030725813b2e2aee31907227a 100644 (file)
@@ -50,13 +50,12 @@ bool Session::end_allow_threads()
 
 void Session::setLUA(lua_State * state)
 {
-       if (uuid) {
-               L = state;
-               lua_setglobal(L, uuid);
-               lua_getfield(L, LUA_GLOBALSINDEX, uuid);
-       } else {
-               //did we fail to make a session?
-       }
+       sanity_check_noreturn;
+
+       L = state;
+       lua_setglobal(L, uuid);
+       lua_getfield(L, LUA_GLOBALSINDEX, uuid ? uuid : "");
+
 }
 
 lua_State *Session::getLUA()
index e4c2b7900230cf909351c32a0ce2471e2ff3ab78..8f9e2823567851bfe6102e0b28372a6486bf26fe 100644 (file)
@@ -4292,6 +4292,186 @@ fail:
 }
 
 
+static int _wrap_CoreSession_uuid_set(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("uuid",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("uuid",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("uuid",2,"char *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_uuid_set",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  {
+    if (arg1->uuid) delete [] arg1->uuid;
+    if (arg2) {
+      arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->uuid, (const char *)arg2);
+    } else {
+      arg1->uuid = 0;
+    }
+  }
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_uuid_get(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("uuid",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("uuid",1,"CoreSession *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_uuid_get",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  result = (char *) ((arg1)->uuid);
+  SWIG_arg=0;
+  lua_pushstring(L,(const char*)result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_tts_name_set(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("tts_name",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("tts_name",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("tts_name",2,"char *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_tts_name_set",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  {
+    if (arg1->tts_name) delete [] arg1->tts_name;
+    if (arg2) {
+      arg1->tts_name = (char *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->tts_name, (const char *)arg2);
+    } else {
+      arg1->tts_name = 0;
+    }
+  }
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_tts_name_get(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("tts_name",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("tts_name",1,"CoreSession *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_tts_name_get",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  result = (char *) ((arg1)->tts_name);
+  SWIG_arg=0;
+  lua_pushstring(L,(const char*)result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_voice_name_set(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("voice_name",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("voice_name",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("voice_name",2,"char *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_voice_name_set",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  {
+    if (arg1->voice_name) delete [] arg1->voice_name;
+    if (arg2) {
+      arg1->voice_name = (char *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->voice_name, (const char *)arg2);
+    } else {
+      arg1->voice_name = 0;
+    }
+  }
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_voice_name_get(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("voice_name",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("voice_name",1,"CoreSession *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_voice_name_get",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  result = (char *) ((arg1)->voice_name);
+  SWIG_arg=0;
+  lua_pushstring(L,(const char*)result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
 static int _wrap_CoreSession_answer(lua_State* L) {
   int SWIG_arg = -1;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -6387,6 +6567,9 @@ static swig_lua_attribute swig_CoreSession_attributes[] = {
     { "allocated", _wrap_CoreSession_allocated_get, _wrap_CoreSession_allocated_set},
     { "cb_state", _wrap_CoreSession_cb_state_get, _wrap_CoreSession_cb_state_set},
     { "hook_state", _wrap_CoreSession_hook_state_get, _wrap_CoreSession_hook_state_set},
+    { "uuid", _wrap_CoreSession_uuid_get, _wrap_CoreSession_uuid_set},
+    { "tts_name", _wrap_CoreSession_tts_name_get, _wrap_CoreSession_tts_name_set},
+    { "voice_name", _wrap_CoreSession_voice_name_get, _wrap_CoreSession_voice_name_set},
     {0,0,0}
 };
 static swig_lua_class *swig_CoreSession_bases[] = {0};
index 03453bab505265c8d2002ff3966186d6f6c58b5d..373a0b387381117759e0b5b0a182a9ce831a3ddb 100644 (file)
@@ -16,7 +16,7 @@ Session::Session():CoreSession()
 Session::Session(char *uuid):CoreSession(uuid)
 {
        init_me();
-       if (session) {
+       if (session && allocated) {
                suuid = switch_core_session_sprintf(session, "main::uuid_%s\n", switch_core_session_get_uuid(session));
                for (char *p = suuid; p && *p; p++) {
                        if (*p == '-') {
@@ -26,8 +26,6 @@ Session::Session(char *uuid):CoreSession(uuid)
                                *p = '\0';
                        }
                }
-       } else {
-               //handle failure
        }
 }
 
@@ -74,11 +72,14 @@ bool Session::end_allow_threads()
 
 void Session::setPERL(PerlInterpreter * pi)
 {
+       sanity_check_noreturn;
        my_perl = pi;
 }
 
 void Session::setME(SV *p)
 {
+       sanity_check_noreturn;
+
        me = p;
 }
 
index b9e305cc45291e6ea6d5450d5721135fdbc674d5..e3f7bb1dc46abe41e95b8a067ffc0b8151ef6c27 100644 (file)
@@ -1,6 +1,6 @@
---- mod_perl_wrap.cpp  2008-07-14 15:52:35.000000000 -0400
-+++ old.cpp    2008-07-14 15:52:01.000000000 -0400
-@@ -8852,13 +8852,17 @@
+--- mod_perl_wrap.cpp  2008-07-16 13:38:11.000000000 -0500
++++ old.cpp    2008-07-16 13:37:44.000000000 -0500
+@@ -8852,13 +8852,18 @@
    {
      PERL::Session *result = 0 ;
      int argvi = 0;
 -    result = (PERL::Session *)new PERL::Session();
 -    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
 +    result = (PERL::Session *)new PERL::Session(); 
-+      foo = get_sv("foo", TRUE);
++      result->setPERL(my_perl);
++      foo = sv_newmortal();
 +      SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW);
 +      result->setME(foo);     
 +      ST(argvi) = foo; argvi++ ;
      XSRETURN(argvi);
    fail:
      SWIG_croak_null();
-@@ -8874,6 +8878,7 @@
+@@ -8874,6 +8879,7 @@
      char *buf1 = 0 ;
      int alloc1 = 0 ;
      int argvi = 0;
      dXSARGS;
      
      if ((items < 1) || (items > 1)) {
-@@ -8884,9 +8889,13 @@
+@@ -8884,9 +8890,19 @@
        SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'");
      }
      arg1 = reinterpret_cast< char * >(buf1);
 -    result = (PERL::Session *)new PERL::Session(arg1);
 -    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
-+    result = (PERL::Session *)new PERL::Session(arg1); 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);     
++    result = (PERL::Session *)new PERL::Session(arg1); 
++      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;
-@@ -8902,6 +8911,7 @@
+@@ -8902,6 +8918,7 @@
      void *argp1 = 0 ;
      int res1 = 0 ;
      int argvi = 0;
      dXSARGS;
      
      if ((items < 1) || (items > 1)) {
-@@ -8913,8 +8923,11 @@
+@@ -8913,8 +8930,18 @@
      }
      arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
      result = (PERL::Session *)new PERL::Session(arg1);
 -    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
 -    
-+      foo = get_sv(result->suuid, TRUE);
-+      SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW);
-+      result->setME(foo);     
++      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++ ;
 +      
      XSRETURN(argvi);
index ab499b49c657dede758f5bc81dc692c33040ccf5..72a73c6507ee737638635ae784e9aedceb318752 100644 (file)
@@ -8859,7 +8859,8 @@ XS(_wrap_new_Session__SWIG_0) {
       SWIG_croak("Usage: new_Session();");
     }
     result = (PERL::Session *)new PERL::Session(); 
-       foo = get_sv("foo", TRUE);
+       result->setPERL(my_perl);
+       foo = sv_newmortal();
        SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW);
        result->setME(foo);     
        ST(argvi) = foo; argvi++ ;
@@ -8889,10 +8890,16 @@ XS(_wrap_new_Session__SWIG_1) {
       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'");
     }
     arg1 = reinterpret_cast< char * >(buf1);
-    result = (PERL::Session *)new PERL::Session(arg1); 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);     
+    result = (PERL::Session *)new PERL::Session(arg1); 
+       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;
 
@@ -8923,9 +8930,16 @@ XS(_wrap_new_Session__SWIG_2) {
     }
     arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
     result = (PERL::Session *)new PERL::Session(arg1);
-       foo = get_sv(result->suuid, TRUE);
-       SWIG_MakePtr(foo, SWIG_as_voidptr(result), SWIGTYPE_p_PERL__Session, SWIG_OWNER | SWIG_SHADOW);
-       result->setME(foo);     
+       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++ ;
        
     XSRETURN(argvi);
index a91306fe277ff26e44048d26ff19ea0931c45b74..b9694c155e5fe7821a3a3c62225b57aaa37f16a6 100644 (file)
@@ -1061,12 +1061,35 @@ SWITCH_DECLARE(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;
+       switch_channel_t *channel_a = NULL, *channel_b = NULL;
+       const char *err = "Channels not ready\n";
+       
+       if (session_a.allocated && session_a.session && session_b.allocated && session_b.session) {
+               channel_a = switch_core_session_get_channel(session_a.session);
+               channel_b = switch_core_session_get_channel(session_b.session);
+
+               if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
+                       session_a.begin_allow_threads();
+                       if (!switch_channel_test_flag(channel_a, CF_ANSWERED)) {
+                               switch_channel_answer(channel_a);
+                       }
+                       if (!switch_channel_test_flag(channel_b, CF_ANSWERED)) {
+                               switch_channel_answer(channel_b);
+                       }
+                       if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
+                               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
+                               err = NULL;
+                               switch_ivr_multi_threaded_bridge(session_a.session, session_b.session, dtmf_func, args.buf, args.buf);
+                               session_a.end_allow_threads();
+                       }
+               }
+       }
+
+       if (err) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s", err);
+       }
 
-       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();
 
 }