From 46367dfbbe9185d713291e8f62d1aaa245868238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Tue, 27 Aug 2019 09:48:16 -0400 Subject: [PATCH] ice: enable aggressive nomination to avoid latencies As specified in RFC 5245, the aggressive negotiation uses the candidates as soon as possibe. This avoid some possible latencies due to the negotiation of an unique pair. For our use case, this avoid a 30 seconds delay during the media negotiation in some cases. Change-Id: I155a0c5f5706908d5e86a08fb2d65e0e3b8c61e2 Gitlab: #140 --- src/ice_transport.h | 4 +++- src/jamidht/jamiaccount.cpp | 2 -- src/jamidht/p2p.cpp | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ice_transport.h b/src/ice_transport.h index 4bf7fec134..1c3a4dc2b6 100644 --- a/src/ice_transport.h +++ b/src/ice_transport.h @@ -71,7 +71,9 @@ struct IceTransportOptions { std::vector<StunServerInfo> stunServers; std::vector<TurnServerInfo> turnServers; bool tcpEnable {false}; // If we want to use TCP - bool aggressive {false}; // If we use the aggressive nomination strategy + // See https://tools.ietf.org/html/rfc5245#section-8.1.1.2 + // Make negotiation aggressive by default to avoid latencies. + bool aggressive {true}; }; struct SDP { diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index a31d83b2a5..7c798d75d4 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -482,7 +482,6 @@ JamiAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: auto ice_config = getIceOptions(); ice_config.tcpEnable = true; - ice_config.aggressive = true; // This will directly select the first candidate. auto ice_tcp = createIceTransport(("sip:" + dev_call->getCallId()).c_str(), ICE_COMPONENTS, true, ice_config); if (not ice_tcp) { JAMI_WARN("Can't create ICE over TCP, will only use UDP"); @@ -2543,7 +2542,6 @@ JamiAccount::incomingCall(dht::IceCandidates&& msg, const std::shared_ptr<dht::c auto ice = createIceTransport(("sip:"+call->getCallId()).c_str(), ICE_COMPONENTS, false, getIceOptions()); auto ice_config = getIceOptions(); ice_config.tcpEnable = true; - ice_config.aggressive = true; // This will directly select the first candidate. auto ice_tcp = createIceTransport(("sip:" + call->getCallId()).c_str(), ICE_COMPONENTS, true, ice_config); std::weak_ptr<SIPCall> wcall = call; diff --git a/src/jamidht/p2p.cpp b/src/jamidht/p2p.cpp index 75b5a9471e..ef90528acc 100644 --- a/src/jamidht/p2p.cpp +++ b/src/jamidht/p2p.cpp @@ -373,7 +373,6 @@ private: auto &iceTransportFactory = Manager::instance().getIceTransportFactory(); auto ice_config = parent_.account.getIceOptions(); ice_config.tcpEnable = true; - ice_config.aggressive = true; // This will directly select the first candidate. auto ice = iceTransportFactory.createTransport(parent_.account.getAccountID().c_str(), 1, false, ice_config); if (ice->waitForInitialization(ICE_INIT_TIMEOUT) <= 0) { @@ -728,7 +727,6 @@ DhtPeerConnector::Impl::answerToRequest(PeerConnectionMsg&& request, auto &iceTransportFactory = Manager::instance().getIceTransportFactory(); auto ice_config = account.getIceOptions(); ice_config.tcpEnable = true; - ice_config.aggressive = true; ice_config.onRecvReady = [iceReady]() { auto& ir = *iceReady; std::lock_guard<std::mutex> lk{ir.mtx}; -- GitLab