allow mod loopback bowout to reach out across stacked loopback bridges and remove all of them

This commit is contained in:
Anthony Minessale 2012-05-17 18:57:22 -05:00
parent 83e090c30d
commit ad7149bfa6

View File

@ -650,6 +650,39 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
return status; return status;
} }
static switch_status_t find_non_loopback_bridge(switch_core_session_t *session, switch_core_session_t **br_session, const char **br_uuid)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *a_uuid;
switch_core_session_t *sp;
*br_session = NULL;
*br_uuid = NULL;
a_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
while (a_uuid && (sp = switch_core_session_locate(a_uuid))) {
if (switch_core_session_check_interface(sp, loopback_endpoint_interface)) {
private_t *tech_pvt = switch_core_session_get_private(sp);
a_uuid = switch_channel_get_variable(tech_pvt->other_channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_core_session_rwunlock(sp);
sp = NULL;
} else {
break;
}
}
if (sp) {
*br_session = sp;
*br_uuid = a_uuid;
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
{ {
switch_channel_t *channel = NULL; switch_channel_t *channel = NULL;
@ -678,8 +711,8 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
switch_channel_test_flag(tech_pvt->other_channel, CF_BRIDGED) && switch_channel_test_flag(tech_pvt->other_channel, CF_BRIDGED) &&
switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) && switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) &&
switch_channel_test_flag(tech_pvt->other_channel, CF_ANSWERED) && --tech_pvt->bowout_frame_count <= 0) { switch_channel_test_flag(tech_pvt->other_channel, CF_ANSWERED) && --tech_pvt->bowout_frame_count <= 0) {
const char *a_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); const char *a_uuid = NULL;
const char *b_uuid = switch_channel_get_variable(tech_pvt->other_channel, SWITCH_SIGNAL_BOND_VARIABLE); const char *b_uuid = NULL;
const char *vetoa, *vetob; const char *vetoa, *vetob;
@ -691,15 +724,20 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
switch_channel_t *ch_a = NULL, *ch_b = NULL; switch_channel_t *ch_a = NULL, *ch_b = NULL;
int good_to_go = 0; int good_to_go = 0;
if ((br_a = switch_core_session_locate(a_uuid))) { find_non_loopback_bridge(session, &br_a, &a_uuid);
find_non_loopback_bridge(tech_pvt->other_session, &br_b, &b_uuid);
if (br_a) {
ch_a = switch_core_session_get_channel(br_a); ch_a = switch_core_session_get_channel(br_a);
} }
if ((br_b = switch_core_session_locate(b_uuid))) { if (br_b) {
ch_b = switch_core_session_get_channel(br_b); ch_b = switch_core_session_get_channel(br_b);
} }
if (ch_a && ch_b && switch_channel_test_flag(ch_a, CF_BRIDGED) && switch_channel_test_flag(ch_b, CF_BRIDGED)) { if (ch_a && ch_b && switch_channel_test_flag(ch_a, CF_BRIDGED) && switch_channel_test_flag(ch_b, CF_BRIDGED)) {
switch_set_flag_locked(tech_pvt, TFLAG_BOWOUT); switch_set_flag_locked(tech_pvt, TFLAG_BOWOUT);
switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_BOWOUT); switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_BOWOUT);