]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add vars: flip_record_on_hold to make the recording flip to the other leg on hold...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 1 Jun 2011 03:22:09 +0000 (22:22 -0500)
committerBrian West <brian@freeswitch.org>
Wed, 1 Jun 2011 03:22:18 +0000 (22:22 -0500)
src/mod/endpoints/mod_sofia/sofia.c
src/switch_channel.c
src/switch_core_media_bug.c
src/switch_ivr_async.c
src/switch_ivr_originate.c

index c9468872aa9cc37df804630ebc2be7ec9eabe15d..4e5860e8a0d3959e16c120b8b289be490bf028cd 100644 (file)
@@ -5886,17 +5886,19 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                                                   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden\r\n"),
                                                                                   SIPTAG_EVENT_STR(etmp), TAG_END());
                                                        } else {
-                                                               switch_core_session_t *t_session;
+                                                               switch_core_session_t *t_session, *hup_session;
                                                                switch_channel_t *hup_channel;
                                                                const char *ext;
 
                                                                if (br_a && !br_b) {
                                                                        t_session = switch_core_session_locate(br_a);
                                                                        hup_channel = channel_b;
+                                                                       hup_session = b_session;
                                                                } else {
                                                                        private_object_t *h_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session);
                                                                        t_session = switch_core_session_locate(br_b);
                                                                        hup_channel = channel_a;
+                                                                       hup_session = session;
                                                                        sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
                                                                        switch_channel_clear_flag(tech_pvt->channel, CF_LEG_HOLDING);
                                                                        sofia_clear_flag_locked(h_tech_pvt, TFLAG_SIP_HOLD);
@@ -5917,6 +5919,11 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                                                switch_channel_set_variable(t_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
                                                                        }
 
+                                                                       
+                                                                       if (switch_true(switch_channel_get_variable(hup_channel, "recording_follow_transfer"))) {
+                                                                               switch_core_media_bug_transfer_recordings(hup_session, t_session);
+                                                                       }
+
                                                                        if (idest) {
                                                                                switch_ivr_session_transfer(t_session, idest, "inline", NULL);
                                                                        } else {
@@ -6079,6 +6086,10 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                        switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
                                }
 
+                               if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) {
+                                       switch_core_media_bug_transfer_recordings(session, b_session);
+                               }
+
                                switch_ivr_session_transfer(b_session, exten, NULL, NULL);
                                switch_core_session_rwunlock(b_session);
                        }
index ebddafb2364efbcbd4ee9dce05dbb1c837d13fc2..6ccaedee3da15691f51c6618e5621bef75e8d1bf 100644 (file)
@@ -635,7 +635,7 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_
        switch_event_t *event;
 
        if (!!on == !!switch_channel_test_flag(channel, CF_LEG_HOLDING)) {
-               return;
+               goto end;
        }
        
        if (on) {
@@ -649,6 +649,18 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_
                switch_event_fire(&event);
        }
 
+ end:
+
+       if (on) {
+               if (switch_true(switch_channel_get_variable(channel, "flip_record_on_hold"))) {
+                       switch_core_session_t *other_session;
+                       if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
+                               switch_core_media_bug_transfer_recordings(channel->session, other_session);
+                               switch_core_session_rwunlock(other_session);
+                       }
+               }
+       }
+
 }
 
 SWITCH_DECLARE(const char *) switch_channel_get_hold_music(switch_channel_t *channel)
index d546fba47daef58fbed5e52f61fe68a2edd2224d..2c33ca2707c8c5ee3ace9fa326409d159a2218c3 100644 (file)
@@ -420,7 +420,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch
                switch_thread_rwlock_unlock(orig_session->bug_rwlock);
 
                for(i = 0; i < x; i++) {
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_DEBUG, "Transfering %s from %s to %s\n", list[i],
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_CRIT, "Transfering %s from %s to %s\n", list[i],
                                                          switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session));
                        switch_ivr_stop_record_session(orig_session, list[i]);
                        switch_ivr_record_session(new_session, list[i], stop_times[i], NULL);
index 955fdee14cb92d658bf3c219b046747eafdb3469..7f0b37905acd61cf7f205290fe7db041fa3a80a8 100644 (file)
@@ -1444,7 +1444,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
        int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
        switch_bool_t hangup_on_error = SWITCH_FALSE;
        char *file_path = NULL;
-
+       
        if ((p = switch_channel_get_variable(channel, "RECORD_HANGUP_ON_ERROR"))) {
                hangup_on_error = switch_true(p);
        }
@@ -1463,7 +1463,36 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
        channels = read_impl.number_of_channels;
 
        if ((bug = switch_channel_get_private(channel, file))) {
-               return switch_ivr_stop_record_session(session, file);
+               if (switch_true(switch_channel_get_variable(channel, "RECORD_TOGGLE_ON_REPEAT"))) {
+                       return switch_ivr_stop_record_session(session, file);
+               }
+               
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Already recording [%s]\n", file);
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       
+       if ((p = switch_channel_get_variable(channel, "RECORD_CHECK_BRIDGE")) && switch_true(p)) {
+               switch_core_session_t *other_session;
+               int exist = 0;
+               switch_status_t rstatus = SWITCH_STATUS_SUCCESS;
+               
+               if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
+                       switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+                       if ((bug = switch_channel_get_private(other_channel, file))) {
+                               if (switch_true(switch_channel_get_variable(other_channel, "RECORD_TOGGLE_ON_REPEAT"))) {
+                                       rstatus = switch_ivr_stop_record_session(other_session, file);
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(other_session), SWITCH_LOG_WARNING, "Already recording [%s]\n", file);
+                               }
+                               exist = 1;
+                       }
+                       switch_core_session_rwunlock(other_session);
+               }
+               
+               if (exist) {
+                       return rstatus;
+               }
        }
 
        if (!fh) {
@@ -1615,7 +1644,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
        rh->file = switch_core_session_strdup(session, file);
        rh->packet_len = read_impl.decoded_bytes_per_packet;
 
-       rh->min_sec = 3;
+       if (file_flags & SWITCH_FILE_WRITE_APPEND) {
+               rh->min_sec = 3;
+       }
 
        if ((p = switch_channel_get_variable(channel, "RECORD_MIN_SEC"))) {
                int tmp = atoi(p);
index 78b553601b85db55e2cdc28bd71dbfee09a2fbd1..3f5c576c31c861253d7eb596915fb0a03d4c18af 100644 (file)
@@ -3123,10 +3123,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                        switch_core_session_t *holding_session;
 
                                                        if ((holding_session = switch_core_session_locate(holding))) {
-                                                               switch_channel_set_variable(switch_core_session_get_channel(holding_session), SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
+                                                               switch_channel_t *holding_channel = switch_core_session_get_channel(holding_session);
+                                                               
+                                                               switch_channel_set_variable(holding_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
+
+                                                               if (caller_channel && switch_true(switch_channel_get_variable(caller_channel, "recording_follow_transfer"))) {
+                                                                       switch_core_media_bug_transfer_recordings(session, originate_status[i].peer_session);
+                                                               }
+
+                                                               if (switch_true(switch_channel_get_variable(holding_channel, "recording_follow_transfer"))) {
+                                                                       switch_core_media_bug_transfer_recordings(holding_session, originate_status[i].peer_session);
+                                                               }
+                                                               
                                                                switch_core_session_rwunlock(holding_session);
                                                        }
                                                        switch_channel_set_flag(originate_status[i].peer_channel, CF_LAZY_ATTENDED_TRANSFER);
+                                                       
                                                        switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(originate_status[i].peer_session));
                                                        holding = NULL;
                                                } else {