Commit a20eff52 authored by Guillaume Roguez's avatar Guillaume Roguez

sipcall: fix nullptr access in remote sdp handling

sipvoiplink code may set remote sdp to nullptr and this case was not
handled correctly later.
This patch fixes that by not using the nullptr to set ICE call transport.
Also moved the code to use the remote sdp, duplicated, into sipcall
for factorization.

Change-Id: I6dcfd3bebed3fd754c91dd7f2cab7ca110d3de09
parent 81279958
...@@ -1000,13 +1000,8 @@ SIPCall::onReceiveOffer(const pjmedia_sdp_session* offer) ...@@ -1000,13 +1000,8 @@ SIPCall::onReceiveOffer(const pjmedia_sdp_session* offer)
acc.getActiveAccountCodecInfoList(MEDIA_AUDIO), acc.getActiveAccountCodecInfoList(MEDIA_AUDIO),
acc.getActiveAccountCodecInfoList(acc.isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE), acc.getActiveAccountCodecInfoList(acc.isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE),
acc.getSrtpKeyExchange(), acc.getSrtpKeyExchange(),
getState() == CallState::HOLD getState() == CallState::HOLD);
); setRemoteSdp(offer);
auto ice_attrs = Sdp::getIceAttributes(offer);
if (not ice_attrs.ufrag.empty() and not ice_attrs.pwd.empty()) {
if (initIceTransport(false))
setupLocalSDPFromIce();
}
sdp_->startNegotiation(); sdp_->startNegotiation();
pjsip_inv_set_sdp_answer(inv.get(), sdp_->getLocalSdpSession()); pjsip_inv_set_sdp_answer(inv.get(), sdp_->getLocalSdpSession());
} }
...@@ -1136,4 +1131,20 @@ SIPCall::merge(const std::shared_ptr<SIPCall>& scall) ...@@ -1136,4 +1131,20 @@ SIPCall::merge(const std::shared_ptr<SIPCall>& scall)
waitForIceAndStartMedia(); waitForIceAndStartMedia();
} }
void
SIPCall::setRemoteSdp(const pjmedia_sdp_session* sdp)
{
if (!sdp)
return;
auto ice_attrs = Sdp::getIceAttributes(sdp);
if (not ice_attrs.ufrag.empty() and not ice_attrs.pwd.empty()) {
if (not getIceTransport()) {
RING_DBG("Initializing ICE transport");
initIceTransport(false);
}
setupLocalSDPFromIce();
}
}
} // namespace ring } // namespace ring
...@@ -224,6 +224,12 @@ class SIPCall : public Call ...@@ -224,6 +224,12 @@ class SIPCall : public Call
peerRegistredName_ = name; peerRegistredName_ = name;
} }
/**
* Give peer SDP to the call for handling
* @param sdp pointer on PJSIP sdp structure, could be nullptr (acts as no-op in such case)
*/
void setRemoteSdp(const pjmedia_sdp_session* sdp);
private: private:
NON_COPYABLE(SIPCall); NON_COPYABLE(SIPCall);
......
...@@ -335,16 +335,8 @@ transaction_request_cb(pjsip_rx_data *rdata) ...@@ -335,16 +335,8 @@ transaction_request_cb(pjsip_rx_data *rdata)
call->getSDP().receiveOffer(r_sdp, call->getSDP().receiveOffer(r_sdp,
account->getActiveAccountCodecInfoList(MEDIA_AUDIO), account->getActiveAccountCodecInfoList(MEDIA_AUDIO),
account->getActiveAccountCodecInfoList(account->isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE), account->getActiveAccountCodecInfoList(account->isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE),
account->getSrtpKeyExchange() account->getSrtpKeyExchange());
); call->setRemoteSdp(r_sdp);
auto ice_attrs = Sdp::getIceAttributes(r_sdp);
if (not ice_attrs.ufrag.empty() and not ice_attrs.pwd.empty()) {
if (not call->getIceTransport()) {
RING_DBG("Initializing ICE transport");
call->initIceTransport(false);
}
call->setupLocalSDPFromIce();
}
pjsip_dialog *dialog = nullptr; pjsip_dialog *dialog = nullptr;
if (pjsip_dlg_create_uas_and_inc_lock(pjsip_ua_instance(), rdata, nullptr, &dialog) != PJ_SUCCESS) { if (pjsip_dlg_create_uas_and_inc_lock(pjsip_ua_instance(), rdata, nullptr, &dialog) != PJ_SUCCESS) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment