From 4cb49fbaa09b865d01ae8b0dd86954327d63dec7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 13 Sep 2011 16:19:00 -0500 Subject: [PATCH] fix some minor internal dtmf issues --- .../applications/mod_dptools/mod_dptools.c | 7 +-- src/switch_channel.c | 29 ++++++------ src/switch_core_io.c | 45 ++++++++++--------- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index c8366f05c8..1c8fe1262e 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -110,7 +110,6 @@ static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t { switch_core_session_t *session = (switch_core_session_t *) match->user_data; switch_channel_t *channel; - char str[DMACHINE_MAX_DIGIT_LEN + 2]; switch_event_t *event; switch_status_t status; switch_core_session_t *use_session = session; @@ -139,10 +138,8 @@ static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t } } - /* send it back around flagged to skip the dmachine */ - switch_snprintf(str, sizeof(str), "!%s", match->match_digits); - - switch_channel_queue_dtmf_string(channel, str); + /* send it back around and skip the dmachine */ + switch_channel_queue_dtmf_string(channel, match->match_digits); if (use_session != session) { switch_core_session_rwunlock(use_session); diff --git a/src/switch_channel.c b/src/switch_channel.c index 5650b1ef3b..2055e8fc07 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -430,9 +430,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_ return SWITCH_STATUS_FALSE; } - if (*dtmf_string == '!') { + + dtmf.flags = DTMF_FLAG_SKIP_PROCESS; + + if (*dtmf_string == '~') { dtmf_string++; - dtmf.flags = DTMF_FLAG_SKIP_PROCESS; + dtmf.flags = 0; } string = switch_core_session_strdup(channel->session, dtmf_string); @@ -448,20 +451,20 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_ } } - if (dtmf.duration > switch_core_max_dtmf_duration(0)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "EXCESSIVE DTMF DIGIT LEN %c %d\n", dtmf.digit, dtmf.duration); - dtmf.duration = switch_core_max_dtmf_duration(0); - } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "SHORT DTMF DIGIT LEN %c %d\n", dtmf.digit, dtmf.duration); - dtmf.duration = switch_core_min_dtmf_duration(0); - } else if (!dtmf.duration) { - dtmf.duration = switch_core_default_dtmf_duration(0); - } - - for (p = argv[i]; p && *p; p++) { if (is_dtmf(*p)) { dtmf.digit = *p; + + if (dtmf.duration > switch_core_max_dtmf_duration(0)) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "EXCESSIVE DTMF DIGIT LEN %c %d\n", dtmf.digit, dtmf.duration); + dtmf.duration = switch_core_max_dtmf_duration(0); + } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "SHORT DTMF DIGIT LEN %c %d\n", dtmf.digit, dtmf.duration); + dtmf.duration = switch_core_min_dtmf_duration(0); + } else if (!dtmf.duration) { + dtmf.duration = switch_core_default_dtmf_duration(0); + } + if (switch_channel_queue_dtmf(channel, &dtmf) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s Queue dtmf\ndigit=%c ms=%u samples=%u\n", switch_channel_get_name(channel), dtmf.digit, dur, dtmf.duration); diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 587218339a..a36d55776b 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -1354,14 +1354,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio new_dtmf.duration = switch_core_default_dtmf_duration(0); } - - for (ptr = session->event_hooks.send_dtmf; ptr; ptr = ptr->next) { - if ((status = ptr->send_dtmf(session, dtmf, SWITCH_DTMF_SEND)) != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_SUCCESS; - } - } - if (!switch_test_flag(dtmf, DTMF_FLAG_SKIP_PROCESS)) { + if (!switch_test_flag(dtmf, DTMF_FLAG_SKIP_PROCESS)) { + for (ptr = session->event_hooks.send_dtmf; ptr; ptr = ptr->next) { + if ((status = ptr->send_dtmf(session, dtmf, SWITCH_DTMF_SEND)) != SWITCH_STATUS_SUCCESS) { + return SWITCH_STATUS_SUCCESS; + } + } + if (session->dmachine[1] && !switch_channel_test_flag(session->channel, CF_BROADCAST)) { char str[2] = { new_dtmf.digit, '\0' }; switch_ivr_dmachine_feed(session->dmachine[1], str, NULL); @@ -1396,7 +1396,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string) { char *p; - switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) }; + switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0), DTMF_FLAG_SKIP_PROCESS, 0}; int sent = 0, dur; char *string; int i, argc; @@ -1405,6 +1405,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core switch_assert(session != NULL); + if (*dtmf_string == '~') { + dtmf_string++; + dtmf.flags = 0; + } if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; @@ -1437,21 +1441,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core } - if (dtmf.duration > switch_core_max_dtmf_duration(0)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n", - switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration); - dtmf.duration = switch_core_max_dtmf_duration(0); - } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n", - switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration); - dtmf.duration = switch_core_min_dtmf_duration(0); - } else if (!dtmf.duration) { - dtmf.duration = switch_core_default_dtmf_duration(0); - } - for (p = argv[i]; p && *p; p++) { if (is_dtmf(*p)) { dtmf.digit = *p; + + if (dtmf.duration > switch_core_max_dtmf_duration(0)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n", + switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration); + dtmf.duration = switch_core_max_dtmf_duration(0); + } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n", + switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration); + dtmf.duration = switch_core_min_dtmf_duration(0); + } else if (!dtmf.duration) { + dtmf.duration = switch_core_default_dtmf_duration(0); + } + if (switch_core_session_send_dtmf(session, &dtmf) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n", switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);