Improve recording transfer

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
This commit is contained in:
Hunyadvári Péter 2018-03-20 09:20:37 +01:00
parent dd0bb0e331
commit 069da397f5
8 changed files with 19 additions and 67 deletions

View 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 *));

View 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);
}

View 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)) {

View 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");

View 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) {

View 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);
}
}

View 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 *))

View 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);