add timelimit to record

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3475 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2006-11-28 21:46:29 +00:00
1 parent fe376294fc
commit d288ae58a8
10 files changed
+148 -120

No files matched your search

@@ -132,10 +132,20 @@ static void record_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
switch_status_t status;
uint32_t limit = 0;
char *path;
char *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
status = switch_ivr_record_file(session, NULL, data, on_dtmf, NULL, 0);
path = switch_core_session_strdup(session, data);
if ((p = strchr(path, '+'))) {
*p++ = '\0';
limit = atoi(p);
}
status = switch_ivr_record_file(session, NULL, path, on_dtmf, NULL, 0, limit);
if (!switch_channel_ready(channel) || (status != SWITCH_STATUS_SUCCESS && !SWITCH_STATUS_IS_BREAK(status))) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@@ -43,7 +43,6 @@
************************************************************************/
#include <string.h>
#include <switch.h>
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(_MSC_VER) || defined(__GNUC__)
@@ -808,7 +807,7 @@ extern void fs_channel_set_variable(switch_core_session_t *,char *,char *);
extern void fs_channel_get_variable(switch_core_session_t *,char *);
extern void fs_channel_set_state(switch_core_session_t *,char *);
extern int fs_ivr_play_file(switch_core_session_t *,char *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
extern int fs_switch_ivr_sleep(switch_core_session_t *,uint32_t);
extern int fs_ivr_play_file2(switch_core_session_t *,char *);
extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
@@ -1263,12 +1262,13 @@ XS(_wrap_fs_switch_ivr_record_file) {
switch_input_callback_function_t arg4 ;
void *arg5 = (void *) 0 ;
unsigned int arg6 ;
unsigned int arg7 ;
int result;
int argvi = 0;
dXSARGS;
if ((items < 6) || (items > 6)) {
SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,dtmf_callback,buf,buflen);");
if ((items < 7) || (items > 7)) {
SWIG_croak("Usage: fs_switch_ivr_record_file(session,fh,file,dtmf_callback,buf,buflen,limit);");
}
{
if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
@@ -1295,7 +1295,8 @@ XS(_wrap_fs_switch_ivr_record_file) {
}
}
arg6 = (unsigned int) SvUV(ST(5));
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6);
arg7 = (unsigned int) SvUV(ST(6));
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
ST(argvi) = sv_newmortal();
sv_setiv(ST(argvi++), (IV) result);
@@ -93,14 +93,3 @@ ZEND_END_MODULE_GLOBALS(freeswitch)
#endif
#endif /* PHP_FREESWITCH_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:nil
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/
+9 -4
View File
@@ -577,7 +577,7 @@ extern void fs_channel_set_variable(switch_core_session_t *,char *,char *);
extern void fs_channel_get_variable(switch_core_session_t *,char *);
extern void fs_channel_set_state(switch_core_session_t *,char *);
extern int fs_ivr_play_file(switch_core_session_t *,char *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
extern int fs_switch_ivr_sleep(switch_core_session_t *,uint32_t);
extern int fs_ivr_play_file2(switch_core_session_t *,char *);
extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
@@ -1143,15 +1143,16 @@ ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_record_file) {
switch_input_callback_function_t arg4 ;
void *arg5 = (void *) 0 ;
unsigned int arg6 ;
unsigned int arg7 ;
int result;
zval **args[7];
zval **args[8];
int argbase=0 ;
if (this_ptr && this_ptr->type==IS_OBJECT) {
/* fake this_ptr as first arg (till we can work out how to do it better */
argbase++;
}
if(((ZEND_NUM_ARGS() + argbase )!= 6) || (zend_get_parameters_array_ex(6-argbase, args)!= SUCCESS)) {
if(((ZEND_NUM_ARGS() + argbase )!= 7) || (zend_get_parameters_array_ex(7-argbase, args)!= SUCCESS)) {
WRONG_PARAM_COUNT;
}
@@ -1187,7 +1188,11 @@ ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_record_file) {
convert_to_long_ex(args[5-argbase]);
arg6 = (unsigned int) Z_LVAL_PP(args[5-argbase]);
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6);
convert_to_long_ex(args[6-argbase]);
arg7 = (unsigned int) Z_LVAL_PP(args[6-argbase]);
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
ZVAL_LONG(return_value,result);
@@ -716,7 +716,7 @@ extern void fs_channel_set_variable(switch_core_session_t *,char *,char *);
extern void fs_channel_get_variable(switch_core_session_t *,char *);
extern void fs_channel_set_state(switch_core_session_t *,char *);
extern int fs_ivr_play_file(switch_core_session_t *,char *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
extern int fs_switch_ivr_sleep(switch_core_session_t *,uint32_t);
extern int fs_ivr_play_file2(switch_core_session_t *,char *);
extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
@@ -1000,6 +1000,7 @@ static PyObject *_wrap_fs_switch_ivr_record_file(PyObject *self, PyObject *args)
switch_input_callback_function_t arg4 ;
void *arg5 = (void *) 0 ;
unsigned int arg6 ;
unsigned int arg7 ;
int result;
switch_input_callback_function_t *argp4 ;
PyObject * obj0 = 0 ;
@@ -1007,8 +1008,9 @@ static PyObject *_wrap_fs_switch_ivr_record_file(PyObject *self, PyObject *args)
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
PyObject * obj5 = 0 ;
PyObject * obj6 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"OOsOOO:fs_switch_ivr_record_file",&obj0,&obj1,&arg3,&obj3,&obj4,&obj5)) goto fail;
if(!PyArg_ParseTuple(args,(char *)"OOsOOOO:fs_switch_ivr_record_file",&obj0,&obj1,&arg3,&obj3,&obj4,&obj5,&obj6)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_switch_core_session_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_switch_file_handle_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
if ((SWIG_ConvertPtr(obj3,(void **) &argp4, SWIGTYPE_p_switch_input_callback_function_t,SWIG_POINTER_EXCEPTION) == -1)) SWIG_fail;
@@ -1016,7 +1018,9 @@ static PyObject *_wrap_fs_switch_ivr_record_file(PyObject *self, PyObject *args)
if ((SWIG_ConvertPtr(obj4,(void **) &arg5, 0, SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
arg6 = (unsigned int) PyInt_AsLong(obj5);
if (PyErr_Occurred()) SWIG_fail;
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6);
arg7 = (unsigned int) PyInt_AsLong(obj6);
if (PyErr_Occurred()) SWIG_fail;
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
resultobj = PyInt_FromLong((long)result);
return resultobj;
@@ -628,7 +628,7 @@ extern void fs_channel_set_variable(switch_core_session_t *,char *,char *);
extern void fs_channel_get_variable(switch_core_session_t *,char *);
extern void fs_channel_set_state(switch_core_session_t *,char *);
extern int fs_ivr_play_file(switch_core_session_t *,char *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int);
extern int fs_switch_ivr_record_file(switch_core_session_t *,switch_file_handle_t *,char *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
extern int fs_switch_ivr_sleep(switch_core_session_t *,uint32_t);
extern int fs_ivr_play_file2(switch_core_session_t *,char *);
extern int fs_switch_ivr_collect_digits_callback(switch_core_session_t *,switch_input_callback_function_t,void *,unsigned int,unsigned int);
@@ -893,11 +893,12 @@ _wrap_fs_switch_ivr_record_file(int argc, VALUE *argv, VALUE self) {
switch_input_callback_function_t arg4 ;
void *arg5 = (void *) 0 ;
unsigned int arg6 ;
unsigned int arg7 ;
int result;
VALUE vresult = Qnil;
if ((argc < 6) || (argc > 6))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 6)",argc);
if ((argc < 7) || (argc > 7))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 7)",argc);
SWIG_ConvertPtr(argv[0], (void **) &arg1, SWIGTYPE_p_switch_core_session_t, 1);
SWIG_ConvertPtr(argv[1], (void **) &arg2, SWIGTYPE_p_switch_file_handle_t, 1);
arg3 = StringValuePtr(argv[2]);
@@ -908,7 +909,8 @@ _wrap_fs_switch_ivr_record_file(int argc, VALUE *argv, VALUE self) {
}
SWIG_ConvertPtr(argv[4], (void **) &arg5, 0, 1);
arg6 = NUM2UINT(argv[5]);
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6);
arg7 = NUM2UINT(argv[6]);
result = (int)fs_switch_ivr_record_file(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
vresult = INT2NUM(result);
return vresult;
@@ -831,6 +831,7 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
struct input_callback_state cb_state = {0};
switch_file_handle_t fh;
JSFunction *function;
int32 limit = 0;
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -857,12 +858,16 @@ static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval
bp = &cb_state;
len = sizeof(cb_state);
}
if (argc > 3) {
JS_ValueToInt32(cx, argv[4], &limit);
}
}
memset(&fh, 0, sizeof(fh));
cb_state.extra = &fh;
cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
switch_ivr_record_file(jss->session, &fh, file_name, dtmf_func, bp, len);
switch_ivr_record_file(jss->session, &fh, file_name, dtmf_func, bp, len, limit);
*rval = cb_state.ret;
return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;