]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add execute_on_pre_bridge and execute_on_post_bridge vars to behave like the other...
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 26 Mar 2013 21:33:13 +0000 (16:33 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 26 Mar 2013 21:33:13 +0000 (16:33 -0500)
src/include/switch_types.h
src/switch_ivr_bridge.c

index 6c75ff4b3de4973e3d117edf14350c06f9600f4a..9f89289d866d24c55ee7239192a9dda76a58c0ec 100644 (file)
@@ -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"
index 8ec2df18b5d913fafed768b7cd265ee5e39486bd..f4bf8ec6561fea8986ee8679d8b85284708be963 100644 (file)
@@ -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)) {