diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 126f722ce2..5805d5d039 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -215,7 +215,9 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_LOCAL_VIDEO_PORT_VARIABLE "local_video_port" #define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE "hangup_after_bridge" #define SWITCH_PARK_AFTER_BRIDGE_VARIABLE "park_after_bridge" +#define SWITCH_PARK_AFTER_EARLY_BRIDGE_VARIABLE "park_after_early_bridge" #define SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE "transfer_after_bridge" +#define SWITCH_TRANSFER_AFTER_EARLY_BRIDGE_VARIABLE "transfer_after_early_bridge" #define SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE "exec_after_bridge_app" #define SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE "exec_after_bridge_arg" #define SWITCH_MAX_FORWARDS_VARIABLE "max_forwards" diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index e25fff1bf5..917021005b 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1696,6 +1696,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_call_cause_t cause = switch_channel_get_cause(peer_channel); const char *hup = switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE); int explicit = 0; + int answered = 0; + int early = 0; if (cause == SWITCH_CAUSE_NONE) { cause = SWITCH_CAUSE_NORMAL_CLEARING; @@ -1716,16 +1718,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses switch_channel_hangup(caller_channel, cause); } - 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)) { + answered = switch_channel_test_flag(peer_channel, CF_ANSWERED); + early = switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA); + + if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) || ((answered || early) && state < CS_HANGUP)) { if (!switch_channel_test_flag(caller_channel, CF_TRANSFER)) { - if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) { + + if ((answered && switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) || + switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_EARLY_BRIDGE_VARIABLE))) { switch_ivr_park_session(session); - } else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) { + } else if ((answered && (var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) || + (var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_EARLY_BRIDGE_VARIABLE))) { transfer_after_bridge(session, var); - } else { - if ((switch_channel_test_flag(peer_channel, CF_ANSWERED) && switch_true(hup))) { + } else if (answered) { + if (switch_true(hup)) { if (switch_channel_test_flag(peer_channel, CF_INTERCEPTED)) { switch_channel_set_flag(peer_channel, CF_INTERCEPT); }