diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index c2607c2d41f1862cb1f5635f1582188cc3381ff8..62c457c9a09725c9429c8eada32a3ef5435d547a 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -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, diff --git a/daemon/src/sip/sdp.h b/daemon/src/sip/sdp.h index cfa898ae64aaa8e70514cce9bd43b329487eb426..13254e1e1b9ecf6d96667f6f243d798122157618 100644 --- a/daemon/src/sip/sdp.h +++ b/daemon/src/sip/sdp.h @@ -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 diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 380e08a3185e1f3e7eafa82851d2c1267b9d707b..b5cf35624e616c62df218a974601b336b4fc27a0 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -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.