From f60f17d39145f5eed8c1b1417db839deb9487f9d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 23 Jan 2009 18:44:25 +0000 Subject: [PATCH] pause media bugs while not in a bridge while inside mod_fifo git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11466 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 4 ++++ src/include/switch_types.h | 2 +- src/mod/applications/mod_fifo/mod_fifo.c | 24 ++++++++++++++++++------ src/switch_core_media_bug.c | 10 ++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index bf6d40d6aa..345337f928 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -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 diff --git a/src/include/switch_types.h b/src/include/switch_types.h index ee4ddf8392..899d330c8a 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -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; diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index d21449f457..68263a69e1 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -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 { diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 19d8a50abd..a012fd7b62 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -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);