]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Improve recording transfer
authorHunyadvári Péter <peter.hunyadvari@vcc.live>
Tue, 20 Mar 2018 08:20:37 +0000 (09:20 +0100)
committerHunyadvári Péter <peter.hunyadvari@vcc.live>
Tue, 20 Mar 2018 08:20:37 +0000 (09:20 +0100)
Use the same method everywhere
Move the bug without stopping and starting the recording over
It was broken in some circumstances and also some settings were lost

FS-8900 --resolve

src/include/switch_core.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/endpoints/mod_loopback/mod_loopback.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_verto/mod_verto.c
src/switch_channel.c
src/switch_core_media_bug.c
src/switch_ivr_originate.c

index a07ea36a1ea69618084f1d9f2a2e86e566b9fd8d..b92bba4dfb936a0e58585e9cf475502d9e39bfcb 100644 (file)
@@ -409,7 +409,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all_function(_In_ s
 #define switch_core_media_bug_remove_all(_s) switch_core_media_bug_remove_all_function(_s, NULL)
 
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_enumerate(switch_core_session_t *session, switch_stream_handle_t *stream);
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session);
 
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session,
                                                                                                                                                switch_media_bug_callback_t callback, void * (*user_data_dup_func) (switch_core_session_t *, void *));
index ea1b5161cfbcf9fe7417ab116d04ee2c4af4d3e0..670f5f2a37aa790447989fc7942ae27eda0f666b 100644 (file)
@@ -2930,7 +2930,7 @@ SWITCH_STANDARD_API(transfer_function)
                                tsession = other_session;
                                other_session = NULL;
                                if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) {
-                                       switch_core_media_bug_transfer_recordings(tmp, tsession);
+                                       switch_ivr_transfer_recordings(tmp, tsession);
                                }
                                switch_core_session_rwunlock(tmp);
                        }
index e22ec9cc847ee37ff2141c6a851b88675b84527d..8360a5655b995f65eef5ab3d775a2137fada044d 100644 (file)
@@ -866,12 +866,12 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
 
                        if (br_a) {
                                ch_a = switch_core_session_get_channel(br_a);
-                               switch_core_media_bug_transfer_recordings(session, br_a);
+                               switch_ivr_transfer_recordings(session, br_a);
                        }
 
                        if (br_b) {
                                ch_b = switch_core_session_get_channel(br_b);
-                               switch_core_media_bug_transfer_recordings(tech_pvt->other_session, br_b);
+                               switch_ivr_transfer_recordings(tech_pvt->other_session, br_b);
                        }
 
                        if (ch_a && ch_b && switch_channel_test_flag(ch_a, CF_BRIDGED) && switch_channel_test_flag(ch_b, CF_BRIDGED)) {
index 54f3e6802a61812c873717b280f5e6960679d3db..d0d1b7d9753f9c45a8d19fe277be7c233ed74ddc 100644 (file)
@@ -6748,7 +6748,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                                                                                          p_contact->m_url->url_user, sip_redirect_dialplan, sip_redirect_context);
 
                                                        if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) {
-                                                               switch_core_media_bug_transfer_recordings(session, a_session);
+                                                               switch_ivr_transfer_recordings(session, a_session);
                                                        }
 
                                                        switch_ivr_session_transfer(a_session, p_contact->m_url->url_user, sip_redirect_dialplan, sip_redirect_context);
@@ -6765,7 +6765,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                                                                                  p_contact->m_url->url_user);
 
                                                if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) {
-                                                       switch_core_media_bug_transfer_recordings(session, a_session);
+                                                       switch_ivr_transfer_recordings(session, a_session);
                                                }
 
                                                switch_ivr_session_transfer(a_session, p_contact->m_url->url_user, NULL, NULL);
@@ -7738,7 +7738,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
 
                                                                                if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer")) &&
                                                                                        (tmp = switch_core_session_locate(br_a))) {
-                                                                                       switch_core_media_bug_transfer_recordings(session, tmp);
+                                                                                       switch_ivr_transfer_recordings(session, tmp);
                                                                                        switch_core_session_rwunlock(tmp);
                                                                                }
 
@@ -8543,7 +8543,7 @@ void *SWITCH_THREAD_FUNC nightmare_xfer_thread_run(switch_thread_t *thread, void
                                if (switch_channel_up(channel_a)) {
 
                                        if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer"))) {
-                                               switch_core_media_bug_transfer_recordings(session, a_session);
+                                               switch_ivr_transfer_recordings(session, a_session);
                                        }
 
 
@@ -8931,12 +8931,12 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                                switch_ivr_session_transfer(a_session, "park", "inline", NULL);
                                                        }
                                                        if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer"))) {
-                                                               switch_core_media_bug_transfer_recordings(session, a_session);
+                                                               switch_ivr_transfer_recordings(session, a_session);
                                                        }
                                                        if (switch_true(switch_channel_get_variable(channel_b, "recording_follow_transfer")) && (tmpsess = switch_core_session_locate(br_a))) {
                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,
                                                                                  "Early transfer detected with no media, moving recording bug to other leg\n");
-                                                               switch_core_media_bug_transfer_recordings(b_session, tmpsess);
+                                                               switch_ivr_transfer_recordings(b_session, tmpsess);
                                                                switch_core_session_rwunlock(tmpsess);
                                                        }
 
