diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index 4ffae97c2f6867d7bb1d7c33173a1d0de5eeea49..5d27d3b612ba9fb2946a6662fb4f44b5ffe4e356 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -65,7 +65,7 @@ Sdp::Sdp(pj_pool_t *pool) , video_codec_list_() , sessionAudioMedia_() , sessionVideoMedia_() - , localIpAddr_() + , publishedIpAddr_() , remoteIpAddr_() , localAudioDataPort_(0) , localAudioControlPort_(0) @@ -323,7 +323,7 @@ Sdp::setMediaDescriptorLines(bool audio) void Sdp::addRTCPAttribute(pjmedia_sdp_media *med) { std::ostringstream os; - os << localIpAddr_ << ":" << localAudioControlPort_; + os << publishedIpAddr_ << ":" << localAudioControlPort_; const std::string str(os.str()); pj_str_t input_str = pj_str((char*) str.c_str()); pj_sockaddr outputAddr; @@ -424,7 +424,7 @@ int Sdp::createLocalSession(const vector<int> &selectedAudioCodecs, const vector localSession_->origin.id = tv.sec + 2208988800UL; localSession_->origin.net_type = pj_str((char*) "IN"); localSession_->origin.addr_type = pj_str((char*) "IP4"); - localSession_->origin.addr = pj_str((char*) localIpAddr_.c_str()); + localSession_->origin.addr = pj_str((char*) publishedIpAddr_.c_str()); localSession_->name = pj_str((char*) PACKAGE); diff --git a/daemon/src/sip/sdp.h b/daemon/src/sip/sdp.h index fe6ca012e26998e5f58f0e7838be2dacde817064..a731c14d528b7447ec08896e6af91cfebaddf938 100644 --- a/daemon/src/sip/sdp.h +++ b/daemon/src/sip/sdp.h @@ -153,15 +153,15 @@ class Sdp { /* * Write accessor. Set the local IP address that will be used in the sdp session */ - void setLocalIP(const std::string &ip_addr) { - localIpAddr_ = ip_addr; + void setPublishedIP(const std::string &ip_addr) { + publishedIpAddr_ = ip_addr; } /* * Read accessor. Get the local IP address */ - std::string getLocalIP() const { - return localIpAddr_; + std::string getPublishedIP() const { + return publishedIpAddr_; } void setLocalPublishedAudioPort(int port) { @@ -311,7 +311,7 @@ class Sdp { std::vector<sfl::AudioCodec *> sessionAudioMedia_; std::vector<std::string> sessionVideoMedia_; - std::string localIpAddr_; + std::string publishedIpAddr_; std::string remoteIpAddr_; int localAudioDataPort_; diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index b8ba1d0b39e584fd705ecd0ba8ff2147ee0837be..18def26cb903cff846065bfdb2f442a75c76a0f6 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -227,6 +227,7 @@ void updateSDPFromSTUN(SIPCall &call, SIPAccount &account, const SipTransport &t account.setPublishedAddress(pj_inet_ntoa(stunPorts[0].sin_addr)); call.getLocalSDP()->updatePorts(stunPorts); + call.getLocalSDP()->setPublishedIP(account.getPublishedAddress()); } catch (const std::runtime_error &e) { ERROR("%s", e.what()); } @@ -343,7 +344,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) setCallMediaLocal(call, addrToUse); - call->getLocalSDP()->setLocalIP(addrSdp); + call->getLocalSDP()->setPublishedIP(addrSdp); call->getAudioRtp().initConfig(); try { @@ -932,7 +933,7 @@ Call *SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to // Building the local SDP offer Sdp *localSDP = call->getLocalSDP(); - localSDP->setLocalIP(localAddress); + localSDP->setPublishedIP(localAddress); const bool created = localSDP->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs()); if (not created or not SIPStartCall(call)) { @@ -1001,7 +1002,7 @@ Call *SIPVoIPLink::newRegisteredAccountCall(const std::string& id, const std::st call->initRecFilename(toUrl); Sdp *localSDP = call->getLocalSDP(); - localSDP->setLocalIP(addrSdp); + localSDP->setPublishedIP(addrSdp); const bool created = localSDP->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs()); if (not created or not SIPStartCall(call)) { @@ -1021,8 +1022,11 @@ SIPVoIPLink::answer(Call *call) SIPCall *sipCall = static_cast<SIPCall*>(call); if (!sipCall->inv->neg) { WARN("Negotiator is NULL, we've received an INVITE without an SDP"); - pjmedia_sdp_session *dummy; + pjmedia_sdp_session *dummy = 0; sdp_create_offer_cb(sipCall->inv, &dummy); + SIPAccount *account = Manager::instance().getSipAccount(sipCall->getAccountId()); + if (account and account->isStunEnabled()) + updateSDPFromSTUN(*sipCall, *account, SIPVoIPLink::instance()->sipTransport); } call->answer(); @@ -1788,7 +1792,7 @@ void sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer) setCallMediaLocal(call, localAddress); Sdp *localSDP = call->getLocalSDP(); - localSDP->setLocalIP(addrSdp); + localSDP->setPublishedIP(addrSdp); const bool created = localSDP->createOffer(account->getActiveAudioCodecs(), account->getActiveVideoCodecs()); if (created) *p_offer = localSDP->getLocalSdpSession();