[Freeswitch-svn] [commit] r9062 - in freeswitch/trunk/src: . include mod/languages/mod_java mod/languages/mod_java/src/org/freeswitch/swig mod/languages/mod_lua mod/languages/mod_perl

Freeswitch SVN anthm at freeswitch.org
Wed Jul 16 16:19:11 EDT 2008


Author: anthm
Date: Wed Jul 16 16:19:11 2008
New Revision: 9062

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

Log:
lang stuff

Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h	(original)
+++ freeswitch/trunk/src/include/switch_cpp.h	Wed Jul 16 16:19:11 2008
@@ -346,7 +346,7 @@
 	 * \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

Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java	(original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java	Wed Jul 16 16:19:11 2008
@@ -84,6 +84,30 @@
     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);
   }

Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java	(original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java	Wed Jul 16 16:19:11 2008
@@ -96,6 +96,12 @@
   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);

Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp	Wed Jul 16 16:19:11 2008
@@ -1720,6 +1720,129 @@
 }
 
 
+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 ;

Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp	Wed Jul 16 16:19:11 2008
@@ -50,13 +50,12 @@
 
 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()

Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	Wed Jul 16 16:19:11 2008
@@ -4292,6 +4292,186 @@
 }
 
 
+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 @@
     { "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};

Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp	Wed Jul 16 16:19:11 2008
@@ -16,7 +16,7 @@
 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 @@
 				*p = '\0';
 			}
 		}
-	} else {
-		//handle failure
 	}
 }
 
@@ -74,11 +72,14 @@
 
 void Session::setPERL(PerlInterpreter * pi)
 {
+	sanity_check_noreturn;
 	my_perl = pi;
 }
 
 void Session::setME(SV *p)
 {
+	sanity_check_noreturn;
+
 	me = p;
 }
 

Modified: freeswitch/trunk/src/mod/languages/mod_perl/hack.diff
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/hack.diff	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/hack.diff	Wed Jul 16 16:19:11 2008
@@ -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;
@@ -14,14 +14,15 @@
 -    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;
@@ -29,23 +30,29 @@
      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;
@@ -53,15 +60,22 @@
      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);

Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp	Wed Jul 16 16:19:11 2008
@@ -8859,7 +8859,8 @@
       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 @@
       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 @@
     }
     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);

Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp	(original)
+++ freeswitch/trunk/src/switch_cpp.cpp	Wed Jul 16 16:19:11 2008
@@ -1061,12 +1061,35 @@
     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();
 
 }
 



More information about the Freeswitch-svn mailing list