From d5e0fcdd97d8bba561335bd8840cda5bd26e8a1f Mon Sep 17 00:00:00 2001 From: Qingsi Wang Date: Mon, 26 Feb 2018 19:29:05 -0800 Subject: [PATCH] Add immediate sorting of candidate pairs after the network preference is configured. An immediate (re)sorting of candidate paris reduces the latency of network switching when it is necessary in ICE after (re)configuring the network preference. A fix of comment and boilerplate code is also included. Bug: None Change-Id: I8685235172d97193ffa6b53d4d2c7796fd01f861 Reviewed-on: https://webrtc-review.googlesource.com/57340 Commit-Queue: Qingsi Wang Reviewed-by: Taylor Brandstetter Cr-Commit-Position: refs/heads/master@{#22197} --- p2p/base/p2ptransportchannel.cc | 1 + p2p/base/port.h | 2 +- p2p/base/stunport.cc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc index 414ff2b764..b728334780 100644 --- a/p2p/base/p2ptransportchannel.cc +++ b/p2p/base/p2ptransportchannel.cc @@ -536,6 +536,7 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { if (config_.network_preference != config.network_preference) { config_.network_preference = config.network_preference; + RequestSortAndStateUpdate(); RTC_LOG(LS_INFO) << "Set network preference to " << (config_.network_preference.has_value() ? config_.network_preference.value() diff --git a/p2p/base/port.h b/p2p/base/port.h index 16fedb8148..ee5fa65b69 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -106,7 +106,7 @@ enum class IceCandidatePairState { // frozen because we have not implemented ICE freezing logic. }; -// Stats that we can return about the port of a connection. +// Stats that we can return about the port of a STUN candidate. class StunStats { public: StunStats() = default; diff --git a/p2p/base/stunport.cc b/p2p/base/stunport.cc index 3ea1f96a7f..9871e4fb61 100644 --- a/p2p/base/stunport.cc +++ b/p2p/base/stunport.cc @@ -322,7 +322,7 @@ void UDPPort::GetStunStats(rtc::Optional* stats) { } void UDPPort::set_stun_keepalive_delay(const rtc::Optional& delay) { - stun_keepalive_delay_ = (delay.has_value() ? delay.value() : KEEPALIVE_DELAY); + stun_keepalive_delay_ = delay.value_or(KEEPALIVE_DELAY); } void UDPPort::OnLocalAddressReady(rtc::AsyncPacketSocket* socket,