sla cid tweaks

Conflicts:
	src/mod/endpoints/mod_sofia/sofia_glue.c
This commit is contained in:
Anthony Minessale 2013-04-05 00:29:20 -05:00
parent 241cf2a8c2
commit 900f2aab74
5 changed files with 3005 additions and 31 deletions

View File

@ -485,6 +485,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
char *bye_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
const char *val = NULL;
const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason");
@ -503,8 +504,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
}
if (switch_channel_test_flag(channel, CF_ANSWERED) || sofia_test_flag(tech_pvt, TFLAG_ANS)) {
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
if (!tech_pvt->got_bye) {
switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye");
}
@ -524,6 +523,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
}
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
nua_cancel(tech_pvt->nh,
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END());
}
} else {
@ -1592,6 +1592,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_DISPLAY:
{
const char *name = msg->string_array_arg[0], *number = msg->string_array_arg[1];
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
if (!zstr(name)) {
char message[256] = "";
@ -1668,6 +1669,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_update(tech_pvt->nh,
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
@ -1678,6 +1680,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_update(tech_pvt->nh,
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
@ -1688,6 +1691,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_update(tech_pvt->nh,
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
@ -1698,6 +1702,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_update(tech_pvt->nh,
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());

View File

@ -8512,9 +8512,15 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
const char *bridge_uuid;
switch_caller_profile_t *orig_cp;
const char *sent_name, *sent_number;
//const char *sent_name, *sent_number;
orig_cp = switch_channel_get_caller_profile(b_channel);
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
tech_pvt->caller_profile->caller_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
#if 0
sent_name = switch_channel_get_variable(b_channel, "last_sent_callee_id_name");
sent_number = switch_channel_get_variable(b_channel, "last_sent_callee_id_number");
@ -8530,6 +8536,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
}
}
#endif
if (is_nat) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat);
@ -8558,13 +8565,25 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame,
read_impl.microseconds_per_packet / 1000);
}
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,
"%sanswer,intercept:%s", codec_str, bridge_uuid);
} else {
const char *name = NULL, *num = NULL;
switch_caller_profile_t *bcp = switch_channel_get_caller_profile(b_channel);
if (switch_channel_test_flag(b_channel, CF_BRIDGE_ORIGINATOR) || !switch_channel_test_flag(b_channel, CF_BRIDGED)) {
name = bcp->callee_id_name;
num = bcp->callee_id_number;
} else {
name = bcp->caller_id_name;
num = bcp->caller_id_number;
}
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, name);
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, num);
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
"%sanswer,sofia_sla:%s", codec_str, b_private->uuid);
}

File diff suppressed because it is too large Load Diff

View File

@ -3276,26 +3276,22 @@ static int broadsoft_sla_gather_state_callback(void *pArg, int argc, char **argv
data = switch_core_hash_find(sh->hash, key);
if (uuid && (session = switch_core_session_locate(uuid))) {
if (strcasecmp(state, "idle") && uuid && (session = switch_core_session_locate(uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
callee_name = switch_channel_get_variable(channel, "callee_id_name");
callee_number = switch_channel_get_variable(channel, "callee_id_number");
if (zstr((callee_name = switch_channel_get_variable(channel, "effective_callee_id_name"))) &&
zstr((callee_name = switch_channel_get_variable(channel, "sip_callee_id_name")))) {
callee_name = switch_channel_get_variable(channel, "callee_id_name");
}
if (zstr((callee_number = switch_channel_get_variable(channel, "effective_callee_id_number"))) &&
zstr((callee_number = switch_channel_get_variable(channel, "sip_callee_id_number"))) &&
zstr((callee_number = switch_channel_get_variable(channel, "callee_id_number")))) {
if (zstr(callee_number)) {
callee_number = switch_channel_get_variable(channel, "destination_number");
}
} else {
callee_name = switch_channel_get_variable(channel, "caller_id_name");
callee_number = switch_channel_get_variable(channel, "caller_id_number");
}
if (zstr(callee_name) && !zstr(callee_number)) {
callee_name = callee_number;
}
@ -3307,9 +3303,20 @@ static int broadsoft_sla_gather_state_callback(void *pArg, int argc, char **argv
if (!zstr(callee_name)) {
callee_name = switch_sanitize_number(switch_core_session_strdup(session, callee_name));
}
//if (switch_channel_get_state(channel) != CS_EXECUTE) {
//callee_number = NULL;
//}
switch_core_session_rwunlock(session);
}
if (data && strstr(data, info)) {
return 0;
}
if (!zstr(callee_number)) {
if (zstr(callee_name)) {
callee_name = "unknown";

View File

@ -1473,7 +1473,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
switch_codec_implementation_t tread_impl = { 0 }, read_impl = { 0 };
switch_core_session_message_t msg = { 0 };
char cid_buf[1024] = "";
switch_caller_profile_t *cp = NULL;
switch_caller_profile_t *cp = NULL, *my_cp = NULL;
uint32_t sanity = 600;
if (!switch_channel_media_up(channel)) {
@ -1595,26 +1595,29 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
switch_core_session_receive_message(session, &msg);
cp = switch_channel_get_caller_profile(tchannel);
my_cp = switch_channel_get_caller_profile(channel);
name = cp->caller_id_name;
num = cp->caller_id_number;
if (flags & ED_COPY_DISPLAY) {
const char *tmp_name = NULL, *tmp_num = NULL;
name = cp->callee_id_name;
num = cp->callee_id_number;
if (!((tmp_name = switch_channel_get_variable(tchannel, "last_sent_callee_id_name"))
&& (tmp_num = switch_channel_get_variable(tchannel, "last_sent_callee_id_number")))) {
tmp_name = switch_channel_get_variable(tchannel, "callee_id_name");
tmp_num = switch_channel_get_variable(tchannel, "callee_id_number");
if (switch_channel_test_flag(tchannel, CF_BRIDGE_ORIGINATOR) || !switch_channel_test_flag(tchannel, CF_BRIDGED)) {
name = cp->callee_id_name;
num = cp->callee_id_number;
} else {
name = cp->caller_id_name;
num = cp->caller_id_number;
}
if (tmp_name) name = tmp_name;
if (tmp_num) num = tmp_num;
my_cp->callee_id_name = switch_core_strdup(my_cp->pool, name);
my_cp->callee_id_number = switch_core_strdup(my_cp->pool, num);
}
sanity = 300;
while(switch_channel_up(channel) && !switch_channel_media_ack(channel) && --sanity) {
switch_yield(10000);
}
switch_snprintf(cid_buf, sizeof(cid_buf), "%s|%s", name, num);
msg.string_arg = cid_buf;
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;