]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
pause media bugs while not in a bridge while inside mod_fifo
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Jan 2009 18:44:25 +0000 (18:44 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Jan 2009 18:44:25 +0000 (18:44 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11466 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_core.h
src/include/switch_types.h
src/mod/applications/mod_fifo/mod_fifo.c
src/switch_core_media_bug.c

index bf6d40d6aa53d2c80e606338a497dfc918f008bb..345337f9282bcdeb5822bfdf3bb87b93a8388dd9 100644 (file)
@@ -143,6 +143,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(_In_ switch_core_sessi
                                                                                                                  _In_ switch_media_bug_callback_t callback,
                                                                                                                  _In_opt_ void *user_data,
                                                                                                                  _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
+
+SWITCH_DECLARE(void) switch_core_media_bug_pause(switch_core_session_t *session);
+SWITCH_DECLARE(void) switch_core_media_bug_resume(switch_core_session_t *session);
+
 /*!
   \brief Obtain private data from a media bug
   \param bug the bug to get the data from
index ee4ddf83923435c885e4e608c5466f1cd2984339..899d330c8ab17e2def0f44c351c913c9e4cabb4f 100644 (file)
@@ -841,7 +841,7 @@ typedef enum {
        CF_INNER_BRIDGE,
        CF_REQ_MEDIA,
        CF_VERBOSE_EVENTS,
-
+       CF_PAUSE_BUGS,
        /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
        CF_FLAG_MAX
 } switch_channel_flag_t;
index d21449f45772d139dadaa48a762e2f59ef4e37f0..68263a69e19fbd963cc4d829589a8f100e21ff22 100644 (file)
@@ -767,6 +767,8 @@ SWITCH_STANDARD_APP(fifo_function)
        check_string(moh);
        switch_assert(node);
 
+       switch_core_media_bug_pause(session);
+
        if (!consumer) {
                switch_core_session_t *other_session;
                switch_channel_t *other_channel;
@@ -926,7 +928,7 @@ SWITCH_STANDARD_APP(fifo_function)
 
                if (!aborted && switch_channel_ready(channel)) {
                        switch_channel_set_state(channel, CS_HIBERNATE);
-                       return;
+                       goto done;
                } else {
                        ts = switch_timestamp_now();
                        switch_time_exp_lt(&tm, ts);
@@ -956,7 +958,8 @@ SWITCH_STANDARD_APP(fifo_function)
                        switch_ivr_session_transfer(session, cd.orbit_exten, NULL, NULL);
                }
 
-               return;
+               goto done;
+
        } else {                                        /* consumer */
                void *pop = NULL;
                switch_frame_t *read_frame;
@@ -987,7 +990,7 @@ SWITCH_STANDARD_APP(fifo_function)
                                strat = STRAT_WAITING_LONGER;
                        } else {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid strategy\n");
-                               return;
+                               goto done;
                        }
                }
 
@@ -996,7 +999,7 @@ SWITCH_STANDARD_APP(fifo_function)
                                do_wait = 0;
                        } else if (strcasecmp(argv[2], "wait")) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
-                               return;
+                               goto done;
                        }
                }
 
@@ -1235,8 +1238,12 @@ SWITCH_STANDARD_APP(fifo_function)
                                        switch_ivr_record_session(session, expanded, 0, NULL);
                                }
 
+                               switch_core_media_bug_resume(session);
+                               switch_core_media_bug_resume(other_session);
                                switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session);
-
+                               switch_core_media_bug_pause(session);
+                               switch_core_media_bug_pause(other_session);
+                               
                                if (record_template) {
                                        switch_ivr_stop_record_session(session, expanded);
                                        if (expanded != record_template) {
@@ -1299,7 +1306,7 @@ SWITCH_STANDARD_APP(fifo_function)
                                if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) {
                                        while(switch_channel_ready(channel)) {
                                                char terminator = 0;
-
+                                               
                                                if (fifo_consumer_wrapup_time) {
                                                        wrapup_time_elapsed = (switch_timestamp_now() - wrapup_time_started) / 1000;
                                                        if (wrapup_time_elapsed > fifo_consumer_wrapup_time) {
@@ -1362,6 +1369,11 @@ SWITCH_STANDARD_APP(fifo_function)
                        }
                }
        }
+
+ done:
+
+       switch_core_media_bug_resume(session);
+
 }
 
 struct xml_helper {
index 19d8a50abda501f6e42dd4c5b77dca0bc258cb34..a012fd7b62ebbe40ce12b7b325fcf76008d50327 100644 (file)
@@ -46,6 +46,16 @@ static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
        }
 }
 
+SWITCH_DECLARE(void) switch_core_media_bug_pause(switch_core_session_t *session)
+{
+       switch_channel_set_flag(session->channel, CF_PAUSE_BUGS);
+}
+
+SWITCH_DECLARE(void) switch_core_media_bug_resume(switch_core_session_t *session)
+{
+       switch_channel_clear_flag(session->channel, CF_PAUSE_BUGS);
+}
+
 SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag)
 {
        return switch_test_flag(bug, flag);