[Freeswitch-svn] [commit] r5202 - in freeswitch/branches/greenlizard/src: . include mod/formats/mod_shout mod/languages/mod_python

Freeswitch SVN greenlizard at freeswitch.org
Thu May 17 14:34:07 EDT 2007


Author: greenlizard
Date: Thu May 17 14:34:07 2007
New Revision: 5202

Modified:
   freeswitch/branches/greenlizard/src/include/switch_cpp.h
   freeswitch/branches/greenlizard/src/mod/formats/mod_shout/mod_shout.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h
   freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
   freeswitch/branches/greenlizard/src/switch_cpp.cpp

Log:
Sync up changes from trunk version 5186 to 5202.  streamfile method is working for mod_python now

Modified: freeswitch/branches/greenlizard/src/include/switch_cpp.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_cpp.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_cpp.h	Thu May 17 14:34:07 2007
@@ -44,6 +44,7 @@
 	int playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
 						 char *audio_files, char *bad_input_audio_files, char *dtmf_buf, 
 						 char *digits_regex);
+	int streamfile(char *file, void *cb_func, char *funcargs, int starting_sample_count);
 	void execute(char *app, char *data);
 	void begin_allow_threads();
 	void end_allow_threads();

Modified: freeswitch/branches/greenlizard/src/mod/formats/mod_shout/mod_shout.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/formats/mod_shout/mod_shout.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/formats/mod_shout/mod_shout.c	Thu May 17 14:34:07 2007
@@ -271,7 +271,8 @@
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error!\n");
 				}
 				dlen = 0;
-				continue;
+				//continue;
+                goto error;
 			}
 
 			context->mp3err = 0;
@@ -728,7 +729,11 @@
 			} else if (context->fp) {
 				*cur_sample = fseek(context->fp, *cur_sample, whence);
 			}
+
+            ExitMP3(&context->mp);
+            InitMP3(&context->mp, OUTSCALE, context->samplerate);
 			switch_buffer_zero(context->audio_buffer);
+
 		} else {
 			context->err++;
 		}

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch.py	Thu May 17 14:34:07 2007
@@ -77,6 +77,7 @@
     def getDigits(*args): return _freeswitch.CoreSession_getDigits(*args)
     def transfer(*args): return _freeswitch.CoreSession_transfer(*args)
     def playAndGetDigits(*args): return _freeswitch.CoreSession_playAndGetDigits(*args)
+    def streamfile(*args): return _freeswitch.CoreSession_streamfile(*args)
     def execute(*args): return _freeswitch.CoreSession_execute(*args)
     def begin_allow_threads(*args): return _freeswitch.CoreSession_begin_allow_threads(*args)
     def end_allow_threads(*args): return _freeswitch.CoreSession_end_allow_threads(*args)

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.cpp	Thu May 17 14:34:07 2007
@@ -14,25 +14,16 @@
     }
 }
 
-int PySession::streamfile(char *file, PyObject *pyfunc, PyObject *funcargs, int starting_sample_count)
+int PySession::streamfile(char *file, PyObject *pyfunc, char *funcargs, int starting_sample_count)
 {
-    // TODO: callback_args is currently ignored
-    // NOTE: funcargs is expected to contain a string
-
     switch_status_t status;
     switch_input_args_t args = { 0 }, *ap = NULL;
     struct input_callback_state cb_state = { 0 };
     switch_file_handle_t fh = { 0 };
-    char *s;
 
     sanity_check(-1);
-    if (PyArg_ParseTuple(funcargs, "s", &s)) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "funcargs: %s.", s);
-	cb_state.funcargs = s;
-    }
-    else {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "could not get funcargs");
-    }
+    cb_state.funcargs = funcargs;
+    fh.samples = starting_sample_count;
 
     if (!PyCallable_Check(pyfunc)) {
         dtmfCallbackFunction = NULL;
@@ -42,15 +33,13 @@
         dtmfCallbackFunction = pyfunc;
     }
 
-    fh.samples = starting_sample_count;
-
     if (dtmfCallbackFunction) {
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting DTMF callback\n");
 	cb_state.function = dtmfCallbackFunction;
 	cb_state.extra = &fh;
 	args.buf = &cb_state; 
 	args.buflen = sizeof(cb_state);  // not sure what this is used for, copy mod_spidermonkey
-        args.input_callback = PythonDTMFCallback;  // defined in mod_python.i, will use stuff in cb_state
+        args.input_callback = PythonDTMFCallback;  // defined in mod_python.i, will use ptrs in cb_state
 	ap = &args;
     }
     else {
@@ -65,7 +54,6 @@
 
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 
-
 }
 
 

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/freeswitch_python.h	Thu May 17 14:34:07 2007
@@ -41,7 +41,7 @@
 	PySession(char *uuid) : CoreSession(uuid) {};
 	PySession(switch_core_session_t *session) : CoreSession(session) {};
 	~PySession();        
