Add recordFile method. merge svn r5149 from branch.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5420 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c31639279a
commit
bd2c91b028
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue