<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14812] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14812">14812</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-09-10 16:37:32 -0500 (Thu, 10 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/MODLANG-124">MODLANG-124</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luafreeswitchi">freeswitch/trunk/src/mod/languages/mod_lua/freeswitch.i</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luamod_lua_extrac">freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luamod_lua_wrapcpp">freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp</a></li>
<li><a href="#freeswitchtrunksrcswitch_cppcpp">freeswitch/trunk/src/switch_cpp.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodlanguagesmod_luafreeswitchi"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch.i (14811 => 14812)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">         virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
</span><span class="cx">         void unsetInputCallback(void);
</span><span class="cx">         void setInputCallback(char *cbfunc, char *funcargs = NULL);
</span><del>-        void setHangupHook(char *func, char *arg);
</del><ins>+        void setHangupHook(char *func, char *arg = NULL);
</ins><span class="cx">         bool ready();
</span><span class="cx">         int originate(CoreSession *a_leg_session, char *dest, int timeout);
</span><span class="cx">         
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luamod_lua_extrac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.c (14811 => 14812)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -21,6 +21,7 @@
</span><span class="cx">         Session *result = new Session(session);
</span><span class="cx">
</span><span class="cx">         SWIG_NewPointerObj(L, result, SWIGTYPE_p_LUA__Session, destroy_me);
</span><ins>+        result->setLUA(L);
</ins><span class="cx">         lua_setglobal(L, name);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luamod_lua_wrapcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (14811 => 14812)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -7747,7 +7747,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static int _wrap_Session_setHangupHook(lua_State* L) {
</del><ins>+static int _wrap_Session_setHangupHook__SWIG_0(lua_State* L) {
</ins><span class="cx"> int SWIG_arg = -1;
</span><span class="cx"> LUA::Session *arg1 = (LUA::Session *) 0 ;
</span><span class="cx"> char *arg2 = (char *) 0 ;
</span><span class="lines">@@ -7777,6 +7777,89 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><ins>+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;
+}
+
+
</ins><span class="cx"> static int _wrap_Session_ready(lua_State* L) {
</span><span class="cx"> int SWIG_arg = -1;
</span><span class="cx"> LUA::Session *arg1 = (LUA::Session *) 0 ;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_cppcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_cpp.cpp (14811 => 14812)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -791,8 +791,6 @@
</span><span class="cx">                                                                                  sizeof(dtmf_buf),
</span><span class="cx">                                                                                  digits_regex);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf);
-
</del><span class="cx">         end_allow_threads();
</span><span class="cx">         return dtmf_buf;
</span><span class="cx"> }
</span><span class="lines">@@ -1146,7 +1144,6 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b)
</span><span class="cx"> {
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a.session), SWITCH_LOG_DEBUG, "bridge called, session_a uuid: %s\n", session_a.get_uuid());
</del><span class="cx">         switch_input_callback_function_t dtmf_func = NULL;
</span><span class="cx">         switch_input_args_t args;
</span><span class="cx">         switch_channel_t *channel_a = NULL, *channel_b = NULL;
</span><span class="lines">@@ -1185,9 +1182,6 @@
</span><span class="cx">         CoreSession *coresession = NULL;
</span><span class="cx">         switch_channel_state_t state = switch_channel_get_state(channel);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_hungup), SWITCH_LOG_DEBUG, "hangup_hook called\n");
-        
-
</del><span class="cx">         if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
</span><span class="cx">                 if (coresession->hook_state != state) {
</span><span class="cx">                         coresession->hook_state = state;
</span><span class="lines">@@ -1207,26 +1201,14 @@
</span><span class="cx">         
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session_cb);
</span><span class="cx">         CoreSession *coresession = NULL;
</span><del>-        switch_status_t result;
</del><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_cb), SWITCH_LOG_INFO, "dtmf_callback called\n");
-
-
-        //coresession = (CoreSession *) buf;
</del><span class="cx">         coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
</span><span class="cx">
</span><span class="cx">         if (!coresession) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_cb), SWITCH_LOG_ERROR, "Invalid CoreSession\n");                
</del><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        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;
-
</del><ins>+        return coresession->run_dtmf_callback(input, itype);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1308,30 +1290,33 @@
</span><span class="cx">                         unsigned int pos = 0;
</span><span class="cx">                         char *p;
</span><span class="cx">                         codec = switch_core_session_get_read_codec(session);
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "got codec\n");
</del><ins>+                        
</ins><span class="cx">                         if ((p = strchr(result, ':'))) {
</span><span class="cx">                                 p++;
</span><span class="cx">                                 if (*p == '+' || *p == '-') {
</span><span class="cx">                                         int step;
</span><ins>+                                        int target;
</ins><span class="cx">                                         if (!(step = atoi(p))) {
</span><span class="cx">                                                 step = 1000;
</span><span class="cx">                                         }
</span><del>-                                        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");
</del><ins>+
+                                        samps = step * (codec->implementation->samples_per_second / 1000);
+                                        target = fhp->pos + samps;
+
+                                        if (target < 0) {
+                                                target = 0;
</ins><span class="cx">                                         }
</span><ins>+
+                                        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);
+
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "going to seek\n");
</del><ins>+                                        if (samps < 0) {
+                                                samps = 0;
+                                        }
+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps);
</ins><span class="cx">                                         switch_core_file_seek(fhp, &pos, samps, SEEK_SET);
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done seek\n");
</del><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1340,11 +1325,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> if (!strcmp(result, "true") || !strcmp(result, "undefined")) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "return success\n");
</del><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "no callback result match for '%s', return false\n", result);
</del><span class="cx">
</span><span class="cx"> return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>