]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
MODENDP-259
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 5 Nov 2009 06:56:38 +0000 (06:56 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 5 Nov 2009 06:56:38 +0000 (06:56 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15368 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch_ivr_bridge.c
src/switch_ivr_originate.c

index 61dfd70b36e0c1095d646b9e38e72af3c1672bbc..99b699e63ab9b642442825397284a06c27538b05 100644 (file)
@@ -929,6 +929,7 @@ typedef enum {
        CF_NOT_READY,
        CF_SIGNAL_BRIDGE_TTL,
        CF_MEDIA_BRIDGE_TTL,
+       CF_HANGUP_AFTER_BRIDGE,
        /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
        CF_FLAG_MAX
 } switch_channel_flag_t;
index 9c58b1a51170004d7de11a1967773bf15b12ad3b..9c8a98dcdb14ec39cef4ef91a4fc75fdf872b11d 100644 (file)
@@ -793,7 +793,10 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session)
             switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
                        
             if (switch_channel_up(other_channel)) {
-                               
+                               if (switch_channel_test_flag(other_channel, CF_HANGUP_AFTER_BRIDGE)) {
+                                       switch_channel_hangup(other_channel, switch_channel_get_cause(channel));        
+                               }
+
                                if (switch_true(switch_channel_get_variable(other_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
                                        switch_ivr_park_session(other_session);
                                } else if ((var = switch_channel_get_variable(other_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
@@ -1123,6 +1126,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
                !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !a_leg->clean_exit && !inner_bridge) {
                if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
                        (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) {
+
+                       if (switch_channel_test_flag(caller_channel, CF_HANGUP_AFTER_BRIDGE)) {
+                               switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));  
+                       }
+
                        if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
                                switch_ivr_park_session(session);
                        } else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
index f824135e3286f103eb11828e2b424c5cb13085cb..78326baef0afc3ccef950fb218af0c7bcb4ef23a 100644 (file)
@@ -2089,7 +2089,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                goto notready;
                                        }
                                }
-                               
+
                                /* read from the channel while we wait if the audio is up on it */
                                if (oglobals.session &&
                                        !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
@@ -2281,7 +2281,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        const char *context = NULL;
                                        const char *dialplan = NULL;
                                        switch_core_session_t *holding_session;
-                                       
+
                                        if (caller_channel) {
                                                if (zstr(context)) {
                                                        context = switch_channel_get_variable(caller_channel, "context"); 
@@ -2302,7 +2302,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        if ((holding_session = switch_core_session_locate(holding))) {
                                                switch_channel_t *holding_channel = switch_core_session_get_channel(holding_session);
                                                switch_status_t mstatus = SWITCH_STATUS_FALSE;
-                                               
+
                                                if (caller_channel) {
                                                        if ((mstatus = switch_channel_caller_extension_masquerade(caller_channel, holding_channel, 1)) == SWITCH_STATUS_SUCCESS) {
                                                                switch_channel_restart(holding_channel);
@@ -2333,9 +2333,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        }
                                        force_reason = SWITCH_CAUSE_ATTENDED_TRANSFER;
                                } else {
+
                                        if (peer_channel && switch_channel_ready(peer_channel)) {
+                                               switch_core_session_t *holding_session;
+
                                                force_reason = SWITCH_CAUSE_ATTENDED_TRANSFER;
+
+                                               if ((holding_session = switch_core_session_locate(holding))) {
+                                                       switch_channel_set_flag(switch_core_session_get_channel(holding_session), CF_HANGUP_AFTER_BRIDGE);
+                                                       switch_core_session_rwunlock(holding_session);
+                                               }
+                                               
                                                switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(peer_session));
+                                               holding = NULL;
                                                oglobals.idx = IDX_NADA;
                                                if (caller_channel && switch_channel_up(caller_channel)) {
                                                        switch_channel_hangup(caller_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
@@ -2349,8 +2359,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
                                                if ((holding_session = switch_core_session_locate(holding))) {
                                                        switch_channel_t *holding_channel = switch_core_session_get_channel(holding_session);
+
                                                        if (caller_channel && switch_channel_ready(caller_channel)) {
                                                                switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(session));
+                                                               holding = NULL;
                                                        } else {
                                                                switch_channel_hangup(holding_channel, SWITCH_CAUSE_NORMAL_UNSPECIFIED);
                                                        }
@@ -2361,7 +2373,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
                                peer_session = NULL;
                                peer_channel = NULL;
-                               
                        }
                        
                        for (i = 0; i < and_argc; i++) {