Commit 63a40673 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #27724: sdp: use published IP address for STUN

parent 7fb07ff3
......@@ -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);
......
......@@ -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_;
......
......@@ -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();
......
Supports Markdown
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