]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
It's time to play the music, It's time to light the lights
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Nov 2008 23:25:38 +0000 (23:25 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Nov 2008 23:25:38 +0000 (23:25 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10391 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia.c
src/switch_ivr.c

index 651568084925120db99fc6a0c784b8008ba04177..a721ab9d4e429e9b42cc94ef561639b027d3958b 100644 (file)
@@ -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);
index 9484813adb99aa78841b30ee66f11777c908b22e..93d7bbbae357dfd5477e990a55382ff763d933b9 100644 (file)
@@ -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"))) {