]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add origination_cancel_key variable for a dtmf key that can abort an originating...
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 26 Aug 2009 19:49:35 +0000 (19:49 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 26 Aug 2009 19:49:35 +0000 (19:49 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14645 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr_originate.c

index ed9fc490f78391eaf3159e9b7c6666a4f7b318bc..1893f8b4561d8d2d411060bbe823b819af7f28d9 100644 (file)
@@ -618,6 +618,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
        int timelimit = 60;
        const char *var;
        switch_time_t start = 0;
+       const char *cancel_key = NULL;
 
        switch_assert(peer_channel);
        
@@ -643,6 +644,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
        start = switch_micro_time_now();
 
        if (caller_channel) {
+               cancel_key = switch_channel_get_variable(caller_channel, "origination_cancel_key");
+
                if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
                        ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
                }
@@ -758,6 +761,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
                   && !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
                int diff = (int) (switch_micro_time_now() - start);
 
+               if (caller_channel && cancel_key) {
+                       if (switch_channel_has_dtmf(caller_channel)) {
+                               switch_dtmf_t dtmf = { 0, 0 };
+                               if (switch_channel_dequeue_dtmf(caller_channel, &dtmf) == SWITCH_STATUS_SUCCESS) {
+                                       if (dtmf.digit == *cancel_key) {
+                                               status = SWITCH_STATUS_FALSE;
+                                               goto done;
+                                       }
+                               }
+                       }
+               }
+
                if (diff > timelimit) {
                        status = SWITCH_STATUS_TIMEOUT;
                        goto done;
@@ -929,7 +944,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
        originate_global_t oglobals = { 0 };
        int cdr_total = 0;
        int local_clobber = 0;
-       
+       const char *cancel_key = NULL;
+
        oglobals.idx = IDX_NADA;
        oglobals.early_ok = 1;
        oglobals.session = session;
@@ -1103,6 +1119,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
        if (caller_channel) {           /* ringback is only useful when there is an originator */
                ringback_data = NULL;
+               cancel_key = switch_channel_get_variable(caller_channel, "origination_cancel_key");
 
                if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
                        ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
@@ -1871,6 +1888,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        switch_status_t tstatus = SWITCH_STATUS_SUCCESS;
                                        int silence = 0;
 
+                                       if (caller_channel && cancel_key) {
+                                               if (switch_channel_has_dtmf(caller_channel)) {
+                                                       switch_dtmf_t dtmf = { 0, 0 };
+                                                       if (switch_channel_dequeue_dtmf(caller_channel, &dtmf) == SWITCH_STATUS_SUCCESS) {
+                                                               if (dtmf.digit == *cancel_key) {
+                                                                       oglobals.idx = IDX_TIMEOUT;
+                                                                       goto notready;
+                                                               }
+                                                       }
+                                               }
+                                       }
+
                                        if (switch_channel_media_ready(caller_channel)) {
                                                tstatus = switch_core_session_read_frame(oglobals.session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
                                                if (!SWITCH_READ_ACCEPTABLE(tstatus)) {