fix some minor internal dtmf issues

This commit is contained in:
Anthony Minessale 2011-09-13 16:19:00 -05:00
parent 637a5ed83d
commit 4cb49fbaa0
3 changed files with 43 additions and 38 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);