From a803e849ebbfbdba2c42ad784e7bc2d3649ea107 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 26 Mar 2013 16:33:13 -0500 Subject: [PATCH] add execute_on_pre_bridge and execute_on_post_bridge vars to behave like the other family of execute_on and not break the existing pre bridge vars that are now depricated --- src/include/switch_types.h | 4 ++++ src/switch_ivr_bridge.c | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 6c75ff4b3d..9f89289d86 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -149,6 +149,9 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE "execute_on_post_originate" #define SWITCH_CHANNEL_EXECUTE_ON_PRE_ORIGINATE_VARIABLE "execute_on_pre_originate" +#define SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE "execute_on_pre_bridge" +#define SWITCH_CHANNEL_EXECUTE_ON_POST_BRIDGE_VARIABLE "execute_on_post_bridge" + #define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE "api_on_answer" #define SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE "api_on_pre_answer" #define SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE "api_on_media" @@ -162,6 +165,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid" #define SWITCH_SOFT_HOLDING_UUID_VARIABLE "soft_holding_uuid" #define SWITCH_API_BRIDGE_END_VARIABLE "api_after_bridge" +#define SWITCH_API_BRIDGE_START_VARIABLE "api_before_bridge" #define SWITCH_API_HANGUP_HOOK_VARIABLE "api_hangup_hook" #define SWITCH_API_REPORTING_HOOK_VARIABLE "api_reporting_hook" #define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE "session_in_hangup_hook" diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 8ec2df18b5..f4bf8ec656 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -170,7 +170,6 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_session_t *session_a, *session_b; uint32_t read_frame_count = 0; const char *app_name = NULL, *app_arg = NULL; - const char *hook_var = NULL; int inner_bridge = 0; switch_codec_t silence_codec = { 0 }; switch_frame_t silence_frame = { 0 }; @@ -361,6 +360,12 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) if (read_frame_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { + switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE); + + if (!inner_bridge) { + switch_channel_api_on(chan_a, SWITCH_API_BRIDGE_START_VARIABLE); + } + if (exec_app) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "%s Bridge execute app %s(%s)\n", switch_channel_get_name(chan_a), exec_app, exec_data); @@ -536,21 +541,10 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_codec_destroy(&silence_codec); } - if (!inner_bridge) { - hook_var = switch_channel_get_variable(chan_a, SWITCH_API_BRIDGE_END_VARIABLE); - } + switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_POST_BRIDGE_VARIABLE); - if (!zstr(hook_var)) { - switch_stream_handle_t stream = { 0 }; - char *cmd = switch_core_session_strdup(session_a, hook_var); - char *arg = NULL; - if ((arg = strchr(cmd, ' '))) { - *arg++ = '\0'; - } - SWITCH_STANDARD_STREAM(stream); - switch_api_execute(cmd, arg, NULL, &stream); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "\nPost-Bridge Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *) stream.data)); - switch_safe_free(stream.data); + if (!inner_bridge) { + switch_channel_api_on(chan_a, SWITCH_API_BRIDGE_END_VARIABLE); } if (!inner_bridge && switch_channel_up_nosig(chan_a)) {