Skip to content
Snippets Groups Projects
Commit 73edc972 authored by pierre-luc's avatar pierre-luc
Browse files

[#1810] GUI is now notified that the call failed. Also, a segfault was

prevented by enclosing all the message->body access into
PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER in order to make sure that we are in
an SDP ANSWER.
parent ae818746
No related branches found
No related tags found
No related merge requests found
......@@ -204,37 +204,44 @@ int Sdp::receiving_initial_offer (pjmedia_sdp_session* remote)
return PJ_SUCCESS;
}
pj_status_t Sdp::check_incoming_sdp(pjsip_inv_session *inv, pjsip_rx_data *rdata)
pj_status_t Sdp::check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata)
{
static const pj_str_t str_application = { "application", 11 };
static const pj_str_t str_sdp = { "sdp", 3 };
pj_status_t status;
pjsip_msg * message;
pjmedia_sdp_session * remote_sdp;
pjsip_msg * message = NULL;
pjmedia_sdp_session * remote_sdp = NULL;
message = rdata->msg_info.msg;
if (message->body == NULL) {
_debug("Empty message body\n");
return -1;
}
if (pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) {
if (pj_stricmp(&message->body->content_type.type, &str_application) || pj_stricmp(&message->body->content_type.subtype, &str_sdp)) {
_debug("Incoming Message does not contain SDP\n");
return PJMEDIA_SDP_EINSDP;
}
// Parse the SDP body.
status = pjmedia_sdp_parse(rdata->tp_info.pool, (char*)message->body->data, message->body->len, &remote_sdp);
if (status == PJ_SUCCESS) {
status = pjmedia_sdp_validate(remote_sdp);
}
message = rdata->msg_info.msg;
if (status != PJ_SUCCESS) {
_debug("SDP cannot be validated\n");
return PJMEDIA_SDP_EINSDP;
}
if(message == NULL) {
_debug("No message");
return PJMEDIA_SDP_EINSDP;
}
if (message->body == NULL) {
_debug("Empty message body\n");
return PJMEDIA_SDP_EINSDP;
}
if (pj_stricmp(&message->body->content_type.type, &str_application) || pj_stricmp(&message->body->content_type.subtype, &str_sdp)) {
_debug("Incoming Message does not contain SDP\n");
return PJMEDIA_SDP_EINSDP;
}
// Parse the SDP body.
status = pjmedia_sdp_parse(rdata->tp_info.pool, (char*)message->body->data, message->body->len, &remote_sdp);
if (status == PJ_SUCCESS) {
status = pjmedia_sdp_validate(remote_sdp);
}
if (status != PJ_SUCCESS) {
_debug("SDP cannot be validated\n");
return PJMEDIA_SDP_EINSDP;
}
if (pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER) {
// This is an answer
_debug("Got SDP answer %s\n", pjsip_rx_data_get_info(rdata));
status = pjmedia_sdp_neg_set_remote_answer(inv->pool, inv->neg, remote_sdp);
......@@ -355,7 +362,6 @@ void Sdp::set_negotiated_sdp (const pjmedia_sdp_session *sdp)
std::string type, dir;
CodecsMap codecs_list;
CodecsMap::iterator iter;
AudioCodec *codec_to_add;
pjmedia_sdp_attr *attribute;
pjmedia_sdp_rtpmap *rtpmap;
......
......@@ -108,7 +108,7 @@ class Sdp {
* @param rdata The remote data
*/
pj_status_t check_incoming_sdp(pjsip_inv_session *inv, pjsip_rx_data *rdata);
pj_status_t check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
/*
* Remove all media in the session media vector.
......
......@@ -1954,7 +1954,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
}
// After 2xx is sent/received.
else if (inv->state == PJSIP_INV_STATE_CONNECTING) {
status = call->getLocalSDP()->check_incoming_sdp (inv, rdata);
status = call->getLocalSDP()->check_sdp_answer (inv, rdata);
if (status != PJ_SUCCESS) {
_debug("Failed to check_incoming_sdp in call_on_state_changed\n");
return;
......@@ -2015,31 +2015,6 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
}
int terminate_call_bad_sdp_answer(SIPCall * call, SIPVoIPLink * link)
{
pj_status_t status;
pjsip_tx_data *tdata = NULL;
status = pjsip_inv_end_session(call->getInvSession(), 488, NULL, &tdata);
if (status != PJ_SUCCESS)
return false;
if (tdata == NULL)
return true;
status = pjsip_inv_send_msg (call->getInvSession(), tdata);
if (status != PJ_SUCCESS)
return false;
call->getInvSession()->mod_data[getModId() ] = NULL;
link->terminateOneCall (call->getCallId());
link->removeCall (call->getCallId());
}
// This callback is called after SDP offer/answer session has completed.
void call_on_media_update (pjsip_inv_session *inv, pj_status_t status)
{
......@@ -2066,8 +2041,8 @@ void call_on_media_update (pjsip_inv_session *inv, pj_status_t status)
if (status != PJ_SUCCESS) {
_debug ("Error while negotiating the offer\n");
//terminate_call_bad_sdp_answer(call, link);
link->hangup(call->getCallId());
Manager::instance().callFailure(call->getCallId());
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment