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 <qingsi@google.com>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22197}
This commit is contained in:
Qingsi Wang
2018-02-26 19:29:05 -08:00
committed by Commit Bot
parent 9c1fb1e389
commit d5e0fcdd97
3 changed files with 3 additions and 2 deletions

View File

@ -536,6 +536,7 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) {
if (config_.network_preference != config.network_preference) { if (config_.network_preference != config.network_preference) {
config_.network_preference = config.network_preference; config_.network_preference = config.network_preference;
RequestSortAndStateUpdate();
RTC_LOG(LS_INFO) << "Set network preference to " RTC_LOG(LS_INFO) << "Set network preference to "
<< (config_.network_preference.has_value() << (config_.network_preference.has_value()
? config_.network_preference.value() ? config_.network_preference.value()

View File

@ -106,7 +106,7 @@ enum class IceCandidatePairState {
// frozen because we have not implemented ICE freezing logic. // 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 { class StunStats {
public: public:
StunStats() = default; StunStats() = default;

View File

@ -322,7 +322,7 @@ void UDPPort::GetStunStats(rtc::Optional<StunStats>* stats) {
} }
void UDPPort::set_stun_keepalive_delay(const rtc::Optional<int>& delay) { void UDPPort::set_stun_keepalive_delay(const rtc::Optional<int>& 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, void UDPPort::OnLocalAddressReady(rtc::AsyncPacketSocket* socket,