]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
MODLANG-124
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 10 Sep 2009 21:37:32 +0000 (21:37 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 10 Sep 2009 21:37:32 +0000 (21:37 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14812 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_lua/freeswitch.i
src/mod/languages/mod_lua/mod_lua_extra.c
src/mod/languages/mod_lua/mod_lua_wrap.cpp
src/switch_cpp.cpp

index fc30cad17c74e6e6f22ae51e64b8d3784497b7ac..3631aca62ffe3d546faa4d5be8ea08c837bce953 100644 (file)
@@ -55,7 +55,7 @@ class Session : public CoreSession {
        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);
        
index f23fc0ecf5c940c77ff26d6b40e74c929574b641..38776f93d7461dc4c3bd1b722764231af0d67e24 100644 (file)
@@ -21,6 +21,7 @@ void mod_lua_conjure_session(lua_State * L, switch_core_session_t *session, cons
        Session *result = new Session(session);
 
        SWIG_NewPointerObj(L, result, SWIGTYPE_p_LUA__Session, destroy_me);
+       result->setLUA(L);
        lua_setglobal(L, name);
 }
 
index 704154cb87ed43f536eca971781d932d9ed892cb..b95163fdf84c50fc958a789c2e9a9caae923deb0 100644 (file)
@@ -7747,7 +7747,7 @@ static int _wrap_Session_setInputCallback(lua_State* L) {
 }
 
 
-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 @@ fail:
 }
 
 
+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 ;
index 046e8db98ec12b285c2b38adeb6e4d036fad8229..7f0eb21d9bae6c270a1d03f0e7b62f2c777c9a26 100644 (file)
@@ -791,8 +791,6 @@ SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits,
                                                                                 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) msleep(unsigned ms)
 
 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 @@ SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session
        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_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *sess
        
        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 @@ SWITCH_DECLARE(switch_status_t) CoreSession::process_callback_result(char *resul
                        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 @@ SWITCH_DECLARE(switch_status_t) CoreSession::process_callback_result(char *resul
        }
 
     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;
 }