diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 56a0a0f48b..28af6b1f17 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -275,9 +275,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_inband_dtmf_generate_session(swi /*! \brief - NEEDDESC - \param session the session to act on - \return SWITCH_STATUS_SUCCESS if all is well - maybe more XXX FIXME */ -SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session); +SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session, switch_input_args_t *args); /*! \brief Stop looking for TONES diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 51e6085566..4fdae5e528 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1238,7 +1238,7 @@ SWITCH_STANDARD_APP(stop_fax_detect_session_function) SWITCH_STANDARD_APP(echo_function) { - switch_ivr_session_echo(session); + switch_ivr_session_echo(session, NULL); } SWITCH_STANDARD_APP(park_function) diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index ea6af4bde7..89b3e56d4a 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -37,20 +37,20 @@ static void switch_core_standard_on_init(switch_core_session_t *session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard INIT %s\n", switch_channel_get_name(session->channel)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard INIT\n", switch_channel_get_name(session->channel)); } static void switch_core_standard_on_hangup(switch_core_session_t *session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HANGUP %s, cause: %s\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard HANGUP, cause: %s\n", switch_channel_get_name(session->channel), switch_channel_cause2str(switch_channel_get_cause(session->channel))); } static void switch_core_standard_on_reset(switch_core_session_t *session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard RESET %s\n", switch_channel_get_name(session->channel)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard RESET\n", switch_channel_get_name(session->channel)); } static void switch_core_standard_on_routing(switch_core_session_t *session) @@ -61,7 +61,7 @@ static void switch_core_standard_on_routing(switch_core_session_t *session) char *expanded = NULL; char *dpstr = NULL; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard ROUTING %s\n", switch_channel_get_name(session->channel)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard ROUTING\n", switch_channel_get_name(session->channel)); if ((caller_profile = switch_channel_get_caller_profile(session->channel)) == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't get profile!\n"); @@ -126,7 +126,7 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) { switch_caller_extension_t *extension; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard EXECUTE\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard EXECUTE\n", switch_channel_get_name(session->channel)); top: switch_channel_clear_flag(session->channel, CF_RESET); @@ -164,20 +164,19 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) static void switch_core_standard_on_exchange_media(switch_core_session_t *session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard LOOPBACK\n"); - switch_ivr_session_echo(session); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard EXCHANGE_MEDIA\n", switch_channel_get_name(session->channel)); } static void switch_core_standard_on_soft_execute(switch_core_session_t *session) { switch_assert(session != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard TRANSMIT\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard SOFT_EXECUTE\n", switch_channel_get_name(session->channel)); } static void switch_core_standard_on_park(switch_core_session_t *session) { switch_assert(session != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard PARK\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard PARK\n", switch_channel_get_name(session->channel)); switch_channel_clear_flag(session->channel, CF_TRANSFER); switch_core_session_reset(session, SWITCH_TRUE); switch_ivr_park(session, NULL); @@ -186,13 +185,13 @@ static void switch_core_standard_on_park(switch_core_session_t *session) static void switch_core_standard_on_consume_media(switch_core_session_t *session) { switch_assert(session != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HOLD\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard CONSUME_MEDIA\n", switch_channel_get_name(session->channel)); } static void switch_core_standard_on_hibernate(switch_core_session_t *session) { switch_assert(session != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard HIBERNATE\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard HIBERNATE\n", switch_channel_get_name(session->channel)); } #include diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index c98a8e88df..7381066a71 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -67,7 +67,7 @@ static void *SWITCH_THREAD_FUNC echo_video_thread(switch_thread_t *thread, void } #endif -SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session) +SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session, switch_input_args_t *args) { switch_status_t status; switch_frame_t *read_frame; @@ -95,6 +95,47 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session) if (!SWITCH_READ_ACCEPTABLE(status)) { break; } + + if (switch_core_session_private_event_count(session)) { + switch_ivr_parse_all_events(session); + } + + 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; + } + } + + switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0); #ifndef SWITCH_VIDEO_IN_THREADS diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 9df133254b..3291c7ca37 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -657,6 +657,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi break; } + if (switch_core_session_private_event_count(session)) { + switch_ivr_parse_all_events(session); + } + if (args && (args->input_callback || args->buf || args->buflen)) { /* dtmf handler function you can hook up to be executed when a digit is dialed during gentones