]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 12 Mar 2008 00:11:33 +0000 (00:11 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 12 Mar 2008 00:11:33 +0000 (00:11 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7870 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch_ivr.c
src/switch_ivr_async.c

index 19e9461ebbd7768636b57244f96cd5495da24010..fa01f73c04dd67f3362424ae46568281d627fbf2 100644 (file)
@@ -245,7 +245,8 @@ typedef enum {
        SMF_ECHO_ALEG = (1 << 1),
        SMF_ECHO_BLEG = (1 << 2),
        SMF_FORCE = (1 << 3),
-       SMF_LOOP = (1 << 4)
+       SMF_LOOP = (1 << 4),
+       SMF_HOLD_BLEG = (1 << 5)
 } switch_media_flag_t;
 
 typedef enum {
index 658b54472684447d31a47e36c40fc2d384595d69..3d00d23fca5e755b9fd4e237114838682a0fbd72 100644 (file)
@@ -291,6 +291,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
                char *app_name = switch_event_get_header(event, "execute-app-name");
                char *app_arg = switch_event_get_header(event, "execute-app-arg");
                char *loop_h = switch_event_get_header(event, "loops");
+               char *hold_bleg = switch_event_get_header(event, "hold-bleg");
                int loops = 1;
 
                if (loop_h) {
@@ -301,8 +302,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
                        if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
                                if (application_interface->application_function) {
                                        int x;
+                                       const char *b_uuid = NULL;
+                                       switch_core_session_t *b_session = NULL;
+                                       
                                        switch_channel_clear_flag(channel, CF_STOP_BROADCAST);
                                        switch_channel_set_flag(channel, CF_BROADCAST);
+                                       if (hold_bleg && switch_true(hold_bleg)) {
+                                               if ((b_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+                                                       const char *stream;
+
+                                                       if (!(stream = switch_channel_get_variable_partner(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+                                                               stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
+                                                       }
+                                                       if (stream) {
+                                                               switch_ivr_broadcast(b_uuid, hold_bleg, SMF_ECHO_ALEG | SMF_LOOP);
+                                                       } else {
+                                                               b_uuid = NULL;
+                                                       }
+                                               }
+                                       }
                                        for (x = 0; x < loops || loops < 0; x++) {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n", 
                                                                                  switch_channel_get_name(channel), app_name, app_arg);
@@ -311,6 +329,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
                                                        break;
                                                }
                                        }
+                                       if (b_uuid) {
+                                               if ((b_session = switch_core_session_locate(b_uuid))) {
+                                                       switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
+                                                       switch_channel_stop_broadcast(b_channel);
+                                                       switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
+                                                       switch_core_session_rwunlock(b_session);
+                                               }
+                                       }
                                        switch_channel_clear_flag(channel, CF_BROADCAST);                                       
                                }
                        }
index f7ad37785e1ad52508a4107368ee1046d9f0bda4..8c4eaad9ce0caaa403c5703f134940c0b5e1c280 100644 (file)
@@ -1353,6 +1353,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se
        if (!switch_strlen_zero(app)) {
                md->map[key].app = switch_core_session_strdup(session, app);
                md->map[key].flags = exec_b ? SMF_ECHO_BLEG : SMF_ECHO_ALEG;
+               md->map[key].flags |= SMF_HOLD_BLEG;
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound: %d %s\n", key, app);
        } else {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "UnBound: %d\n", key);
@@ -1838,6 +1839,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(const char *uuid, const cha
                        if ((flags & SMF_LOOP)) {
                                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
                        }
+                       if ((flags & SMF_HOLD_BLEG)) {
+                               switch_event_add_header(event, SWITCH_STACK_BOTTOM, "hold-bleg", "%s", "true");
+                       }
                                
                        switch_core_session_queue_private_event(other_session, &event);
                }