forked from Mirrors/freeswitch
FS-4204 --resolve
This commit is contained in:
parent
383130f855
commit
f9653fbd38
@ -141,7 +141,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_pop(switch_core_session_t
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session,
|
||||
const char *function, switch_media_bug_exec_cb_t cb, void *user_data);
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function);
|
||||
/*!
|
||||
\brief Add a media bug to the session
|
||||
\param session the session to add the bug to
|
||||
|
@ -5375,11 +5375,23 @@ SWITCH_STANDARD_APP(sofia_sla_function)
|
||||
if (bargee_session == session) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "BARGE: %s (cannot barge on myself)\n", (char *) data);
|
||||
} else {
|
||||
switch_channel_t *channel;
|
||||
|
||||
if (switch_core_session_check_interface(bargee_session, sofia_endpoint_interface)) {
|
||||
tech_pvt = switch_core_session_get_private(bargee_session);
|
||||
sofia_clear_flag(tech_pvt, TFLAG_SLA_BARGING);
|
||||
sofia_set_flag(tech_pvt, TFLAG_SLA_BARGE);
|
||||
switch_ivr_transfer_variable(bargee_session, session, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
}
|
||||
|
||||
if (switch_core_session_check_interface(session, sofia_endpoint_interface)) {
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
sofia_set_flag(tech_pvt, TFLAG_SLA_BARGING);
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_channel_set_variable(channel, "sip_barging_uuid", (char *)data);
|
||||
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(bargee_session);
|
||||
|
@ -334,6 +334,7 @@ typedef enum {
|
||||
TFLAG_CAPTURE,
|
||||
TFLAG_REINVITED,
|
||||
TFLAG_SLA_BARGE,
|
||||
TFLAG_SLA_BARGING,
|
||||
/* No new flags below this line */
|
||||
TFLAG_MAX
|
||||
} TFLAGS;
|
||||
|
@ -599,6 +599,23 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
|
||||
status = 200;
|
||||
phrase = "OK";
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGING)) {
|
||||
const char *bargee_uuid = switch_channel_get_variable(channel, "sip_barging_uuid");
|
||||
switch_core_session_t *bargee_session;
|
||||
uint32_t ttl = 0;
|
||||
|
||||
if ((bargee_session = switch_core_session_locate(bargee_uuid))) {
|
||||
//switch_channel_t *bargee_channel = switch_core_session_get_channel(bargee_session);
|
||||
if ((ttl = switch_core_media_bug_count(bargee_session, "eavesdrop")) == 1) {
|
||||
if (switch_core_session_check_interface(bargee_session, sofia_endpoint_interface)) {
|
||||
private_object_t *bargee_tech_pvt = switch_core_session_get_private(bargee_session);
|
||||
sofia_clear_flag(bargee_tech_pvt, TFLAG_SLA_BARGE);
|
||||
}
|
||||
}
|
||||
switch_core_session_rwunlock(bargee_session);
|
||||
}
|
||||
}
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGE)) {
|
||||
switch_core_session_t *new_session, *other_session;
|
||||
const char *other_uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
@ -8419,9 +8436,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
|
||||
if ((b_session = switch_core_session_locate(b_private->uuid))) {
|
||||
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
|
||||
const char *uuid;
|
||||
const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
|
||||
const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
|
||||
const char *bridge_uuid;
|
||||
switch_caller_profile_t *orig_cp;
|
||||
const char *sent_name, *sent_number;
|
||||
orig_cp = switch_channel_get_caller_profile(b_channel);
|
||||
@ -8446,24 +8461,37 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat);
|
||||
}
|
||||
|
||||
tech_pvt->caller_profile->dialplan = "inline";
|
||||
|
||||
if (app && data && !strcasecmp(app, "conference")) {
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,conference:%s+flags{dist-dtmf}", data);
|
||||
tech_pvt->caller_profile->dialplan = "inline";
|
||||
} else {
|
||||
if (!(uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
|
||||
uuid = switch_core_session_get_uuid(b_session);
|
||||
}
|
||||
bridge_uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
|
||||
if (uuid) {
|
||||
uuid = switch_core_session_strdup(b_session, uuid);
|
||||
if (call_info) {
|
||||
if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) {
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
|
||||
"answer,intercept:%s", bridge_uuid);
|
||||
} else {
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
|
||||
"answer,sofia_sla:%s", b_private->uuid);
|
||||
}
|
||||
} else {
|
||||
if (!zstr(bridge_uuid)) {
|
||||
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
|
||||
} else {
|
||||
const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
|
||||
const char *b_data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
|
||||
|
||||
if (b_data && b_app) {
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s:%s", b_app, b_data);
|
||||
} else if (b_app) {
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s", b_app);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tech_pvt->caller_profile->dialplan = "inline";
|
||||
switch_channel_hangup(b_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
|
||||
}
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(b_session);
|
||||
}
|
||||
}
|
||||
|
@ -4061,6 +4061,10 @@ int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGE) || sofia_test_flag(tech_pvt, TFLAG_SLA_BARGING)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sendonly && switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED)) {
|
||||
if (!sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
|
||||
const char *stream;
|
||||
|
@ -600,6 +600,24 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_pop(switch_core_session_t
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function)
|
||||
{
|
||||
switch_media_bug_t *bp;
|
||||
uint32_t x = 0;
|
||||
|
||||
if (orig_session->bugs) {
|
||||
switch_thread_rwlock_rdlock(orig_session->bug_rwlock);
|
||||
for (bp = orig_session->bugs; bp; bp = bp->next) {
|
||||
if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
switch_thread_rwlock_unlock(orig_session->bug_rwlock);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session,
|
||||
const char *function, switch_media_bug_exec_cb_t cb, void *user_data)
|
||||
{
|
||||
@ -629,7 +647,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_enumerate(switch_core_sess
|
||||
stream->write_function(stream, "<media-bugs>\n");
|
||||
|
||||
if (session->bugs) {
|
||||
switch_thread_rwlock_wrlock(session->bug_rwlock);
|
||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||
for (bp = session->bugs; bp; bp = bp->next) {
|
||||
int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self());
|
||||
stream->write_function(stream,
|
||||
@ -778,6 +796,8 @@ SWITCH_DECLARE(uint32_t) switch_core_media_bug_prune(switch_core_session_t *sess
|
||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
||||
|
||||
if (bp) {
|
||||
switch_clear_flag(bp, SMBF_LOCK);
|
||||
bp->thread_id = 0;
|
||||
switch_core_media_bug_close(&bp);
|
||||
ttl++;
|
||||
goto top;
|
||||
|
@ -228,6 +228,8 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
}
|
||||
}
|
||||
|
||||
switch_channel_clear_flag(chan_a, CF_INTERCEPT);
|
||||
switch_channel_clear_flag(chan_a, CF_INTERCEPTED);
|
||||
|
||||
switch_channel_set_flag(chan_a, CF_BRIDGED);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user