Revision
14812
Author
anthm
Date
2009-09-10 16:37:32 -0500 (Thu, 10 Sep 2009)

Log Message

MODLANG-124

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch.i (14811 => 14812)


--- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch.i	2009-09-10 20:42:17 UTC (rev 14811)
+++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch.i	2009-09-10 21:37:32 UTC (rev 14812)
@@ -55,7 +55,7 @@
 	virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
 	void unsetInputCallback(void);
 	void setInputCallback(char *cbfunc, char *funcargs = NULL);
-	void setHangupHook(char *func, char *arg);
+	void setHangupHook(char *func, char *arg = NULL);
 	bool ready();
 	int originate(CoreSession *a_leg_session, char *dest, int timeout);
 	

Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.c (14811 => 14812)


--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.c	2009-09-10 20:42:17 UTC (rev 14811)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.c	2009-09-10 21:37:32 UTC (rev 14812)
@@ -21,6 +21,7 @@
 	Session *result = new Session(session);
 
 	SWIG_NewPointerObj(L, result, SWIGTYPE_p_LUA__Session, destroy_me);
+	result->setLUA(L);
 	lua_setglobal(L, name);
 }
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (14811 => 14812)


--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	2009-09-10 20:42:17 UTC (rev 14811)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	2009-09-10 21:37:32 UTC (rev 14812)
@@ -7747,7 +7747,7 @@
 }
 
 
-static int _wrap_Session_setHangupHook(lua_State* L) {
+static int _wrap_Session_setHangupHook__SWIG_0(lua_State* L) {
   int SWIG_arg = -1;
   LUA::Session *arg1 = (LUA::Session *) 0 ;
   char *arg2 = (char *) 0 ;
@@ -7777,6 +7777,89 @@
 }
 
 
+static int _wrap_Session_setHangupHook__SWIG_1(lua_State* L) {
+  int SWIG_arg = -1;
+  LUA::Session *arg1 = (LUA::Session *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("setHangupHook",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setHangupHook",1,"LUA::Session *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("setHangupHook",2,"char *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
+    SWIG_fail_ptr("Session_setHangupHook",1,SWIGTYPE_p_LUA__Session);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  (arg1)->setHangupHook(arg2);
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_setHangupHook(lua_State* L) {
+  int argc;
+  int argv[4]={
+    1,2,3,4
+  };
+  
+  argc = lua_gettop(L);
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
+        _v = 0;
+      } else {
+        _v = 1;
+      }
+    }
+    if (_v) {
+      {
+        _v = lua_isstring(L,argv[1]);
+      }
+      if (_v) {
+        return _wrap_Session_setHangupHook__SWIG_1(L);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    {
+      void *ptr;
+      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
+        _v = 0;
+      } else {
+        _v = 1;
+      }
+    }
+    if (_v) {
+      {
+        _v = lua_isstring(L,argv[1]);
+      }
+      if (_v) {
+        {
+          _v = lua_isstring(L,argv[2]);
+        }
+        if (_v) {
+          return _wrap_Session_setHangupHook__SWIG_0(L);
+        }
+      }
+    }
+  }
+  
+  lua_pushstring(L,"No matching function for overloaded 'Session_setHangupHook'");
+  lua_error(L);return 0;
+}
+
+
 static int _wrap_Session_ready(lua_State* L) {
   int SWIG_arg = -1;
   LUA::Session *arg1 = (LUA::Session *) 0 ;

Modified: freeswitch/trunk/src/switch_cpp.cpp (14811 => 14812)


--- freeswitch/trunk/src/switch_cpp.cpp	2009-09-10 20:42:17 UTC (rev 14811)
+++ freeswitch/trunk/src/switch_cpp.cpp	2009-09-10 21:37:32 UTC (rev 14812)
@@ -791,8 +791,6 @@
 										 sizeof(dtmf_buf), 
 										 digits_regex);
 
-	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf);
-
 	end_allow_threads();
 	return dtmf_buf;
 }
@@ -1146,7 +1144,6 @@
 
 SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b)
 {
-    switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a.session), 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;
@@ -1185,9 +1182,6 @@
 	CoreSession *coresession = NULL;
 	switch_channel_state_t state = switch_channel_get_state(channel);
 
-	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_hungup), SWITCH_LOG_DEBUG, "hangup_hook called\n");
-	
-
 	if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
 		if (coresession->hook_state != state) {
 			coresession->hook_state = state;
@@ -1207,26 +1201,14 @@
 	
 	switch_channel_t *channel = switch_core_session_get_channel(session_cb);
 	CoreSession *coresession = NULL;
-	switch_status_t result;
 
-	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_cb), SWITCH_LOG_INFO, "dtmf_callback called\n");
-
-
-	//coresession = (CoreSession *) buf;
 	coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
 
 	if (!coresession) {
-		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_cb), SWITCH_LOG_ERROR, "Invalid CoreSession\n");		
 		return SWITCH_STATUS_FALSE;
 	}
 
-	result = coresession->run_dtmf_callback(input, itype);
-	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_cb), SWITCH_LOG_DEBUG, "process_callback_result returned\n");
-	if (result) {
-		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_cb), SWITCH_LOG_DEBUG, "process_callback_result returned: %d\n", result);
-	}
-	return result;
-
+	return coresession->run_dtmf_callback(input, itype);
 }
 
 
@@ -1308,30 +1290,33 @@
 			unsigned int pos = 0;
 			char *p;
 			codec = switch_core_session_get_read_codec(session);
-			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "got codec\n");
+			
 			if ((p = strchr(result, ':'))) {
 				p++;
 				if (*p == '+' || *p == '-') {
 					int step;
+					int target;
 					if (!(step = atoi(p))) {
 						step = 1000;
 					}
-					if (step > 0) {
-						samps = step * (codec->implementation->samples_per_second / 1000);
-						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "going to seek\n");
-						switch_core_file_seek(fhp, &pos, samps, SEEK_CUR);
-						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done seek\n");
-					} else {
-						samps = step * (codec->implementation->samples_per_second / 1000);
-						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "going to seek\n");
-						switch_core_file_seek(fhp, &pos, fhp->pos - samps, SEEK_SET);
-						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done seek\n");
+
+					samps = step * (codec->implementation->samples_per_second / 1000);
+					target = fhp->pos + samps;
+
+					if (target < 0) {
+						target = 0;
 					}
+
+					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", target);
+					switch_core_file_seek(fhp, &pos, target, SEEK_SET);
+
 				} else {
 					samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
-					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "going to seek\n");
+					if (samps < 0) {
+						samps = 0;
+					}
+					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps);
 					switch_core_file_seek(fhp, &pos, samps, SEEK_SET);
-					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done seek\n");
 				}
 			}
 
@@ -1340,11 +1325,9 @@
 	}
 
     if (!strcmp(result, "true") || !strcmp(result, "undefined")) {
-		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "return success\n");
 		return SWITCH_STATUS_SUCCESS;
     }
 
-	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "no callback result match for '%s', return false\n", result);
 
     return SWITCH_STATUS_FALSE;
 }