From cc36e272866687d06c1fab2a0654f7e8ec62d33e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 13 Nov 2008 23:25:38 +0000 Subject: [PATCH] It's time to play the music, It's time to light the lights git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10391 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia.c | 1 + src/switch_ivr.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 6515680849..a721ab9d4e 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2986,6 +2986,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t switch_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD); switch_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK); + switch_channel_set_variable(switch_core_session_get_channel(b_session), "park_timeout", "2"); switch_channel_set_state(switch_core_session_get_channel(b_session), CS_PARK); new_b_session = switch_core_session_locate(br_b); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 9484813adb..93d7bbbae3 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -494,6 +494,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_codec_t *read_codec; uint32_t rate; uint32_t bpf; + const char *to; + int timeout = 0; + time_t expires = 0; if (switch_channel_test_flag(channel, CF_CONTROLLED)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that are under control already.\n"); @@ -522,6 +525,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, rate = read_codec->implementation->actual_samples_per_second; bpf = read_codec->implementation->decoded_bytes_per_packet; + if ((to = switch_channel_get_variable(channel, "park_timeout"))) { + if ((timeout = atoi(to)) < 0) { + timeout = 0; + } else { + expires = switch_timestamp(NULL) + timeout; + } + } + switch_channel_set_flag(channel, CF_CONTROLLED); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PARK) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); @@ -535,6 +546,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, break; } + if (expires && switch_timestamp(NULL) >= expires) { + switch_channel_hangup(channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE); + break; + } + if (switch_channel_test_flag(channel, CF_UNICAST)) { if (!conninfo) { if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {