From a03f9621748aa60685aa2b2a1d9183c07842f856 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 16 Feb 2007 21:32:49 +0000 Subject: [PATCH] add callbacks to park git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4300 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_ivr.h | 2 +- src/mod/applications/mod_park/mod_park.c | 2 +- src/switch_ivr.c | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 1266eb5706..10cf6dd74a 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -77,7 +77,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se */ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms); -SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args); /*! \brief Wait for DTMF digits calling a pluggable callback function when digits are collected. diff --git a/src/mod/applications/mod_park/mod_park.c b/src/mod/applications/mod_park/mod_park.c index 4903fefd27..4aadd7ed4d 100644 --- a/src/mod/applications/mod_park/mod_park.c +++ b/src/mod/applications/mod_park/mod_park.c @@ -34,7 +34,7 @@ static const char modname[] = "mod_park"; static void park_function(switch_core_session_t *session, char *data) { - switch_ivr_park(session); + switch_ivr_park(session, NULL); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index e55a469a66..9bff5e0894 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -143,7 +143,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se } -SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session) +SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args) { switch_status_t status = SWITCH_STATUS_SUCCESS; switch_channel_t *channel; @@ -177,11 +177,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session) if (switch_channel_has_dtmf(channel)) { char dtmf[128]; switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf)); + if (args && args->input_callback) { + if ((status = args->input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) { + break; + } + } } if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(channel, event); - switch_event_fire(&event); + if (args && args->input_callback) { + if ((status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) { + break; + } + } else { + switch_channel_event_set_data(channel, event); + switch_event_fire(&event); + } } }