diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 78d71d4f75..05b11c6d97 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -229,6 +229,8 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel); \returns SWITCH_STATUS_SUCCESS if successful */ +SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val); + SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check); SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...); diff --git a/src/include/switch_types.h b/src/include/switch_types.h index d672e98a42..e7737fddf2 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -868,6 +868,7 @@ CF_STOP_BROADCAST - Signal to stop broadcast typedef enum { CC_MEDIA_ACK = 1, + CC_BYPASS_MEDIA = 1, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CC_FLAG_MAX } switch_channel_cap_t; diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 78733f8729..8aa72bd553 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -784,15 +784,12 @@ SWITCH_STANDARD_APP(set_global_function) SWITCH_STANDARD_APP(set_profile_var_function) { - switch_caller_profile_t *caller_profile; char *name, *val = NULL; - caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session)); - if (switch_strlen_zero(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { - name = switch_core_strdup(caller_profile->pool, data); + name = switch_core_session_strdup(session, data); val = strchr(name, '='); if (val) { @@ -801,66 +798,8 @@ SWITCH_STANDARD_APP(set_profile_var_function) val = NULL; } } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SET_PROFILE_VAR [%s]=[%s]\n", name, val ? val : "UNDEF"); - - if (!strcasecmp(name, "dialplan")) { - caller_profile->dialplan = val; - } - if (!strcasecmp(name, "username")) { - caller_profile->username = val; - } - if (!strcasecmp(name, "caller_id_name")) { - caller_profile->caller_id_name = val; - } - if (!strcasecmp(name, "caller_id_number")) { - caller_profile->caller_id_number = val; - } - if (!strcasecmp(name, "callee_id_name")) { - caller_profile->callee_id_name = val; - } - if (!strcasecmp(name, "callee_id_number")) { - caller_profile->callee_id_number = val; - } - if (val && !strcasecmp(name, "caller_ton")) { - caller_profile->caller_ton = (uint8_t) atoi(val); - } - if (val && !strcasecmp(name, "caller_numplan")) { - caller_profile->caller_numplan = (uint8_t) atoi(val); - } - if (val && !strcasecmp(name, "destination_number_ton")) { - caller_profile->destination_number_ton = (uint8_t) atoi(val); - } - if (val && !strcasecmp(name, "destination_number_numplan")) { - caller_profile->destination_number_numplan = (uint8_t) atoi(val); - } - if (!strcasecmp(name, "ani")) { - caller_profile->ani = val; - } - if (!strcasecmp(name, "aniii")) { - caller_profile->aniii = val; - } - if (!strcasecmp(name, "network_addr")) { - caller_profile->network_addr = val; - } - if (!strcasecmp(name, "rdnis")) { - caller_profile->rdnis = val; - } - if (!strcasecmp(name, "destination_number")) { - caller_profile->destination_number = val; - } - if (!strcasecmp(name, "uuid")) { - caller_profile->uuid = val; - } - if (!strcasecmp(name, "source")) { - caller_profile->source = val; - } - if (!strcasecmp(name, "context")) { - caller_profile->context = val; - } - if (!strcasecmp(name, "chan_name")) { - caller_profile->chan_name = val; - } + + switch_channel_set_profile_var(switch_core_session_get_channel(session), name, val); } } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index a146e460ca..4a99b5e5f9 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1232,7 +1232,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_channel_clear_flag(channel, CF_PROXY_MODE); sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE); - if (!switch_channel_media_ready(channel)) { + if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) { if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); @@ -2989,6 +2989,14 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true"); } + if ((hval = switch_event_get_header(var_event, "sip_callee_id_name"))) { + caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, hval); + } + + if ((hval = switch_event_get_header(var_event, "sip_callee_id_number"))) { + caller_profile->callee_id_number = switch_core_strdup(caller_profile->pool, hval); + } + if (session) { switch_channel_t *o_channel = switch_core_session_get_channel(session); const char *vval = NULL; @@ -3005,7 +3013,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session switch_ivr_transfer_variable(session, nsession, "sip-force-contact"); switch_ivr_transfer_variable(session, nsession, "sip_sticky_contact"); switch_ivr_transfer_variable(session, nsession, "sip_cid_type"); - + if (switch_core_session_compare(session, nsession)) { /* It's another sofia channel! so lets cache what they use as a pt for telephone event so we can keep it the same diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 4d03bcda28..b39415ed09 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3113,11 +3113,12 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status caller_profile->network_addr = switch_core_strdup(caller_profile->pool, network_ip); } + switch_channel_clear_flag(channel, CF_REQ_MEDIA); + if ((status == 180 || status == 183 || status == 200)) { const char *x_actually_support; switch_channel_set_flag(channel, CF_MEDIA_ACK); - switch_channel_clear_flag(channel, CF_REQ_MEDIA); if ((x_actually_support = sofia_glue_get_unknown_header(sip, "X-Actually-Support"))) { tech_pvt->x_actually_support_remote = switch_core_session_strdup(session, x_actually_support); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 9e401e644f..861762b25f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -522,6 +522,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * tech_pvt->session = session; tech_pvt->channel = switch_core_session_get_channel(session); switch_channel_set_cap(tech_pvt->channel, CC_MEDIA_ACK); + switch_channel_set_cap(tech_pvt->channel, CC_BYPASS_MEDIA); switch_core_session_set_private(session, tech_pvt); diff --git a/src/switch_channel.c b/src/switch_channel.c index 2836edcff7..3b7d39d37f 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -622,6 +622,65 @@ SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel) return (!switch_strlen_zero(channel->name)) ? channel->name : "N/A"; } +SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val) +{ + char *v; + switch_status_t status = SWITCH_STATUS_SUCCESS; + + switch_mutex_lock(channel->profile_mutex); + + if (!switch_strlen_zero(val)) { + v = switch_core_strdup(channel->caller_profile->pool, val); + } else { + v = SWITCH_BLANK_STRING; + } + + if (!strcasecmp(name, "dialplan")) { + channel->caller_profile->dialplan = v; + } else if (!strcasecmp(name, "username")) { + channel->caller_profile->username = v; + } else if (!strcasecmp(name, "caller_id_name")) { + channel->caller_profile->caller_id_name = v; + } else if (!strcasecmp(name, "caller_id_number")) { + channel->caller_profile->caller_id_number = v; + } else if (!strcasecmp(name, "callee_id_name")) { + channel->caller_profile->callee_id_name = v; + } else if (!strcasecmp(name, "callee_id_number")) { + channel->caller_profile->callee_id_number = v; + } else if (val && !strcasecmp(name, "caller_ton")) { + channel->caller_profile->caller_ton = (uint8_t) atoi(v); + } else if (val && !strcasecmp(name, "caller_numplan")) { + channel->caller_profile->caller_numplan = (uint8_t) atoi(v); + } else if (val && !strcasecmp(name, "destination_number_ton")) { + channel->caller_profile->destination_number_ton = (uint8_t) atoi(v); + } else if (val && !strcasecmp(name, "destination_number_numplan")) { + channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v); + } else if (!strcasecmp(name, "ani")) { + channel->caller_profile->ani = v; + } else if (!strcasecmp(name, "aniii")) { + channel->caller_profile->aniii = v; + } else if (!strcasecmp(name, "network_addr")) { + channel->caller_profile->network_addr = v; + } else if (!strcasecmp(name, "rdnis")) { + channel->caller_profile->rdnis = v; + } else if (!strcasecmp(name, "destination_number")) { + channel->caller_profile->destination_number = v; + } else if (!strcasecmp(name, "uuid")) { + channel->caller_profile->uuid = v; + } else if (!strcasecmp(name, "source")) { + channel->caller_profile->source = v; + } else if (!strcasecmp(name, "context")) { + channel->caller_profile->context = v; + } else if (!strcasecmp(name, "chan_name")) { + channel->caller_profile->chan_name = v; + } else { + status = SWITCH_STATUS_FALSE; + } + switch_mutex_unlock(channel->profile_mutex); + + return status; +} + SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check) { diff --git a/src/switch_core_session.c b/src/switch_core_session.c index b892524cbd..eff4c537bb 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -506,13 +506,21 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_ } if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { - switch_channel_set_flag(peer_channel, CF_PROXY_MODE); - } - - if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { - switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA); - if (switch_channel_test_flag(channel, CF_VIDEO)) { - switch_channel_set_flag(peer_channel, CF_VIDEO); + if (switch_channel_test_cap(peer_channel, CC_BYPASS_MEDIA)) { + switch_channel_set_flag(peer_channel, CF_PROXY_MODE); + + if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { + switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA); + if (switch_channel_test_flag(channel, CF_VIDEO)) { + switch_channel_set_flag(peer_channel, CF_VIDEO); + } + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, + "%s does not support the proxy feature, disabling.\n", + switch_channel_get_name(peer_channel)); + switch_channel_clear_flag(channel, CF_PROXY_MODE); + switch_channel_clear_flag(channel, CF_PROXY_MEDIA); } } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 0a76484edc..24248fd4d6 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -84,7 +84,7 @@ static void send_display(switch_core_session_t *session, switch_core_session_t * switch_core_session_message_t *msg; switch_caller_profile_t *caller_profile; switch_channel_t *caller_channel; - const char *name, *number; + const char *name, *number, *p; caller_channel = switch_core_session_get_channel(session); caller_profile = switch_channel_get_caller_profile(caller_channel); @@ -111,6 +111,13 @@ static void send_display(switch_core_session_t *session, switch_core_session_t * } } + if ((p = strrchr(number, '/'))) { + number = p+1; + } + if ((p = strrchr(name, '/'))) { + name = p+1; + } + msg = switch_core_session_alloc(peer_session, sizeof(*msg)); MESSAGE_STAMP_FFL(msg); msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY; @@ -394,9 +401,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(un)); goto end_of_bridge_loop; } - - if (ans_a) ans_b = 1; else ans_a = 1; } + + if (ans_a) ans_b = 1; else ans_a = 1; } if (originator && !sent_update && ans_a && ans_b && switch_channel_media_ack(chan_a) && switch_channel_media_ack(chan_b)) { @@ -866,6 +873,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t * switch_channel_set_flag(peer_channel, CF_TRANSFER); } + switch_ivr_bridge_display(session, peer_session); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index cb023b139c..67cb3f873c 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1725,6 +1725,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (originate_status[i].peer_channel) { const char *vvar; + if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_callee_id_name"))) { + switch_channel_set_profile_var(originate_status[i].peer_channel, "callee_id_name", vvar); + } + + if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_callee_id_number"))) { + switch_channel_set_profile_var(originate_status[i].peer_channel, "callee_id_number", vvar); + } + if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_timeout"))) { int val = atoi(vvar); if (val > 0) {