Commit de3b93a1 authored by Tristan Matthews's avatar Tristan Matthews

* #14434: sip: don't start call if offer was not created

parent 3c9925ad
......@@ -351,12 +351,19 @@ int Sdp::createLocalSession(const vector<int> &selectedAudioCodecs, const vector
return pjmedia_sdp_validate(localSession_);
}
void Sdp::createOffer(const vector<int> &selectedCodecs, const vector<map<string, string> > &videoCodecs)
bool
Sdp::createOffer(const vector<int> &selectedCodecs,
const vector<map<string, string> > &videoCodecs)
{
if (createLocalSession(selectedCodecs, videoCodecs) != PJ_SUCCESS)
bool result = true;
if (createLocalSession(selectedCodecs, videoCodecs) != PJ_SUCCESS) {
ERROR("Failed to create initial offer");
else if (pjmedia_sdp_neg_create_w_local_offer(memPool_, localSession_, &negotiator_) != PJ_SUCCESS)
result = false;
} else if (pjmedia_sdp_neg_create_w_local_offer(memPool_, localSession_, &negotiator_) != PJ_SUCCESS) {
ERROR("Failed to create an initial SDP negotiator");
result = false;
}
return result;
}
void Sdp::receiveOffer(const pjmedia_sdp_session* remote,
......
......@@ -118,8 +118,11 @@ class Sdp {
/*
* On building an invite outside a dialog, build the local offer and create the
* SDP negotiator instance with it.
* @returns true if offer was created, false otherwise
*/
void createOffer(const std::vector<int> &selectedCodecs, const std::vector<std::map<std::string, std::string> > &videoCodecs);
bool
createOffer(const std::vector<int> &selectedCodecs,
const std::vector<std::map<std::string, std::string> > &videoCodecs);
/*
* On receiving an invite outside a dialog, build the local offer and create the
......
......@@ -785,10 +785,11 @@ Call *SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to
call->getAudioRtp().start(ac);
// Building the local SDP offer
call->getLocalSDP()->setLocalIP(localAddress);
call->getLocalSDP()->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs());
Sdp *localSDP = call->getLocalSDP();
localSDP->setLocalIP(localAddress);
const bool created = localSDP->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs());
if (!SIPStartCall(call)) {
if (not created or not SIPStartCall(call)) {
delete call;
throw VoipLinkException("Could not create new call");
}
......@@ -847,10 +848,11 @@ Call *SIPVoIPLink::newRegisteredAccountCall(const std::string& id, const std::st
call->initRecFilename(toUrl);
call->getLocalSDP()->setLocalIP(addrSdp);
call->getLocalSDP()->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs());
Sdp *localSDP = call->getLocalSDP();
localSDP->setLocalIP(addrSdp);
const bool created = localSDP->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs());
if (!SIPStartCall(call)) {
if (not created or not SIPStartCall(call)) {
delete call;
throw VoipLinkException("Could not send outgoing INVITE request for new call");
}
......@@ -1478,10 +1480,11 @@ void sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer)
setCallMediaLocal(call, localAddress);
call->getLocalSDP()->setLocalIP(addrSdp);
call->getLocalSDP()->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs());
*p_offer = call->getLocalSDP()->getLocalSdpSession();
Sdp *localSDP = call->getLocalSDP();
localSDP->setLocalIP(addrSdp);
const bool created = localSDP->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs());
if (created)
*p_offer = localSDP->getLocalSdpSession();
}
// This callback is called after SDP offer/answer session has completed.
......
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