add transfer_after_bridge magic var

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12691 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-03-20 20:40:30 +00:00
parent 80e897b3fd
commit 3aacae1aa3
2 changed files with 22 additions and 0 deletions

View File

@ -160,6 +160,7 @@ 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_TRANSFER_AFTER_BRIDGE_VARIABLE "transfer_after_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"

View File

@ -456,11 +456,27 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
return NULL;
}
static void transfer_after_bridge(switch_core_session_t *session, const char *where)
{
int argc;
char *argv[4] = { 0 };
char *mydata;
if (!switch_strlen_zero(where) && (mydata = switch_core_session_strdup(session, where))) {
if ((argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No extension specified.\n");
}
}
}
static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_ivr_bridge_data_t *bd = switch_channel_get_private(channel, "_bridge_");
switch_channel_state_t state;
const char *var;
if (bd) {
switch_channel_set_private(channel, "_bridge_", NULL);
@ -479,6 +495,8 @@ static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *ses
if (state < CS_HANGUP && switch_true(switch_channel_get_variable(channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
switch_ivr_park_session(session);
} else if (state < CS_HANGUP && (var = switch_channel_get_variable(channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
transfer_after_bridge(session, var);
} else {
if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) && bd && !bd->clean_exit
&& state != CS_PARK && state != CS_ROUTING && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
@ -808,6 +826,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
switch_event_t *event;
int br = 0;
int inner_bridge = switch_channel_test_flag(caller_channel, CF_INNER_BRIDGE);
const char *var;
switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
@ -971,6 +990,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
(switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) {
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_PARK_AFTER_BRIDGE_VARIABLE))) {
transfer_after_bridge(session, var);
} else if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
}