]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Add recordFile method. merge svn r5149 from branch.
authorMichael Jerris <mike@jerris.com>
Wed, 20 Jun 2007 14:35:22 +0000 (14:35 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 20 Jun 2007 14:35:22 +0000 (14:35 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5420 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_cpp.h
src/mod/languages/mod_python/freeswitch.py
src/mod/languages/mod_python/mod_python_wrap.cpp
src/switch_cpp.cpp

index 5e45c0bf126bf09c74d92204ab9b515b8f2c215e..57f35aeeb33ba1454d623065dbfd1b9e04a8eaa2 100644 (file)
@@ -68,6 +68,17 @@ class CoreSession {
        void setVariable(char *var, char *val);
        char *getVariable(char *var);
 
+
+       /** \brief Record to a file
+        * \param filename 
+        * \param <[max_len]> maximum length of the recording in seconds
+     * \param <[silence_threshold]> energy level audio must fall below 
+        *        to be considered silence (500 is a good starting point).
+        * \param <[silence_secs]> seconds of silence to interrupt the record.
+        */
+       int recordFile(char *file_name, int max_len=0, int silence_threshold=0, int silence_secs=0);
+
+
        /** \brief Set attributes of caller data for purposes of outgoing calls
         * \param var - the variable name, eg, "caller_id_name"
         * \param val - the data to set, eg, "bob"
index 01f4354741d7de26fa1ede2273dfcde7362ca107..046ce729f0bad6c9e45756583cab752802f5cd4d 100644 (file)
@@ -106,6 +106,7 @@ class CoreSession(_object):
     def hangup(*args): return _freeswitch.CoreSession_hangup(*args)
     def setVariable(*args): return _freeswitch.CoreSession_setVariable(*args)
     def getVariable(*args): return _freeswitch.CoreSession_getVariable(*args)
+    def recordFile(*args): return _freeswitch.CoreSession_recordFile(*args)
     def setCallerData(*args): return _freeswitch.CoreSession_setCallerData(*args)
     def originate(*args): return _freeswitch.CoreSession_originate(*args)
     def playFile(*args): return _freeswitch.CoreSession_playFile(*args)
index 7773fd5a9dcf2ab9d72dcf18ed32249b39b0aaf1..f9c85ff99ef5b4451cde760cb730bb255734e879 100644 (file)
@@ -3745,6 +3745,73 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_CoreSession_recordFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  int arg3 = (int) 0 ;
+  int arg4 = (int) 0 ;
+  int arg5 = (int) 0 ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 ;
+  char *buf2 = 0 ;
+  int alloc2 = 0 ;
+  int val3 ;
+  int ecode3 = 0 ;
+  int val4 ;
+  int ecode4 = 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 *)"OO|OOO:CoreSession_recordFile",&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_recordFile" "', 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_recordFile" "', argument " "2"" of type '" "char *""'");
+  }
+  arg2 = reinterpret_cast< char * >(buf2);
+  if (obj2) {
+    ecode3 = SWIG_AsVal_int(obj2, &val3);
+    if (!SWIG_IsOK(ecode3)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_recordFile" "', argument " "3"" of type '" "int""'");
+    } 
+    arg3 = static_cast< int >(val3);
+  }
+  if (obj3) {
+    ecode4 = SWIG_AsVal_int(obj3, &val4);
+    if (!SWIG_IsOK(ecode4)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_recordFile" "', argument " "4"" of type '" "int""'");
+    } 
+    arg4 = static_cast< int >(val4);
+  }
+  if (obj4) {
+    ecode5 = SWIG_AsVal_int(obj4, &val5);
+    if (!SWIG_IsOK(ecode5)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_recordFile" "', argument " "5"" of type '" "int""'");
+    } 
+    arg5 = static_cast< int >(val5);
+  }
+  result = (int)(arg1)->recordFile(arg2,arg3,arg4,arg5);
+  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;
+}
+
+
 SWIGINTERN PyObject *_wrap_CoreSession_setCallerData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -4821,6 +4888,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"CoreSession_hangup", _wrap_CoreSession_hangup, METH_VARARGS, NULL},
         { (char *)"CoreSession_setVariable", _wrap_CoreSession_setVariable, METH_VARARGS, NULL},
         { (char *)"CoreSession_getVariable", _wrap_CoreSession_getVariable, METH_VARARGS, NULL},
+        { (char *)"CoreSession_recordFile", _wrap_CoreSession_recordFile, METH_VARARGS, NULL},
         { (char *)"CoreSession_setCallerData", _wrap_CoreSession_setCallerData, METH_VARARGS, NULL},
         { (char *)"CoreSession_originate", _wrap_CoreSession_originate, METH_VARARGS, NULL},
         { (char *)"CoreSession_playFile", _wrap_CoreSession_playFile, METH_VARARGS, NULL},
index a4224bbf0864389ea6bbb0eb4ca9eaa5a51a9135..3ee9d72fe4cf57ed78749e0012b0b60d0f013503 100644 (file)
@@ -303,6 +303,20 @@ int CoreSession::originate(CoreSession *aleg_session,
        return SWITCH_STATUS_FALSE;
 }
 
+int CoreSession::recordFile(char *file_name, int max_len, int silence_threshold, int silence_secs) 
+{
+       switch_file_handle_t fh = { 0 };
+       switch_status_t status;
+
+       fh.thresh = silence_threshold;
+       fh.silence_hits = silence_secs;
+       store_file_handle(&fh);
+       begin_allow_threads();
+       status = switch_ivr_record_file(session, &fh, file_name, &args, max_len);
+       end_allow_threads();
+    return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
+
+}
 
 void CoreSession::setCallerData(char *var, char *val) {