MODSOFIA-77

This commit is contained in:
Anthony Minessale 2010-06-18 17:09:26 -05:00
parent 2ff5af80fa
commit fabaa4a28e
4 changed files with 73 additions and 35 deletions

View File

@ -1341,42 +1341,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_BRIDGE:
{
const char *network_addr_a, *network_addr_b, *simplify_a, *simplify_b;
int s_ok = 0;
int do_s = 0;
simplify_a = switch_channel_get_variable(channel, "sip_auto_simplify");
simplify_b = switch_channel_get_variable_partner(channel, "sip_auto_simplify");
if (switch_true(simplify_a)) {
if (switch_true(simplify_b) && !switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
s_ok = 0;
} else {
s_ok = 1;
}
}
if (s_ok) {
network_addr_a = switch_channel_get_variable(channel, "network_addr");
network_addr_b = switch_channel_get_variable_partner(channel, "network_addr");
if (!zstr(network_addr_a) && !zstr(network_addr_b) && !strcmp(network_addr_a, network_addr_b)) {
if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip)) &&
strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) {
switch_core_session_message_t smsg = { 0 };
smsg.message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
smsg.from = __FILE__;
status = switch_core_session_receive_message(session, &smsg);
do_s = 1;
}
}
}
if (!do_s) {
sofia_glue_tech_track(tech_pvt->profile, session);
}
sofia_glue_tech_simplify(tech_pvt);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
const char *val;

View File

@ -998,3 +998,4 @@ void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int sta
void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session);
switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *session, const char *r_sdp);
char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type);
void sofia_glue_tech_simplify(private_object_t *tech_pvt);

View File

@ -4925,6 +4925,12 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
done:
if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
sofia_glue_tech_simplify(tech_pvt);
}
return;
}

View File

@ -5457,6 +5457,71 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use
return SWITCH_STATUS_SUCCESS;
}
void sofia_glue_tech_simplify(private_object_t *tech_pvt)
{
const char *uuid, *network_addr_a, *network_addr_b, *simplify, *simplify_other_channel;
switch_channel_t *other_channel = NULL, *inbound_channel = NULL;
switch_core_session_t *other_session = NULL, *inbound_session = NULL;
uint8_t did_simplify = 0;
if (!switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED)) {
return;
}
if ((uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session);
if (switch_channel_test_flag(other_channel, CF_ANSWERED)) { /* Check if the other channel is answered */
simplify = switch_channel_get_variable(tech_pvt->channel, "sip_auto_simplify");
simplify_other_channel = switch_channel_get_variable(other_channel, "sip_auto_simplify");
if (switch_true(simplify) && !switch_channel_test_flag(tech_pvt->channel, CF_BRIDGE_ORIGINATOR)) {
network_addr_a = switch_channel_get_variable(tech_pvt->channel, "network_addr");
network_addr_b = switch_channel_get_variable(other_channel, "network_addr");
inbound_session = other_session;
inbound_channel = other_channel;
} else if (switch_true(simplify_other_channel) && !switch_channel_test_flag(other_channel, CF_BRIDGE_ORIGINATOR)) {
network_addr_a = switch_channel_get_variable(other_channel, "network_addr");
network_addr_b = switch_channel_get_variable(tech_pvt->channel, "network_addr");
inbound_session = tech_pvt->session;
inbound_channel = tech_pvt->channel;
}
if (inbound_channel && inbound_session && !zstr(network_addr_a) && !zstr(network_addr_b) && !strcmp(network_addr_a, network_addr_b)) {
if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip)) && strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) {
switch_core_session_message_t *msg;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel), SWITCH_LOG_NOTICE,
"Will simplify channel [%s]\n", switch_channel_get_name(inbound_channel));
msg = switch_core_session_alloc(inbound_session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
msg->from = __FILE__;
switch_core_session_receive_message(inbound_session, msg);
did_simplify = 1;
sofia_glue_tech_track(tech_pvt->profile, inbound_session);
}
}
if (!did_simplify && inbound_channel) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel), SWITCH_LOG_NOTICE,
"Could not simplify channel [%s]\n", switch_channel_get_name(inbound_channel));
}
}
switch_core_session_rwunlock(other_session);
}
}
/* For Emacs:
* Local Variables:
* mode:c