[Freeswitch-svn] [commit] r9004 - in freeswitch/trunk/src: . include mod/applications/mod_fsv mod/languages/mod_java mod/languages/mod_java/src/org/freeswitch/swig mod/languages/mod_lua mod/languages/mod_perl mod/languages/mod_python
Freeswitch SVN
brian at freeswitch.org
Sat Jul 12 14:44:07 EDT 2008
Author: brian
Date: Sat Jul 12 14:44:05 2008
New Revision: 9004
Modified:
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/include/switch_platform.h
freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c
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/freeswitch_lua.h
freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_cpp.cpp
freeswitch/trunk/src/switch_utils.c
Log:
fix callback arg and CoreSession::sleep to not require a file
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Sat Jul 12 14:44:05 2008
@@ -284,7 +284,7 @@
*
*/
SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0);
- SWITCH_DECLARE(int) sleep(char *file, int ms);
+ SWITCH_DECLARE(int) sleep(int ms);
/** \brief flush any pending events
*/
Modified: freeswitch/trunk/src/include/switch_platform.h
==============================================================================
--- freeswitch/trunk/src/include/switch_platform.h (original)
+++ freeswitch/trunk/src/include/switch_platform.h Sat Jul 12 14:44:05 2008
@@ -163,6 +163,7 @@
#endif
#define SWITCH_THREAD_FUNC __stdcall
#else //not win32
+#define O_BINARY 0
#define SWITCH_DECLARE(type) type
#define SWITCH_DECLARE_NONSTD(type) type
#define SWITCH_MOD_DECLARE(type) type
Modified: freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c Sat Jul 12 14:44:05 2008
@@ -231,7 +231,7 @@
aud_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
vid_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
- if ((fd = open((char *) data, O_RDONLY)) < 0) {
+ if ((fd = open((char *) data, O_RDONLY | O_BINARY)) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
return;
}
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 Sat Jul 12 14:44:05 2008
@@ -209,8 +209,8 @@
return freeswitchJNI.CoreSession_streamFile__SWIG_1(swigCPtr, this, file);
}
- public int sleep(String file, int ms) {
- return freeswitchJNI.CoreSession_sleep(swigCPtr, this, file, ms);
+ public int sleep(int ms) {
+ return freeswitchJNI.CoreSession_sleep(swigCPtr, this, ms);
}
public int flushEvents() {
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 Sat Jul 12 14:44:05 2008
@@ -127,7 +127,7 @@
public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
- public final static native int CoreSession_sleep(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
+ public final static native int CoreSession_sleep(long jarg1, CoreSession jarg1_, int jarg2);
public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_flushDigits(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_setAutoHangup(long jarg1, CoreSession jarg1_, boolean 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 Sat Jul 12 14:44:05 2008
@@ -2487,26 +2487,19 @@
}
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sleep(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sleep(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
jint jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- int arg3 ;
+ int arg2 ;
int result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(CoreSession **)&jarg1;
- arg2 = 0;
- if (jarg2) {
- arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
- if (!arg2) return 0;
- }
- arg3 = (int)jarg3;
- result = (int)(arg1)->sleep(arg2,arg3);
+ arg2 = (int)jarg2;
+ result = (int)(arg1)->sleep(arg2);
jresult = (jint)result;
- if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
return jresult;
}
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 Sat Jul 12 14:44:05 2008
@@ -51,6 +51,8 @@
void Session::setLUA(lua_State * state)
{
L = state;
+ lua_setglobal(L, uuid);
+ lua_getfield(L, LUA_GLOBALSINDEX, uuid);
}
lua_State *Session::getLUA()
@@ -180,9 +182,11 @@
{
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
char str[2] = "";
- int arg_count = 2;
+ int arg_count = 3;
lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_function);
+ lua_getfield(L, LUA_GLOBALSINDEX, uuid);
+
lua_pushstring(L, "dtmf");
lua_newtable(L);
@@ -210,9 +214,11 @@
case SWITCH_INPUT_TYPE_EVENT:
{
switch_event_t *event = (switch_event_t *) input;
- int arg_count = 2;
+ int arg_count = 3;
+
lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_function);
+ lua_getfield(L, LUA_GLOBALSINDEX, uuid);
lua_pushstring(L, "event");
mod_lua_conjure_event(L, event, "__Input_Event__", 1);
lua_getfield(L, LUA_GLOBALSINDEX, "__Input_Event__");
@@ -222,8 +228,7 @@
arg_count++;
}
- lua_call(L, 2, 1);
-
+ lua_call(L, arg_count, 1);
ret = lua_tostring(L, -1);
lua_pop(L, 1);
Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h Sat Jul 12 14:44:05 2008
@@ -29,7 +29,7 @@
virtual void check_hangup_hook();
virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
- void setInputCallback(char *cbfunc, char *funcargs);
+ void setInputCallback(char *cbfunc, char *funcargs = NULL);
void setHangupHook(char *func, char *arg = NULL);
bool ready();
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 Sat Jul 12 14:44:05 2008
@@ -5729,22 +5729,19 @@
static int _wrap_CoreSession_sleep(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- int arg3 ;
+ int arg2 ;
int result;
- SWIG_check_num_args("sleep",3,3)
+ SWIG_check_num_args("sleep",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("sleep",1,"CoreSession *");
- if(!lua_isstring(L,2)) SWIG_fail_arg("sleep",2,"char *");
- if(!lua_isnumber(L,3)) SWIG_fail_arg("sleep",3,"int");
+ if(!lua_isnumber(L,2)) SWIG_fail_arg("sleep",2,"int");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
SWIG_fail_ptr("CoreSession_sleep",1,SWIGTYPE_p_CoreSession);
}
- arg2 = (char *)lua_tostring(L, 2);
- arg3 = (int)lua_tonumber(L, 3);
- result = (int)(arg1)->sleep(arg2,arg3);
+ arg2 = (int)lua_tonumber(L, 2);
+ result = (int)(arg1)->sleep(arg2);
SWIG_arg=0;
lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
return SWIG_arg;
@@ -6786,7 +6783,7 @@
}
-static int _wrap_Session_setInputCallback(lua_State* L) {
+static int _wrap_Session_setInputCallback__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
LUA::Session *arg1 = (LUA::Session *) 0 ;
char *arg2 = (char *) 0 ;
@@ -6816,6 +6813,89 @@
}
+static int _wrap_Session_setInputCallback__SWIG_1(lua_State* L) {
+ int SWIG_arg = -1;
+ LUA::Session *arg1 = (LUA::Session *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ SWIG_check_num_args("setInputCallback",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setInputCallback",1,"LUA::Session *");
+ if(!lua_isstring(L,2)) SWIG_fail_arg("setInputCallback",2,"char *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
+ SWIG_fail_ptr("Session_setInputCallback",1,SWIGTYPE_p_LUA__Session);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ (arg1)->setInputCallback(arg2);
+ SWIG_arg=0;
+
+ return SWIG_arg;
+
+ if(0) SWIG_fail;
+
+fail:
+ lua_error(L);
+ return SWIG_arg;
+}
+
+
+static int _wrap_Session_setInputCallback(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_setInputCallback__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_setInputCallback__SWIG_0(L);
+ }
+ }
+ }
+ }
+
+ lua_pushstring(L,"No matching function for overloaded 'Session_setInputCallback'");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_Session_setHangupHook__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
LUA::Session *arg1 = (LUA::Session *) 0 ;
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 Sat Jul 12 14:44:05 2008
@@ -7674,46 +7674,35 @@
XS(_wrap_CoreSession_sleep) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- int arg3 ;
+ int arg2 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
- int res2 ;
- char *buf2 = 0 ;
- int alloc2 = 0 ;
- int val3 ;
- int ecode3 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
int argvi = 0;
dXSARGS;
- if ((items < 3) || (items > 3)) {
- SWIG_croak("Usage: CoreSession_sleep(self,file,ms);");
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: CoreSession_sleep(self,ms);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_sleep" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_sleep" "', argument " "2"" of type '" "char *""'");
- }
- arg2 = reinterpret_cast< char * >(buf2);
- ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
- if (!SWIG_IsOK(ecode3)) {
- SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_sleep" "', argument " "3"" of type '" "int""'");
+ ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_sleep" "', argument " "2"" of type '" "int""'");
}
- arg3 = static_cast< int >(val3);
- result = (int)(arg1)->sleep(arg2,arg3);
+ arg2 = static_cast< int >(val2);
+ result = (int)(arg1)->sleep(arg2);
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
XSRETURN(argvi);
fail:
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
SWIG_croak_null();
}
Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Sat Jul 12 14:44:05 2008
@@ -7656,42 +7656,30 @@
SWIGINTERN PyObject *_wrap_CoreSession_sleep(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- int arg3 ;
+ int arg2 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
- int res2 ;
- char *buf2 = 0 ;
- int alloc2 = 0 ;
- int val3 ;
- int ecode3 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_sleep",&obj0,&obj1,&obj2)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OO:CoreSession_sleep",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_sleep" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_sleep" "', argument " "2"" of type '" "char *""'");
- }
- arg2 = reinterpret_cast< char * >(buf2);
- ecode3 = SWIG_AsVal_int(obj2, &val3);
- if (!SWIG_IsOK(ecode3)) {
- SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_sleep" "', argument " "3"" of type '" "int""'");
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_sleep" "', argument " "2"" of type '" "int""'");
}
- arg3 = static_cast< int >(val3);
- result = (int)(arg1)->sleep(arg2,arg3);
+ arg2 = static_cast< int >(val2);
+ result = (int)(arg1)->sleep(arg2);
resultobj = SWIG_From_int(static_cast< int >(result));
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
return resultobj;
fail:
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
return NULL;
}
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Sat Jul 12 14:44:05 2008
@@ -606,7 +606,7 @@
mime_path = switch_mprintf("%s/%s", SWITCH_GLOBAL_dirs.conf_dir, cf);
switch_assert(mime_path);
- fd = open(mime_path, O_RDONLY);
+ fd = open(mime_path, O_RDONLY | O_BINARY);
if (fd <= 0) {
goto end;
}
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Sat Jul 12 14:44:05 2008
@@ -724,13 +724,13 @@
}
SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits,
- int max_digits,
- int max_tries,
- int timeout,
- char *terminators,
- char *audio_files,
- char *bad_input_audio_files,
- char *digits_regex)
+ int max_digits,
+ int max_tries,
+ int timeout,
+ char *terminators,
+ char *audio_files,
+ char *bad_input_audio_files,
+ char *digits_regex)
{
switch_status_t status;
sanity_check((char *)"");
@@ -814,7 +814,7 @@
}
-SWITCH_DECLARE(int) CoreSession::sleep(char *file, int ms) {
+SWITCH_DECLARE(int) CoreSession::sleep(int ms) {
switch_status_t status;
@@ -1091,10 +1091,10 @@
SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session_cb,
- void *input,
- switch_input_type_t itype,
- void *buf,
- unsigned int buflen) {
+ void *input,
+ switch_input_type_t itype,
+ void *buf,
+ unsigned int buflen) {
switch_channel_t *channel = switch_core_session_get_channel(session_cb);
CoreSession *coresession = NULL;
@@ -1137,93 +1137,87 @@
fh = fhp;
}
+ if (fh) {
+ if (!fh) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because fh is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!fh->file_interface) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because fh->file_interface is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!strncasecmp(result, "speed", 4)) {
+ char *p;
+
+ if ((p = strchr(result, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1;
+ }
+ fh->speed += step;
+ } else {
+ int speed = atoi(p);
+ fh->speed = speed;
+ }
+ return SWITCH_STATUS_SUCCESS;
+ }
- if (!fh) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because fh is null\n");
- return SWITCH_STATUS_FALSE;
- }
-
- if (!fh->file_interface) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because fh->file_interface is null\n");
- return SWITCH_STATUS_FALSE;
- }
-
- if (!session) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because session is null\n");
- return SWITCH_STATUS_FALSE;
- }
-
-
- if (!strncasecmp(result, "speed", 4)) {
- char *p;
+ return SWITCH_STATUS_FALSE;
- if ((p = strchr(result, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1;
- }
- fh->speed += step;
+ } else if (!strcasecmp(result, "pause")) {
+ if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(fh, SWITCH_FILE_PAUSE);
} else {
- int speed = atoi(p);
- fh->speed = speed;
+ switch_set_flag(fh, SWITCH_FILE_PAUSE);
}
return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_FALSE;
-
- } else if (!strcasecmp(result, "pause")) {
- if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
- switch_clear_flag(fh, SWITCH_FILE_PAUSE);
- } else {
- switch_set_flag(fh, SWITCH_FILE_PAUSE);
- }
- return SWITCH_STATUS_SUCCESS;
- } else if (!strcasecmp(result, "stop")) {
- return SWITCH_STATUS_FALSE;
- } else if (!strcasecmp(result, "restart")) {
- unsigned int pos = 0;
- fh->speed = 0;
- switch_core_file_seek(fh, &pos, 0, SEEK_SET);
- return SWITCH_STATUS_SUCCESS;
- } else if (!strncasecmp(result, "seek", 4)) {
- switch_codec_t *codec;
- unsigned int samps = 0;
- unsigned int pos = 0;
- char *p;
- codec = switch_core_session_get_read_codec(session);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got codec\n");
- if ((p = strchr(result, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1000;
- }
- if (step > 0) {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
- switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
+ } else if (!strcasecmp(result, "stop")) {
+ return SWITCH_STATUS_FALSE;
+ } else if (!strcasecmp(result, "restart")) {
+ unsigned int pos = 0;
+ fh->speed = 0;
+ switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strncasecmp(result, "seek", 4)) {
+ switch_codec_t *codec;
+ unsigned int samps = 0;
+ unsigned int pos = 0;
+ char *p;
+ codec = switch_core_session_get_read_codec(session);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got codec\n");
+ if ((p = strchr(result, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1000;
+ }
+ if (step > 0) {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
+ switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
+ } else {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
+ switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
+ }
} else {
- samps = step * (codec->implementation->samples_per_second / 1000);
+ samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
- switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ switch_core_file_seek(fh, &pos, samps, SEEK_SET);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
}
- } else {
- samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
- switch_core_file_seek(fh, &pos, samps, SEEK_SET);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
}
- }
-
- return SWITCH_STATUS_SUCCESS;
- }
+ return SWITCH_STATUS_SUCCESS;
+ }
+ }
if (!strcmp(result, "true") || !strcmp(result, "undefined")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "return success\n");
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Sat Jul 12 14:44:05 2008
@@ -370,7 +370,7 @@
if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
if (file) {
- if ((ifd = open(file, O_RDONLY)) < 1) {
+ if ((ifd = open(file, O_RDONLY | O_BINARY)) < 1) {
return SWITCH_FALSE;
}
}
More information about the Freeswitch-svn
mailing list