]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_core_get_variables and allow execute_on funcs to see global vars too
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Mar 2013 19:54:01 +0000 (14:54 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Mar 2013 19:54:01 +0000 (14:54 -0500)
src/include/switch_core.h
src/switch_channel.c
src/switch_core.c
src/switch_ivr_bridge.c

index 78b3827aa9d1ee5d61ff189ef0c787e314f83455..21e80e28d516787023e7a2b306903944088d4a27 100644 (file)
@@ -811,6 +811,7 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void);
   \param value the value of the variable
 */
 SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value);
+SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event);
 
 /*! 
   \brief Conditionally add a global variable to the core
index 655dea39c01015881cd8a64abc8e13f3d34a64eb..827d7ea65be9747b697c9328a6121fae0832c9cb 100644 (file)
@@ -3337,7 +3337,7 @@ static void do_execute_on(switch_channel_t *channel, const char *variable)
        char *app;
 
        app = switch_core_session_strdup(channel->session, variable);
-       
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "EXEC %s\n", app);
        for(p = app; p && *p; p++) {
                if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) {
                        *p++ = '\0';
@@ -3360,10 +3360,12 @@ static void do_execute_on(switch_channel_t *channel, const char *variable)
 SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
 {
        switch_event_header_t *hp;
-       switch_event_t *event;
+       switch_event_t *event, *cevent;
        int x = 0;
 
-       switch_channel_get_variables(channel, &event);
+       switch_core_get_variables(&event);
+       switch_channel_get_variables(channel, &cevent);
+       switch_event_merge(event, cevent);
        
        for (hp = event->headers; hp; hp = hp->next) {
                char *var = hp->name;
@@ -3384,6 +3386,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *chan
        }
        
        switch_event_destroy(&event);
+       switch_event_destroy(&cevent);
 
        return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
 }
index 60e133c73014a2502e1f37bc60b26a9cb4c0cba1..64ad73c685c50cd0113b5d6192bf556341cf324e 100644 (file)
@@ -307,6 +307,15 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void)
 }
 
 
+SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event)
+{
+       switch_status_t status;
+       switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
+       status = switch_event_dup(event, runtime.global_vars);
+       switch_thread_rwlock_unlock(runtime.global_var_rwlock);
+       return status;
+}
+
 SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
 {
        char *val;
index 7a20f87b5c5a87197e2a5d636dd5f9174bbeff97..2d80d9357348a953aa2de44f5664e4eeefc9ddec 100644 (file)
@@ -358,8 +358,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
                }
 #endif
 
-               if (read_frame_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) {
-                       
+               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) {
@@ -373,8 +372,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
                                switch_core_session_execute_application_async(session_a, exec_app, exec_data);
                                exec_app = exec_data = NULL;
                        }
+               }
 
-
+               if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) {
                        if ((bypass_media_after_bridge || switch_channel_test_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED)
                                && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
                                switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);