]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix some minor internal dtmf issues
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 13 Sep 2011 21:19:00 +0000 (16:19 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 13 Sep 2011 21:19:00 +0000 (16:19 -0500)
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_channel.c
src/switch_core_io.c

index c8366f05c832fc2ce44f17b120299829fa996edf..1c8fe1262e01a74b21b5a21e77fe0f2ff0a12673 100755 (executable)
@@ -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);
index 5650b1ef3b7ba483754fe1b7b33763bff4caab22..2055e8fc076680a6c43b204db68b00a0ff0449da 100644 (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);
index 587218339ae245f1e51f1448efe8cf80fad68a37..a36d55776b43ff6a72945fc2b1dd92201d9e45f2 100644 (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)) {  
+               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 (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);