From de3b93a1e5beb7be0bffe3f2c7ed4dfaff44c426 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Tue, 7 Aug 2012 13:23:37 -0400 Subject: [PATCH] * #14434: sip: don't start call if offer was not created --- daemon/src/sip/sdp.cpp | 13 ++++++++++--- daemon/src/sip/sdp.h | 5 ++++- daemon/src/sip/sipvoiplink.cpp | 23 +++++++++++++---------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index c2607c2d41..62c457c9a0 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 cfa898ae64..13254e1e1b 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 380e08a318..b5cf35624e 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. -- GitLab