FS-9506 code was too over-zealous about taking control when it should not, pass 1

This commit is contained in:
Anthony Minessale 2016-09-13 15:23:46 -05:00
parent 7258a2484b
commit aee02a3041
1 changed files with 36 additions and 29 deletions

View File

@ -7688,36 +7688,44 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
goto done;
} else {
if (sofia_test_pflag(profile, PFLAG_PROXY_HOLD)) {
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
if (tech_pvt->mparams.num_codecs){
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_REQUEST);
}
if (!match) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite Codec Error!\n");
nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
goto done;
}
} else {
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_NEGOTIATED)) {
nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
goto done;
}
if (!is_t38 && sofia_test_pflag(profile, PFLAG_PROXY_HOLD)) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
switch_core_session_message_t *msg;
const char *hold_msg = "hold";
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
msg = switch_core_session_alloc(other_session, sizeof(*msg));
if (switch_stristr("inactive", r_sdp)) {
sofia_set_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE);
//switch_channel_set_variable(channel, "sofia_hold_inactive", "true");
} else {
sofia_clear_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE);
}
if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp) || switch_stristr("inactive", r_sdp)) {
switch_core_session_message_t *msg;
const char *hold_msg = "hold";
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (tech_pvt->mparams.num_codecs){
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_REQUEST);
}
if (!match) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite Codec Error!\n");
nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
goto done;
}
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
msg = switch_core_session_alloc(other_session, sizeof(*msg));
if (switch_stristr("inactive", r_sdp)) {
sofia_set_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE);
//switch_channel_set_variable(channel, "sofia_hold_inactive", "true");
} else {
sofia_clear_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE);
}
msg->message_id = SWITCH_MESSAGE_INDICATE_HOLD;
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
const char *info = switch_channel_get_variable(channel, "presence_call_info");
@ -7727,6 +7735,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
}
}
sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_set_flag(channel, CF_LEG_HOLDING);
switch_channel_presence(tech_pvt->channel, "unknown", hold_msg, NULL);
@ -7737,14 +7746,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_clear_flag(channel, CF_LEG_HOLDING);
switch_channel_presence(tech_pvt->channel, "unknown", hold_msg, NULL);
}
msg->from = __FILE__;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Indicating %s to other leg.\n%s\n", hold_msg, r_sdp);
switch_core_session_queue_message(other_session, msg);
}
switch_core_session_rwunlock(other_session);
}
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
if (sofia_use_soa(tech_pvt)){
nua_respond(tech_pvt->nh, SIP_200_OK,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
@ -7758,10 +7769,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->mparams.local_sdp_str), TAG_END());
}
goto done;
}
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_NEGOTIATED)) {
nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
goto done;
}