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:
parent
fe376294fc
commit
d288ae58a8
|
@ -200,15 +200,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
\param dtmf_callback code to execute if any dtmf is dialed during the recording
|
||||
\param buf an object to maintain across calls
|
||||
\param buflen the size of buf
|
||||
\param limit max limit to record for (0 for infinite)
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
\note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop recording.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
uint32_t buflen);
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
uint32_t buflen,
|
||||
uint32_t limit);
|
||||
|
||||
/*!
|
||||
\brief Function to evaluate an expression against a string
|
||||
|
|
|
@ -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:
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -325,11 +325,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
|||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t input_callback,
|
||||
void *buf,
|
||||
uint32_t buflen)
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t input_callback,
|
||||
void *buf,
|
||||
uint32_t buflen,
|
||||
uint32_t limit)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
char dtmf[128];
|
||||
|
@ -340,6 +341,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
char *p;
|
||||
const char *vval;
|
||||
time_t start = 0;
|
||||
|
||||
if (!fh) {
|
||||
fh = &lfh;
|
||||
|
@ -422,17 +424,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (limit) {
|
||||
start = time(NULL);
|
||||
}
|
||||
|
||||
while(switch_channel_ready(channel)) {
|
||||
switch_size_t len;
|
||||
switch_event_t *event;
|
||||
|
||||
|
||||
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_ivr_parse_event(session, event);
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
if (start && (time(NULL) - start) > limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (input_callback || buf || buflen) {
|
||||
/*
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
|
|
|
@ -88,17 +88,17 @@ int fs_console_loop(void)
|
|||
|
||||
void fs_consol_log(char *level_str, char *msg)
|
||||
{
|
||||
switch_log_level_t level = SWITCH_LOG_DEBUG;
|
||||
if (level_str) {
|
||||
level = switch_log_str2level(level_str);
|
||||
switch_log_level_t level = SWITCH_LOG_DEBUG;
|
||||
if (level_str) {
|
||||
level = switch_log_str2level(level_str);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
|
||||
}
|
||||
|
||||
void fs_consol_clean(char *msg)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
|
||||
}
|
||||
|
||||
switch_core_session_t *fs_core_session_locate(char *uuid)
|
||||
|
@ -154,7 +154,7 @@ void fs_channel_set_state(switch_core_session_t *session, char *state)
|
|||
|
||||
|
||||
/*
|
||||
IVR Routines! You can do IVR in PHP NOW!
|
||||
IVR Routines! You can do IVR in PHP NOW!
|
||||
*/
|
||||
|
||||
int fs_ivr_play_file(switch_core_session_t *session,
|
||||
|
@ -174,20 +174,22 @@ int fs_ivr_play_file(switch_core_session_t *session,
|
|||
}
|
||||
|
||||
int fs_switch_ivr_record_file(switch_core_session_t *session,
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
unsigned int buflen,
|
||||
unsigned int limit
|
||||
)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_record_file(session, fh, file, dtmf_callback, buf, buflen);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
status = switch_ivr_record_file(session, fh, file, dtmf_callback, buf, buflen, limit);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_sleep(switch_core_session_t *session,
|
||||
uint32_t ms)
|
||||
uint32_t ms)
|
||||
{
|
||||
switch_status_t status;
|
||||
status = switch_ivr_sleep(session, ms);
|
||||
|
@ -211,98 +213,98 @@ int fs_switch_ivr_collect_digits_callback (switch_core_session_t *session,
|
|||
unsigned int buflen,
|
||||
unsigned int timeout)
|
||||
{
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_collect_digits_callback(session, dtmf_callback, buf, buflen, timeout);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
status = switch_ivr_collect_digits_callback(session, dtmf_callback, buf, buflen, timeout);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_collect_digits_count (switch_core_session_t *session,
|
||||
char *buf,
|
||||
unsigned int buflen,
|
||||
unsigned int maxdigits,
|
||||
const char *terminators,
|
||||
char *terminator,
|
||||
unsigned int timeout)
|
||||
char *buf,
|
||||
unsigned int buflen,
|
||||
unsigned int maxdigits,
|
||||
const char *terminators,
|
||||
char *terminator,
|
||||
unsigned int timeout)
|
||||
{
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_collect_digits_count(session, buf, buflen, maxdigits, terminators, terminator, timeout);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
status = switch_ivr_collect_digits_count(session, buf, buflen, maxdigits, terminators, terminator, timeout);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
/*int fs_switch_ivr_multi_threaded_bridge (switch_core_session_t *session,
|
||||
switch_core_session_t *peer_session,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *session_data,
|
||||
void *peer_session_data)
|
||||
{
|
||||
switch_status_t status;
|
||||
switch_core_session_t *peer_session,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *session_data,
|
||||
void *peer_session_data)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_multi_threaded_bridge(session, peer_session, dtmf_callback, session_data, peer_session_data);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
status = switch_ivr_multi_threaded_bridge(session, peer_session, dtmf_callback, session_data, peer_session_data);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
*/
|
||||
|
||||
int fs_switch_ivr_originate (switch_core_session_t *session,
|
||||
switch_core_session_t **bleg,
|
||||
char * bridgeto,
|
||||
uint32_t timelimit_sec)
|
||||
/*const switch_state_handler_table_t *table,
|
||||
char * cid_name_override,
|
||||
char * cid_num_override,
|
||||
switch_caller_profile_t *caller_profile_override) */
|
||||
switch_core_session_t **bleg,
|
||||
char * bridgeto,
|
||||
uint32_t timelimit_sec)
|
||||
/*const switch_state_handler_table_t *table,
|
||||
char * cid_name_override,
|
||||
char * cid_num_override,
|
||||
switch_caller_profile_t *caller_profile_override) */
|
||||
{
|
||||
|
||||
switch_channel_t *caller_channel;
|
||||
switch_core_session_t *peer_session;
|
||||
unsigned int timelimit = 60;
|
||||
char *var;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
switch_channel_t *caller_channel;
|
||||
switch_core_session_t *peer_session;
|
||||
unsigned int timelimit = 60;
|
||||
char *var;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
caller_channel = switch_core_session_get_channel(session);
|
||||
assert(caller_channel != NULL);
|
||||
caller_channel = switch_core_session_get_channel(session);
|
||||
assert(caller_channel != NULL);
|
||||
|
||||
if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
|
||||
timelimit = atoi(var);
|
||||
}
|
||||
if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
|
||||
timelimit = atoi(var);
|
||||
}
|
||||
|
||||
if (switch_ivr_originate(session, &peer_session, &cause, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
|
||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
|
||||
return;
|
||||
} else {
|
||||
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
|
||||
}
|
||||
if (switch_ivr_originate(session, &peer_session, &cause, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
|
||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
|
||||
return;
|
||||
} else {
|
||||
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int fs_switch_ivr_session_transfer(switch_core_session_t *session,
|
||||
char *extension,
|
||||
char *dialplan,
|
||||
char *context)
|
||||
char *extension,
|
||||
char *dialplan,
|
||||
char *context)
|
||||
{
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_session_transfer(session,extension,dialplan,context);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
status = switch_ivr_session_transfer(session,extension,dialplan,context);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_speak_text (switch_core_session_t *session,
|
||||
char *tts_name,
|
||||
char *voice_name,
|
||||
char *timer_name,
|
||||
uint32_t rate,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
char *text,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
char *tts_name,
|
||||
char *voice_name,
|
||||
char *timer_name,
|
||||
uint32_t rate,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
char *text,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_speak_text(session,tts_name,voice_name,timer_name,rate,dtmf_callback,text,buf,buflen);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
status = switch_ivr_speak_text(session,tts_name,voice_name,timer_name,rate,dtmf_callback,text,buf,buflen);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,10 +322,10 @@ char* fs_switch_channel_get_variable(switch_channel_t *channel, char *varname)
|
|||
|
||||
int fs_switch_channel_set_variable(switch_channel_t *channel, char *varname, char *value)
|
||||
{
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_channel_set_variable(channel, varname, value);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
status = switch_channel_set_variable(channel, varname, value);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
|
|
Loading…
Reference in New Issue