@@ -8997,14 +8997,14 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer")) &&
                                                        (tmp = switch_core_session_locate(br_a))) {
                                                        switch_channel_set_variable(switch_core_session_get_channel(tmp), "transfer_disposition", "bridge");
-                                                       switch_core_media_bug_transfer_recordings(session, tmp);
+                                                       switch_ivr_transfer_recordings(session, tmp);
                                                        switch_core_session_rwunlock(tmp);
                                                }
 
 
                                                if (switch_true(switch_channel_get_variable(channel_b, "recording_follow_transfer")) &&
                                                        (tmp = switch_core_session_locate(br_b))) {
-                                                       switch_core_media_bug_transfer_recordings(b_session, tmp);
+                                                       switch_ivr_transfer_recordings(b_session, tmp);
                                                        switch_core_session_rwunlock(tmp);
                                                }
 
@@ -9093,7 +9093,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
 
 
                                                                if (switch_true(switch_channel_get_variable(hup_channel, "recording_follow_transfer"))) {
-                                                                       switch_core_media_bug_transfer_recordings(hup_session, t_session);
+                                                                       switch_ivr_transfer_recordings(hup_session, t_session);
                                                                }
 
                                                                if(sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)) {
@@ -9348,7 +9348,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                        }
 
                        if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) {
-                               switch_core_media_bug_transfer_recordings(session, b_session);
+                               switch_ivr_transfer_recordings(session, b_session);
                        }
 
                        switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "BLIND_TRANSFER");
index 7a8b6e23b113ae5fc41d76a6eef57c60215acce7..5f72e31f8b5211599de4916004b932b314fc1a5c 100644 (file)
@@ -3051,14 +3051,14 @@ static switch_bool_t attended_transfer(switch_core_session_t *session, switch_co
                if (switch_true(switch_channel_get_variable(tech_pvt->channel, "recording_follow_transfer")) &&
                        (tmp = switch_core_session_locate(br_a))) {
                        switch_channel_set_variable(switch_core_session_get_channel(tmp), "transfer_disposition", "bridge");
-                       switch_core_media_bug_transfer_recordings(session, tmp);
+                       switch_ivr_transfer_recordings(session, tmp);
                        switch_core_session_rwunlock(tmp);
                }
 
 
                if (switch_true(switch_channel_get_variable(b_tech_pvt->channel, "recording_follow_transfer")) &&
                        (tmp = switch_core_session_locate(br_b))) {
-                       switch_core_media_bug_transfer_recordings(b_session, tmp);
+                       switch_ivr_transfer_recordings(b_session, tmp);
                        switch_core_session_rwunlock(tmp);
                }
 
@@ -3104,7 +3104,7 @@ static switch_bool_t attended_transfer(switch_core_session_t *session, switch_co
                                ext = switch_channel_get_variable(hup_channel, "destination_number");
 
                                if (switch_true(switch_channel_get_variable(hup_channel, "recording_follow_transfer"))) {
-                                       switch_core_media_bug_transfer_recordings(hup_session, t_session);
+                                       switch_ivr_transfer_recordings(hup_session, t_session);
                                }
 
                                if (idest) {
index 09fefa1f2a4781a446f78fa1c7794419a11ba3f0..684c4014ecd1200c238cd280fe96711f794429fd 100644 (file)
@@ -863,7 +863,7 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_
                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_ivr_transfer_recordings(channel->session, other_session);
                                switch_core_session_rwunlock(other_session);
                        }
                }
index 962a9cb564f3c3f00f4575aba0f47a5928a9c23e..49ed61cd61e7bf6f770dcf0977f7e5eb7f766d02 100644 (file)
@@ -1012,53 +1012,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_flush_all(switch_core_sess
        return SWITCH_STATUS_FALSE;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session)
-{
-       switch_media_bug_t *bp;
-       char *list[100] = { 0 };
-       int stop_times[100] = { 0 };
-       int i = 0, x = 0;
-
-       if (orig_session->bugs) {
-               switch_channel_t *new_channel = switch_core_session_get_channel(new_session);
-               switch_channel_t *orig_channel = switch_core_session_get_channel(orig_session);
-               const char *save_append = switch_channel_get_variable(new_channel, "record_append");
-               const char *save_stereo = switch_channel_get_variable(new_channel, "record_stereo");
-               const char *orig_stereo = switch_channel_get_variable(orig_channel, "record_stereo");
-               const char *new_stereo = orig_stereo;
-
-               switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
-               switch_channel_set_variable(new_channel, "RECORD_MIN_SEC", "0");
-               switch_channel_set_variable(new_channel, "record_append", "true");
-               switch_channel_set_variable(new_channel, "record_stereo", new_stereo);
-
-               for (bp = orig_session->bugs; bp; bp = bp->next) {
-                       if (!strcmp(bp->function, "session_record")) {
-                               list[x] = switch_core_session_strdup(new_session, bp->target);
-                               if (bp->stop_time > 0) {
-                                       stop_times[x] = (int)(bp->stop_time - switch_epoch_time_now(NULL));
-                               }
-                               x++;
-                       }
-               }
-
-               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_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);
-               }
-
-               switch_channel_set_variable(new_channel, "record_append", save_append);
-               switch_channel_set_variable(new_channel, "record_stereo", save_stereo);
-
-       }
-
-       return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
-}
-
 
 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session,
                                                                                                                                                switch_media_bug_callback_t callback, void * (*user_data_dup_func) (switch_core_session_t *, void *))
index 3794ba73b45df34c9564dd94345024a340f19b8c..ba5c7aafbeef39b7cb4ff3e1dea6ebdb4bc5a5e4 100644 (file)
@@ -3610,11 +3610,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                                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);
+                                                                       switch_ivr_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_ivr_transfer_recordings(holding_session, originate_status[i].peer_session);
                                                                }
 
                                                                switch_core_session_rwunlock(holding_session);