add args to sleep

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8930 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-07-08 17:27:02 +00:00
parent d53d96fd73
commit 32bbdb74a8
18 changed files with 294 additions and 16 deletions

View File

@ -276,6 +276,7 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
* *
*/ */
SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0); SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0);
SWITCH_DECLARE(int) sleep(char *file, int ms);
/** \brief flush any pending events /** \brief flush any pending events
*/ */

View File

@ -107,9 +107,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_event(switch_core_session_
\brief Wait for time to pass for a specified number of milliseconds \brief Wait for time to pass for a specified number of milliseconds
\param session the session to wait for. \param session the session to wait for.
\param ms the number of milliseconds \param ms the number of milliseconds
\param args arguements to pass for callbacks etc
\return SWITCH_STATUS_SUCCESS if the channel is still up \return SWITCH_STATUS_SUCCESS if the channel is still up
*/ */
SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms); SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_input_args_t *args);
SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args); SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args);

View File

@ -586,16 +586,6 @@ SWITCH_STANDARD_APP(sched_broadcast_function)
} }
} }
SWITCH_STANDARD_APP(sleep_function)
{
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No timeout specified.\n");
} else {
uint32_t ms = atoi(data);
switch_ivr_sleep(session, ms);
}
}
SWITCH_STANDARD_APP(delay_function) SWITCH_STANDARD_APP(delay_function)
{ {
uint32_t len = 0; uint32_t len = 0;
@ -1323,6 +1313,26 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_APP(sleep_function)
{
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No timeout specified.\n");
} else {
uint32_t ms = atoi(data);
char buf[10];
switch_input_args_t args = { 0 };
args.input_callback = on_dtmf;
args.buf = buf;
args.buflen = sizeof(buf);
switch_ivr_sleep(session, ms, &args);
}
}
SWITCH_STANDARD_APP(clear_speech_cache_function) SWITCH_STANDARD_APP(clear_speech_cache_function)
{ {
switch_ivr_clear_speech_cache(session); switch_ivr_clear_speech_cache(session);

View File

@ -855,7 +855,7 @@ SWITCH_STANDARD_APP(fifo_function)
if (announce) { if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL); switch_ivr_play_file(session, NULL, announce, NULL);
} else { } else {
switch_ivr_sleep(session, 500); switch_ivr_sleep(session, 500, NULL);
} }

View File

@ -1314,7 +1314,7 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
status = switch_ivr_phrase_macro(session, VM_HELLO_MACRO, NULL, NULL, &args); status = switch_ivr_phrase_macro(session, VM_HELLO_MACRO, NULL, NULL, &args);
while (switch_channel_ready(channel)) { while (switch_channel_ready(channel)) {
switch_ivr_sleep(session, 100); switch_ivr_sleep(session, 100, NULL);
switch (vm_check_state) { switch (vm_check_state) {
case VM_CHECK_START: case VM_CHECK_START:

View File

@ -209,6 +209,10 @@ public class CoreSession {
return freeswitchJNI.CoreSession_streamFile__SWIG_1(swigCPtr, this, file); return freeswitchJNI.CoreSession_streamFile__SWIG_1(swigCPtr, this, file);
} }
public int sleep(String file, int ms) {
return freeswitchJNI.CoreSession_sleep(swigCPtr, this, file, ms);
}
public int flushEvents() { public int flushEvents() {
return freeswitchJNI.CoreSession_flushEvents(swigCPtr, this); return freeswitchJNI.CoreSession_flushEvents(swigCPtr, this);
} }

View File

@ -120,6 +120,7 @@ class freeswitchJNI {
public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9); public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3); public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2); public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
public final static native int CoreSession_sleep(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_); public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_flushDigits(long jarg1, CoreSession jarg1_); public final static native int CoreSession_flushDigits(long jarg1, CoreSession jarg1_);
public final static native int CoreSession_setAutoHangup(long jarg1, CoreSession jarg1_, boolean jarg2); public final static native int CoreSession_setAutoHangup(long jarg1, CoreSession jarg1_, boolean jarg2);

View File

@ -2376,6 +2376,30 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1stre
} }
SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1sleep(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
jint jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
char *arg2 = (char *) 0 ;
int arg3 ;
int result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(CoreSession **)&jarg1;
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return 0;
}
arg3 = (int)jarg3;
result = (int)(arg1)->sleep(arg2,arg3);
jresult = (jint)result;
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
return jresult;
}
SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1flushEvents(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1flushEvents(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jint jresult = 0 ; jint jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ; CoreSession *arg1 = (CoreSession *) 0 ;

View File

@ -5476,6 +5476,37 @@ static int _wrap_CoreSession_streamFile(lua_State* L) {
} }
static int _wrap_CoreSession_sleep(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
char *arg2 = (char *) 0 ;
int arg3 ;
int result;
SWIG_check_num_args("sleep",3,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("sleep",1,"CoreSession *");
if(!lua_isstring(L,2)) SWIG_fail_arg("sleep",2,"char *");
if(!lua_isnumber(L,3)) SWIG_fail_arg("sleep",3,"int");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
SWIG_fail_ptr("CoreSession_sleep",1,SWIGTYPE_p_CoreSession);
}
arg2 = (char *)lua_tostring(L, 2);
arg3 = (int)lua_tonumber(L, 3);
result = (int)(arg1)->sleep(arg2,arg3);
SWIG_arg=0;
lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_CoreSession_flushEvents(lua_State* L) { static int _wrap_CoreSession_flushEvents(lua_State* L) {
int SWIG_arg = -1; int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ; CoreSession *arg1 = (CoreSession *) 0 ;
@ -6081,6 +6112,7 @@ static swig_lua_method swig_CoreSession_methods[] = {
{"read", _wrap_CoreSession_read}, {"read", _wrap_CoreSession_read},
{"playAndGetDigits", _wrap_CoreSession_playAndGetDigits}, {"playAndGetDigits", _wrap_CoreSession_playAndGetDigits},
{"streamFile", _wrap_CoreSession_streamFile}, {"streamFile", _wrap_CoreSession_streamFile},
{"sleep", _wrap_CoreSession_sleep},
{"flushEvents", _wrap_CoreSession_flushEvents}, {"flushEvents", _wrap_CoreSession_flushEvents},
{"flushDigits", _wrap_CoreSession_flushDigits}, {"flushDigits", _wrap_CoreSession_flushDigits},
{"setAutoHangup", _wrap_CoreSession_setAutoHangup}, {"setAutoHangup", _wrap_CoreSession_setAutoHangup},

View File

@ -372,6 +372,7 @@ sub DESTROY {
*read = *freeswitchc::CoreSession_read; *read = *freeswitchc::CoreSession_read;
*playAndGetDigits = *freeswitchc::CoreSession_playAndGetDigits; *playAndGetDigits = *freeswitchc::CoreSession_playAndGetDigits;
*streamFile = *freeswitchc::CoreSession_streamFile; *streamFile = *freeswitchc::CoreSession_streamFile;
*sleep = *freeswitchc::CoreSession_sleep;
*flushEvents = *freeswitchc::CoreSession_flushEvents; *flushEvents = *freeswitchc::CoreSession_flushEvents;
*flushDigits = *freeswitchc::CoreSession_flushDigits; *flushDigits = *freeswitchc::CoreSession_flushDigits;
*setAutoHangup = *freeswitchc::CoreSession_setAutoHangup; *setAutoHangup = *freeswitchc::CoreSession_setAutoHangup;

View File

@ -7312,6 +7312,55 @@ XS(_wrap_CoreSession_streamFile) {
} }
XS(_wrap_CoreSession_sleep) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
char *arg2 = (char *) 0 ;
int arg3 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
char *buf2 = 0 ;
int alloc2 = 0 ;
int val3 ;
int ecode3 = 0 ;
int argvi = 0;
dXSARGS;
if ((items < 3) || (items > 3)) {
SWIG_croak("Usage: CoreSession_sleep(self,file,ms);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_sleep" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_sleep" "', argument " "2"" of type '" "char *""'");
}
arg2 = reinterpret_cast< char * >(buf2);
ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_sleep" "', argument " "3"" of type '" "int""'");
}
arg3 = static_cast< int >(val3);
result = (int)(arg1)->sleep(arg2,arg3);
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
XSRETURN(argvi);
fail:
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
SWIG_croak_null();
}
}
XS(_wrap_CoreSession_flushEvents) { XS(_wrap_CoreSession_flushEvents) {
{ {
CoreSession *arg1 = (CoreSession *) 0 ; CoreSession *arg1 = (CoreSession *) 0 ;
@ -9331,6 +9380,7 @@ static swig_command_info swig_commands[] = {
{"freeswitchc::CoreSession_read", _wrap_CoreSession_read}, {"freeswitchc::CoreSession_read", _wrap_CoreSession_read},
{"freeswitchc::CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits}, {"freeswitchc::CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits},
{"freeswitchc::CoreSession_streamFile", _wrap_CoreSession_streamFile}, {"freeswitchc::CoreSession_streamFile", _wrap_CoreSession_streamFile},
{"freeswitchc::CoreSession_sleep", _wrap_CoreSession_sleep},
{"freeswitchc::CoreSession_flushEvents", _wrap_CoreSession_flushEvents}, {"freeswitchc::CoreSession_flushEvents", _wrap_CoreSession_flushEvents},
{"freeswitchc::CoreSession_flushDigits", _wrap_CoreSession_flushDigits}, {"freeswitchc::CoreSession_flushDigits", _wrap_CoreSession_flushDigits},
{"freeswitchc::CoreSession_setAutoHangup", _wrap_CoreSession_setAutoHangup}, {"freeswitchc::CoreSession_setAutoHangup", _wrap_CoreSession_setAutoHangup},

View File

@ -247,6 +247,7 @@ class CoreSession(_object):
def read(*args): return _freeswitch.CoreSession_read(*args) def read(*args): return _freeswitch.CoreSession_read(*args)
def playAndGetDigits(*args): return _freeswitch.CoreSession_playAndGetDigits(*args) def playAndGetDigits(*args): return _freeswitch.CoreSession_playAndGetDigits(*args)
def streamFile(*args): return _freeswitch.CoreSession_streamFile(*args) def streamFile(*args): return _freeswitch.CoreSession_streamFile(*args)
def sleep(*args): return _freeswitch.CoreSession_sleep(*args)
def flushEvents(*args): return _freeswitch.CoreSession_flushEvents(*args) def flushEvents(*args): return _freeswitch.CoreSession_flushEvents(*args)
def flushDigits(*args): return _freeswitch.CoreSession_flushDigits(*args) def flushDigits(*args): return _freeswitch.CoreSession_flushDigits(*args)
def setAutoHangup(*args): return _freeswitch.CoreSession_setAutoHangup(*args) def setAutoHangup(*args): return _freeswitch.CoreSession_setAutoHangup(*args)

View File

@ -7354,6 +7354,49 @@ fail:
} }
SWIGINTERN PyObject *_wrap_CoreSession_sleep(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
char *arg2 = (char *) 0 ;
int arg3 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
char *buf2 = 0 ;
int alloc2 = 0 ;
int val3 ;
int ecode3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_sleep",&obj0,&obj1,&obj2)) 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_sleep" "', 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_sleep" "', argument " "2"" of type '" "char *""'");
}
arg2 = reinterpret_cast< char * >(buf2);
ecode3 = SWIG_AsVal_int(obj2, &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_sleep" "', argument " "3"" of type '" "int""'");
}
arg3 = static_cast< int >(val3);
result = (int)(arg1)->sleep(arg2,arg3);
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_flushEvents(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { SWIGINTERN PyObject *_wrap_CoreSession_flushEvents(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0; PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ; CoreSession *arg1 = (CoreSession *) 0 ;
@ -8540,6 +8583,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"CoreSession_read", _wrap_CoreSession_read, METH_VARARGS, NULL}, { (char *)"CoreSession_read", _wrap_CoreSession_read, METH_VARARGS, NULL},
{ (char *)"CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits, METH_VARARGS, NULL}, { (char *)"CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits, METH_VARARGS, NULL},
{ (char *)"CoreSession_streamFile", _wrap_CoreSession_streamFile, METH_VARARGS, NULL}, { (char *)"CoreSession_streamFile", _wrap_CoreSession_streamFile, METH_VARARGS, NULL},
{ (char *)"CoreSession_sleep", _wrap_CoreSession_sleep, METH_VARARGS, NULL},
{ (char *)"CoreSession_flushEvents", _wrap_CoreSession_flushEvents, METH_VARARGS, NULL}, { (char *)"CoreSession_flushEvents", _wrap_CoreSession_flushEvents, METH_VARARGS, NULL},
{ (char *)"CoreSession_flushDigits", _wrap_CoreSession_flushDigits, METH_VARARGS, NULL}, { (char *)"CoreSession_flushDigits", _wrap_CoreSession_flushDigits, METH_VARARGS, NULL},
{ (char *)"CoreSession_setAutoHangup", _wrap_CoreSession_setAutoHangup, METH_VARARGS, NULL}, { (char *)"CoreSession_setAutoHangup", _wrap_CoreSession_setAutoHangup, METH_VARARGS, NULL},

View File

@ -1689,6 +1689,64 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv
return JS_TRUE; return JS_TRUE;
} }
static JSBool session_sleep(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
void *bp = NULL;
int len = 0;
switch_input_callback_function_t dtmf_func = NULL;
struct input_callback_state cb_state = { 0 };
JSFunction *function;
switch_input_args_t args = { 0 };
int32 ms;
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
CHANNEL_SANITY_CHECK();
CHANNEL_MEDIA_SANITY_CHECK();
if (argc > 0) {
JS_ValueToInt32(cx, argv[0], &ms);
if (ms <= 0) {
return JS_FALSE;
}
}
if (argc > 1) {
if ((function = JS_ValueToFunction(cx, argv[1]))) {
memset(&cb_state, 0, sizeof(cb_state));
cb_state.function = function;
if (argc > 2) {
cb_state.arg = argv[2];
}
cb_state.session_state = jss;
cb_state.cx = cx;
cb_state.obj = obj;
dtmf_func = js_stream_input_callback;
bp = &cb_state;
len = sizeof(cb_state);
}
}
cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
cb_state.saveDepth = JS_SuspendRequest(cx);
args.input_callback = dtmf_func;
args.buf = bp;
args.buflen = len;
check_hangup_hook(jss);
switch_ivr_sleep(jss->session, ms, &args);
check_hangup_hook(jss);
JS_ResumeRequest(cx, cb_state.saveDepth);
*rval = cb_state.ret;
return JS_TRUE;
}
static JSBool session_set_variable(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) static JSBool session_set_variable(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{ {
struct js_session *jss = JS_GetPrivate(cx, obj); struct js_session *jss = JS_GetPrivate(cx, obj);
@ -2488,6 +2546,7 @@ static JSFunctionSpec session_methods[] = {
{"sendEvent", session_send_event, 0}, {"sendEvent", session_send_event, 0},
{"hangup", session_hangup, 0}, {"hangup", session_hangup, 0},
{"execute", session_execute, 0}, {"execute", session_execute, 0},
{"sleep", session_sleep, 1},
{0} {0}
}; };

View File

@ -804,6 +804,21 @@ SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_coun
} }
SWITCH_DECLARE(int) CoreSession::sleep(char *file, int ms) {
switch_status_t status;
this_check(-1);
sanity_check(-1);
begin_allow_threads();
status = switch_ivr_sleep(session, ms, ap);
end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
SWITCH_DECLARE(bool) CoreSession::ready() { SWITCH_DECLARE(bool) CoreSession::ready() {
this_check(false); this_check(false);

View File

@ -38,7 +38,7 @@
#include <switch_ivr.h> #include <switch_ivr.h>
#include "stfu.h" #include "stfu.h"
SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms) SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_input_args_t *args)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
@ -60,6 +60,41 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
break; break;
} }
if (args && (args->input_callback || args->buf || args->buflen)) {
switch_dtmf_t dtmf;
/*
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
if (switch_channel_has_dtmf(channel)) {
if (!args->input_callback && !args->buf) {
status = SWITCH_STATUS_BREAK;
break;
}
switch_channel_dequeue_dtmf(channel, &dtmf);
if (args->input_callback) {
status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
} else {
switch_copy_string((char *) args->buf, (void *) &dtmf, args->buflen);
status = SWITCH_STATUS_BREAK;
}
}
if (args->input_callback) {
switch_event_t *event = NULL;
if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen);
switch_event_destroy(&event);
}
}
if (status != SWITCH_STATUS_SUCCESS) {
break;
}
}
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
switch_yield(1000); switch_yield(1000);
continue; continue;

View File

@ -501,7 +501,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
} }
errs++; errs++;
if (status == SWITCH_STATUS_SUCCESS) { if (status == SWITCH_STATUS_SUCCESS) {
status = switch_ivr_sleep(session, 1000); status = switch_ivr_sleep(session, 1000, NULL);
} }
/* breaks are ok too */ /* breaks are ok too */
if (SWITCH_STATUS_IS_BREAK(status)) { if (SWITCH_STATUS_IS_BREAK(status)) {

View File

@ -40,7 +40,7 @@ static switch_status_t originate_on_consume_media_transmit(switch_core_session_t
if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) { if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) {
while (switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) { while (switch_channel_get_state(channel) == CS_CONSUME_MEDIA && !switch_channel_test_flag(channel, CF_TAGGED)) {
switch_ivr_sleep(session, 10); switch_ivr_sleep(session, 10, NULL);
} }
} }