-	int streamfile(char *file, PyObject *pyfunc, PyObject *funcargs, int starting_sample_count);
+	int streamfile(char *file, PyObject *pyfunc, char *funcargs, int starting_sample_count);
 	void set_dtmf_callback(PyObject *pyfunc);
 	void begin_allow_threads();
 	void end_allow_threads();

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_python/mod_python_wrap.cpp	Thu May 17 14:34:07 2007
@@ -4039,6 +4039,68 @@
 }
 
 
+SWIGINTERN PyObject *_wrap_CoreSession_streamfile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  void *arg3 = (void *) 0 ;
+  char *arg4 = (char *) 0 ;
+  int arg5 ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 ;
+  char *buf2 = 0 ;
+  int alloc2 = 0 ;
+  int res3 ;
+  int res4 ;
+  char *buf4 = 0 ;
+  int alloc4 = 0 ;
+  int val5 ;
+  int ecode5 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  PyObject * obj4 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOOO:CoreSession_streamfile",&obj0,&obj1,&obj2,&obj3,&obj4)) 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_streamfile" "', 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_streamfile" "', argument " "2"" of type '" "char *""'");
+  }
+  arg2 = buf2;
+  res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_streamfile" "', argument " "3"" of type '" "void *""'"); 
+  }
+  res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
+  if (!SWIG_IsOK(res4)) {
+    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_streamfile" "', argument " "4"" of type '" "char *""'");
+  }
+  arg4 = buf4;
+  ecode5 = SWIG_AsVal_int(obj4, &val5);
+  if (!SWIG_IsOK(ecode5)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_streamfile" "', argument " "5"" of type '" "int""'");
+  } 
+  arg5 = static_cast< int >(val5);
+  result = (int)(arg1)->streamfile(arg2,arg3,arg4,arg5);
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+  return resultobj;
+fail:
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_CoreSession_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -4557,7 +4619,7 @@
   PySession *arg1 = (PySession *) 0 ;
   char *arg2 = (char *) 0 ;
   PyObject *arg3 = (PyObject *) 0 ;
-  PyObject *arg4 = (PyObject *) 0 ;
+  char *arg4 = (char *) 0 ;
   int arg5 ;
   int result;
   void *argp1 = 0 ;
@@ -4565,6 +4627,9 @@
   int res2 ;
   char *buf2 = 0 ;
   int alloc2 = 0 ;
+  int res4 ;
+  char *buf4 = 0 ;
+  int alloc4 = 0 ;
   int val5 ;
   int ecode5 = 0 ;
   PyObject * obj0 = 0 ;
@@ -4585,7 +4650,11 @@
   }
   arg2 = buf2;
   arg3 = obj2;
-  arg4 = obj3;
+  res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
+  if (!SWIG_IsOK(res4)) {
+    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "PySession_streamfile" "', argument " "4"" of type '" "char *""'");
+  }
+  arg4 = buf4;
   ecode5 = SWIG_AsVal_int(obj4, &val5);
   if (!SWIG_IsOK(ecode5)) {
     SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "PySession_streamfile" "', argument " "5"" of type '" "int""'");
@@ -4594,9 +4663,11 @@
   result = (int)(arg1)->streamfile(arg2,arg3,arg4,arg5);
   resultobj = SWIG_From_int(static_cast< int >(result));
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
   return resultobj;
 fail:
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
   return NULL;
 }
 
@@ -4698,6 +4769,7 @@
 	 { (char *)"CoreSession_getDigits", _wrap_CoreSession_getDigits, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_transfer", _wrap_CoreSession_transfer, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits, METH_VARARGS, NULL},
+	 { (char *)"CoreSession_streamfile", _wrap_CoreSession_streamfile, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_execute", _wrap_CoreSession_execute, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_begin_allow_threads", _wrap_CoreSession_begin_allow_threads, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_end_allow_threads", _wrap_CoreSession_end_allow_threads, METH_VARARGS, NULL},

Modified: freeswitch/branches/greenlizard/src/switch_cpp.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_cpp.cpp	(original)
+++ freeswitch/branches/greenlizard/src/switch_cpp.cpp	Thu May 17 14:34:07 2007
@@ -171,6 +171,10 @@
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
+int CoreSession::streamfile(char *file, void *cb_func, char *funcargs, int starting_sample_count) {
+	return 0;
+}
+
 void CoreSession::begin_allow_threads() { 
 }
 



More information about the Freeswitch-svn mailing list