Commit b680e4f1 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Adrien Béraud

sipcall: fix non used public address for media transport

Move the registering of public IP for media transport (ICE)
at the right place: after its initialization.
Before, the ICE register method was silently return immediatly
without registering.

This has effect to give a better connection (real P2P) if possible.

A error log has also been added in the ICE publc IP register method
to detect such case.

Change-Id: If88a6801aa55833f687cd552033efe579ab29393
parent e0343a24
......@@ -643,8 +643,10 @@ IceTransport::getLocalCandidatesAddr(unsigned comp_id) const
bool
IceTransport::registerPublicIP(unsigned compId, const IpAddr& publicIP)
{
if (not isInitialized())
if (not isInitialized()) {
RING_ERR("IceTransport::registerPublicIP() called on non initialized transport");
return false;
}
// Find the local candidate corresponding to local host,
// then register a rflx candidate using given public address
......
......@@ -739,6 +739,11 @@ SIPCall::setupLocalSDPFromIce()
return;
}
if (const auto& ip = getSIPAccount().getPublishedIpAddress()) {
for (unsigned compId = 1; compId <= media_tr->getComponentCount(); ++compId)
media_tr->registerPublicIP(compId, ip);
}
RING_WARN("[call:%s] fill SDP with ICE transport %p", getCallId().c_str(), media_tr);
sdp_->addIceAttributes(media_tr->getLocalAttributes());
......@@ -1143,13 +1148,6 @@ SIPCall::initIceMediaTransport(bool master, unsigned channel_num)
tmpMediaTransport_ = iceTransportFactory.createTransport(getCallId().c_str(),
channel_num, master,
getAccount().getIceOptions());
if (tmpMediaTransport_) {
// Add account's public IP as host candidate
if (const auto& publicIP = getSIPAccount().getPublishedIpAddress()) {
for (unsigned compId = 1; compId <= tmpMediaTransport_->getComponentCount(); ++compId)
tmpMediaTransport_->registerPublicIP(compId, publicIP);
}
}
return static_cast<bool>(tmpMediaTransport_);
}
......
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