diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 69a2bc4acc..3fdf607bf3 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -43,8 +43,6 @@ rtc_library("rtc_p2p") { "base/ice_controller_interface.h", "base/ice_credentials_iterator.cc", "base/ice_credentials_iterator.h", - "base/ice_switch_reason.cc", - "base/ice_switch_reason.h", "base/ice_transport_internal.cc", "base/ice_transport_internal.h", "base/p2p_constants.cc", diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc index edd5681f5f..9025fbe2a7 100644 --- a/p2p/base/basic_ice_controller.cc +++ b/p2p/base/basic_ice_controller.cc @@ -415,7 +415,7 @@ BasicIceController::GetBestWritableConnectionPerNetwork() const { IceControllerInterface::SwitchResult BasicIceController::HandleInitialSelectDampening( - IceSwitchReason reason, + IceControllerEvent reason, const Connection* new_connection) { if (!field_trials_->initial_select_dampening.has_value() && !field_trials_->initial_select_dampening_ping_received.has_value()) { @@ -464,13 +464,13 @@ BasicIceController::HandleInitialSelectDampening( } RTC_LOG(LS_INFO) << "delay initial selection up to " << min_delay << "ms"; - return {.connection = absl::nullopt, - .recheck_event = IceControllerEvent( - IceSwitchReason::ICE_CONTROLLER_RECHECK, min_delay)}; + reason.type = IceControllerEvent::ICE_CONTROLLER_RECHECK; + reason.recheck_delay_ms = min_delay; + return {absl::nullopt, reason}; } IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( - IceSwitchReason reason, + IceControllerEvent reason, const Connection* new_connection) { if (!ReadyToSend(new_connection) || selected_connection_ == new_connection) { return {absl::nullopt, absl::nullopt}; @@ -503,8 +503,9 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( // threshold, the new connection is in a better receiving state than the // currently selected connection. So we need to re-check whether it needs // to be switched at a later time. - recheck_event.emplace(reason, - config_.receiving_switching_delay_or_default()); + recheck_event = reason; + recheck_event->recheck_delay_ms = + config_.receiving_switching_delay_or_default(); } if (cmp < 0) { @@ -523,7 +524,7 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( } IceControllerInterface::SwitchResult -BasicIceController::SortAndSwitchConnection(IceSwitchReason reason) { +BasicIceController::SortAndSwitchConnection(IceControllerEvent reason) { // Find the best alternative connection by sorting. It is important to note // that amongst equal preference, writable connections, this will choose the // one whose estimated latency is lowest. So it is the only one that we diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h index b941a0dd7e..e8861952c3 100644 --- a/p2p/base/basic_ice_controller.h +++ b/p2p/base/basic_ice_controller.h @@ -46,9 +46,9 @@ class BasicIceController : public IceControllerInterface { NominationMode mode, IceMode remote_ice_mode) const override; - SwitchResult ShouldSwitchConnection(IceSwitchReason reason, + SwitchResult ShouldSwitchConnection(IceControllerEvent reason, const Connection* connection) override; - SwitchResult SortAndSwitchConnection(IceSwitchReason reason) override; + SwitchResult SortAndSwitchConnection(IceControllerEvent reason) override; std::vector PruneConnections() override; @@ -136,7 +136,7 @@ class BasicIceController : public IceControllerInterface { absl::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const; - SwitchResult HandleInitialSelectDampening(IceSwitchReason reason, + SwitchResult HandleInitialSelectDampening(IceControllerEvent reason, const Connection* new_connection); std::function ice_transport_state_func_; diff --git a/p2p/base/ice_controller_interface.cc b/p2p/base/ice_controller_interface.cc index 9eae922d2e..6d9bb85343 100644 --- a/p2p/base/ice_controller_interface.cc +++ b/p2p/base/ice_controller_interface.cc @@ -12,71 +12,46 @@ #include -#include "p2p/base/ice_switch_reason.h" - namespace cricket { std::string IceControllerEvent::ToString() const { - std::string str = IceSwitchReasonToString(reason); - if (recheck_delay_ms) { - str += " (after delay: " + std::to_string(recheck_delay_ms) + ")"; - } - return str; -} - -// TODO(bugs.webrtc.org/14125) remove when Type is replaced with -// IceSwitchReason. -IceControllerEvent::Type IceControllerEvent::FromIceSwitchReason( - IceSwitchReason reason) { - switch (reason) { - case IceSwitchReason::REMOTE_CANDIDATE_GENERATION_CHANGE: - return IceControllerEvent::REMOTE_CANDIDATE_GENERATION_CHANGE; - case IceSwitchReason::NETWORK_PREFERENCE_CHANGE: - return IceControllerEvent::NETWORK_PREFERENCE_CHANGE; - case IceSwitchReason::NEW_CONNECTION_FROM_LOCAL_CANDIDATE: - return IceControllerEvent::NEW_CONNECTION_FROM_LOCAL_CANDIDATE; - case IceSwitchReason::NEW_CONNECTION_FROM_REMOTE_CANDIDATE: - return IceControllerEvent::NEW_CONNECTION_FROM_REMOTE_CANDIDATE; - case IceSwitchReason::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS: - return IceControllerEvent::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS; - case IceSwitchReason::NOMINATION_ON_CONTROLLED_SIDE: - return IceControllerEvent::NOMINATION_ON_CONTROLLED_SIDE; - case IceSwitchReason::DATA_RECEIVED: - return IceControllerEvent::DATA_RECEIVED; - case IceSwitchReason::CONNECT_STATE_CHANGE: - return IceControllerEvent::CONNECT_STATE_CHANGE; - case IceSwitchReason::SELECTED_CONNECTION_DESTROYED: - return IceControllerEvent::SELECTED_CONNECTION_DESTROYED; - case IceSwitchReason::ICE_CONTROLLER_RECHECK: - return IceControllerEvent::ICE_CONTROLLER_RECHECK; - } -} - -// TODO(bugs.webrtc.org/14125) remove when Type is replaced with -// IceSwitchReason. -IceSwitchReason IceControllerEvent::FromType(IceControllerEvent::Type type) { + std::string reason; switch (type) { - case IceControllerEvent::REMOTE_CANDIDATE_GENERATION_CHANGE: - return IceSwitchReason::REMOTE_CANDIDATE_GENERATION_CHANGE; - case IceControllerEvent::NETWORK_PREFERENCE_CHANGE: - return IceSwitchReason::NETWORK_PREFERENCE_CHANGE; - case IceControllerEvent::NEW_CONNECTION_FROM_LOCAL_CANDIDATE: - return IceSwitchReason::NEW_CONNECTION_FROM_LOCAL_CANDIDATE; - case IceControllerEvent::NEW_CONNECTION_FROM_REMOTE_CANDIDATE: - return IceSwitchReason::NEW_CONNECTION_FROM_REMOTE_CANDIDATE; - case IceControllerEvent::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS: - return IceSwitchReason::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS; - case IceControllerEvent::NOMINATION_ON_CONTROLLED_SIDE: - return IceSwitchReason::NOMINATION_ON_CONTROLLED_SIDE; - case IceControllerEvent::DATA_RECEIVED: - return IceSwitchReason::DATA_RECEIVED; - case IceControllerEvent::CONNECT_STATE_CHANGE: - return IceSwitchReason::CONNECT_STATE_CHANGE; - case IceControllerEvent::SELECTED_CONNECTION_DESTROYED: - return IceSwitchReason::SELECTED_CONNECTION_DESTROYED; - case IceControllerEvent::ICE_CONTROLLER_RECHECK: - return IceSwitchReason::ICE_CONTROLLER_RECHECK; + case REMOTE_CANDIDATE_GENERATION_CHANGE: + reason = "remote candidate generation maybe changed"; + break; + case NETWORK_PREFERENCE_CHANGE: + reason = "network preference changed"; + break; + case NEW_CONNECTION_FROM_LOCAL_CANDIDATE: + reason = "new candidate pairs created from a new local candidate"; + break; + case NEW_CONNECTION_FROM_REMOTE_CANDIDATE: + reason = "new candidate pairs created from a new remote candidate"; + break; + case NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS: + reason = "a new candidate pair created from an unknown remote address"; + break; + case NOMINATION_ON_CONTROLLED_SIDE: + reason = "nomination on the controlled side"; + break; + case DATA_RECEIVED: + reason = "data received"; + break; + case CONNECT_STATE_CHANGE: + reason = "candidate pair state changed"; + break; + case SELECTED_CONNECTION_DESTROYED: + reason = "selected candidate pair destroyed"; + break; + case ICE_CONTROLLER_RECHECK: + reason = "ice-controller-request-recheck"; + break; } + if (recheck_delay_ms) { + reason += " (after delay: " + std::to_string(recheck_delay_ms) + ")"; + } + return reason; } } // namespace cricket diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h index 4bdbf82972..a33315a338 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -15,9 +15,7 @@ #include #include -#include "absl/types/optional.h" #include "p2p/base/connection.h" -#include "p2p/base/ice_switch_reason.h" #include "p2p/base/ice_transport_internal.h" namespace cricket { @@ -25,7 +23,6 @@ namespace cricket { struct IceFieldTrials; // Forward declaration to avoid circular dependency. struct IceControllerEvent { - // TODO(bugs.webrtc.org/14125) replace with IceSwitchReason. enum Type { REMOTE_CANDIDATE_GENERATION_CHANGE, NETWORK_PREFERENCE_CHANGE, @@ -42,22 +39,10 @@ struct IceControllerEvent { ICE_CONTROLLER_RECHECK, }; - IceControllerEvent(IceSwitchReason _reason, int _recheck_delay_ms) - : reason(_reason), - type(FromIceSwitchReason(_reason)), - recheck_delay_ms(_recheck_delay_ms) {} - - [[deprecated("bugs.webrtc.org/14125")]] IceControllerEvent( - const Type& _type) // NOLINT: runtime/explicit - : reason(FromType(_type)), type(_type) {} - - static Type FromIceSwitchReason(IceSwitchReason reason); - static IceSwitchReason FromType(Type type); - + IceControllerEvent(const Type& _type) // NOLINT: runtime/explicit + : type(_type) {} std::string ToString() const; - IceSwitchReason reason; - // TODO(bugs.webrtc.org/14125) replace usage with IceSwitchReason. Type type; int recheck_delay_ms = 0; }; @@ -149,29 +134,13 @@ class IceControllerInterface { virtual void MarkConnectionPinged(const Connection* con) = 0; // Check if we should switch to `connection`. - // This method is called for IceSwitchReasons that can switch directly + // This method is called for IceControllerEvent's that can switch directly // i.e without resorting. - // TODO(bugs.webrtc.org/14125) change to pure virtual. - virtual SwitchResult ShouldSwitchConnection(IceSwitchReason reason, - const Connection* connection) { - return {absl::nullopt, absl::nullopt}; - } - [[deprecated("bugs.webrtc.org/14125")]] virtual SwitchResult - ShouldSwitchConnection(IceControllerEvent reason, - const Connection* connection) { - return ShouldSwitchConnection(IceControllerEvent::FromType(reason.type), - connection); - } + virtual SwitchResult ShouldSwitchConnection(IceControllerEvent reason, + const Connection* connection) = 0; // Sort connections and check if we should switch. - // TODO(bugs.webrtc.org/14125) change to pure virtual. - virtual SwitchResult SortAndSwitchConnection(IceSwitchReason reason) { - return {absl::nullopt, absl::nullopt}; - } - [[deprecated("bugs.webrtc.org/14125")]] virtual SwitchResult - SortAndSwitchConnection(IceControllerEvent reason) { - return SortAndSwitchConnection(IceControllerEvent::FromType(reason.type)); - } + virtual SwitchResult SortAndSwitchConnection(IceControllerEvent reason) = 0; // Prune connections. virtual std::vector PruneConnections() = 0; diff --git a/p2p/base/ice_switch_reason.cc b/p2p/base/ice_switch_reason.cc deleted file mode 100644 index 61f0fa7d5b..0000000000 --- a/p2p/base/ice_switch_reason.cc +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2022 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "p2p/base/ice_switch_reason.h" - -#include - -namespace cricket { - -std::string IceSwitchReasonToString(IceSwitchReason reason) { - switch (reason) { - case IceSwitchReason::REMOTE_CANDIDATE_GENERATION_CHANGE: - return "remote candidate generation maybe changed"; - case IceSwitchReason::NETWORK_PREFERENCE_CHANGE: - return "network preference changed"; - case IceSwitchReason::NEW_CONNECTION_FROM_LOCAL_CANDIDATE: - return "new candidate pairs created from a new local candidate"; - case IceSwitchReason::NEW_CONNECTION_FROM_REMOTE_CANDIDATE: - return "new candidate pairs created from a new remote candidate"; - case IceSwitchReason::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS: - return "a new candidate pair created from an unknown remote address"; - case IceSwitchReason::NOMINATION_ON_CONTROLLED_SIDE: - return "nomination on the controlled side"; - case IceSwitchReason::DATA_RECEIVED: - return "data received"; - case IceSwitchReason::CONNECT_STATE_CHANGE: - return "candidate pair state changed"; - case IceSwitchReason::SELECTED_CONNECTION_DESTROYED: - return "selected candidate pair destroyed"; - case IceSwitchReason::ICE_CONTROLLER_RECHECK: - return "ice-controller-request-recheck"; - default: - return "unknown"; - } -} - -} // namespace cricket diff --git a/p2p/base/ice_switch_reason.h b/p2p/base/ice_switch_reason.h deleted file mode 100644 index 2c4fe31884..0000000000 --- a/p2p/base/ice_switch_reason.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef P2P_BASE_ICE_SWITCH_REASON_H_ -#define P2P_BASE_ICE_SWITCH_REASON_H_ - -#include - -namespace cricket { - -enum class IceSwitchReason { - REMOTE_CANDIDATE_GENERATION_CHANGE, - NETWORK_PREFERENCE_CHANGE, - NEW_CONNECTION_FROM_LOCAL_CANDIDATE, - NEW_CONNECTION_FROM_REMOTE_CANDIDATE, - NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS, - NOMINATION_ON_CONTROLLED_SIDE, - DATA_RECEIVED, - CONNECT_STATE_CHANGE, - SELECTED_CONNECTION_DESTROYED, - // The ICE_CONTROLLER_RECHECK enum value lets an IceController request - // P2PTransportChannel to recheck a switch periodically without an event - // taking place. - ICE_CONTROLLER_RECHECK, -}; - -std::string IceSwitchReasonToString(IceSwitchReason reason); - -} // namespace cricket - -#endif // P2P_BASE_ICE_SWITCH_REASON_H_ diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index fd79d3e72b..c1e4cf7b7c 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -284,7 +284,7 @@ void P2PTransportChannel::AddConnection(Connection* connection) { bool P2PTransportChannel::MaybeSwitchSelectedConnection( Connection* new_connection, - IceSwitchReason reason) { + IceControllerEvent reason) { RTC_DCHECK_RUN_ON(network_thread_); return MaybeSwitchSelectedConnection( @@ -292,12 +292,12 @@ bool P2PTransportChannel::MaybeSwitchSelectedConnection( } bool P2PTransportChannel::MaybeSwitchSelectedConnection( - IceSwitchReason reason, + IceControllerEvent reason, IceControllerInterface::SwitchResult result) { RTC_DCHECK_RUN_ON(network_thread_); if (result.connection.has_value()) { RTC_LOG(LS_INFO) << "Switching selected connection due to: " - << IceSwitchReasonToString(reason); + << reason.ToString(); SwitchSelectedConnection(FromIceController(*result.connection), reason); } @@ -309,7 +309,7 @@ bool P2PTransportChannel::MaybeSwitchSelectedConnection( network_thread_->PostDelayedTask( ToQueuedTask(task_safety_, [this, recheck = *result.recheck_event]() { - SortConnectionsAndUpdateState(recheck.reason); + SortConnectionsAndUpdateState(recheck); }), result.recheck_event->recheck_delay_ms); } @@ -521,7 +521,7 @@ void P2PTransportChannel::SetRemoteIceParameters( } // Updating the remote ICE candidate generation could change the sort order. RequestSortAndStateUpdate( - IceSwitchReason::REMOTE_CANDIDATE_GENERATION_CHANGE); + IceControllerEvent::REMOTE_CANDIDATE_GENERATION_CHANGE); } void P2PTransportChannel::SetRemoteIceMode(IceMode mode) { @@ -675,7 +675,7 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { if (config_.network_preference != config.network_preference) { config_.network_preference = config.network_preference; - RequestSortAndStateUpdate(IceSwitchReason::NETWORK_PREFERENCE_CHANGE); + RequestSortAndStateUpdate(IceControllerEvent::NETWORK_PREFERENCE_CHANGE); RTC_LOG(LS_INFO) << "Set network preference to " << (config_.network_preference.has_value() ? config_.network_preference.value() @@ -979,7 +979,7 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession* session, } SortConnectionsAndUpdateState( - IceSwitchReason::NEW_CONNECTION_FROM_LOCAL_CANDIDATE); + IceControllerEvent::NEW_CONNECTION_FROM_LOCAL_CANDIDATE); } // A new candidate is available, let listeners know @@ -1159,7 +1159,7 @@ void P2PTransportChannel::OnUnknownAddress(PortInterface* port, // after sending the response since it could (in principle) delete the // connection in question. SortConnectionsAndUpdateState( - IceSwitchReason::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS); + IceControllerEvent::NEW_CONNECTION_FROM_UNKNOWN_REMOTE_ADDRESS); } void P2PTransportChannel::OnCandidateFilterChanged(uint32_t prev_filter, @@ -1211,10 +1211,11 @@ void P2PTransportChannel::OnNominated(Connection* conn) { // TODO(qingsi): RequestSortAndStateUpdate will eventually call // MaybeSwitchSelectedConnection again. Rewrite this logic. if (MaybeSwitchSelectedConnection( - conn, IceSwitchReason::NOMINATION_ON_CONTROLLED_SIDE)) { + conn, IceControllerEvent::NOMINATION_ON_CONTROLLED_SIDE)) { // Now that we have selected a connection, it is time to prune other // connections and update the read/write state of the channel. - RequestSortAndStateUpdate(IceSwitchReason::NOMINATION_ON_CONTROLLED_SIDE); + RequestSortAndStateUpdate( + IceControllerEvent::NOMINATION_ON_CONTROLLED_SIDE); } else { RTC_LOG(LS_INFO) << "Not switching the selected connection on controlled side yet: " @@ -1364,7 +1365,7 @@ void P2PTransportChannel::FinishAddingRemoteCandidate( // Resort the connections list, which may have new elements. SortConnectionsAndUpdateState( - IceSwitchReason::NEW_CONNECTION_FROM_REMOTE_CANDIDATE); + IceControllerEvent::NEW_CONNECTION_FROM_REMOTE_CANDIDATE); } void P2PTransportChannel::RemoveRemoteCandidate( @@ -1717,7 +1718,7 @@ void P2PTransportChannel::UpdateConnectionStates() { // Prepare for best candidate sorting. void P2PTransportChannel::RequestSortAndStateUpdate( - IceSwitchReason reason_to_sort) { + IceControllerEvent reason_to_sort) { RTC_DCHECK_RUN_ON(network_thread_); if (!sort_dirty_) { network_thread_->PostTask( @@ -1767,7 +1768,7 @@ bool P2PTransportChannel::PresumedWritable(const Connection* conn) const { // Sort the available connections to find the best one. We also monitor // the number of available connections and the current state. void P2PTransportChannel::SortConnectionsAndUpdateState( - IceSwitchReason reason_to_sort) { + IceControllerEvent reason_to_sort) { RTC_DCHECK_RUN_ON(network_thread_); // Make sure the connection states are up-to-date since this affects how they @@ -1849,7 +1850,7 @@ rtc::NetworkRoute P2PTransportChannel::ConfigureNetworkRoute( // Change the selected connection, and let listeners know. void P2PTransportChannel::SwitchSelectedConnection(Connection* conn, - IceSwitchReason reason) { + IceControllerEvent reason) { RTC_DCHECK_RUN_ON(network_thread_); // Note: if conn is NULL, the previous `selected_connection_` has been // destroyed, so don't use it. @@ -1898,7 +1899,7 @@ void P2PTransportChannel::SwitchSelectedConnection(Connection* conn, // Create event for candidate pair change. if (selected_connection_) { CandidatePairChangeEvent pair_change; - pair_change.reason = IceSwitchReasonToString(reason); + pair_change.reason = reason.ToString(); pair_change.selected_candidate_pair = *GetSelectedCandidatePair(); pair_change.last_data_received_ms = selected_connection_->last_data_received(); @@ -2028,7 +2029,7 @@ void P2PTransportChannel::MaybeStopPortAllocatorSessions() { // RTC_RUN_ON(network_thread_) void P2PTransportChannel::OnSelectedConnectionDestroyed() { RTC_LOG(LS_INFO) << "Selected connection destroyed. Will choose a new one."; - IceSwitchReason reason = IceSwitchReason::SELECTED_CONNECTION_DESTROYED; + IceControllerEvent reason = IceControllerEvent::SELECTED_CONNECTION_DESTROYED; SwitchSelectedConnection(nullptr, reason); RequestSortAndStateUpdate(reason); } @@ -2158,8 +2159,8 @@ void P2PTransportChannel::OnConnectionStateChange(Connection* connection) { // We have to unroll the stack before doing this because we may be changing // the state of connections while sorting. RequestSortAndStateUpdate( - IceSwitchReason::CONNECT_STATE_CHANGE); // "candidate pair state - // changed"); + IceControllerEvent::CONNECT_STATE_CHANGE); // "candidate pair state + // changed"); } // When a connection is removed, edit it out, and then update our best @@ -2288,7 +2289,8 @@ void P2PTransportChannel::OnReadPacket(Connection* connection, // May need to switch the sending connection based on the receiving media path // if this is the controlled side. if (ice_role_ == ICEROLE_CONTROLLED) { - MaybeSwitchSelectedConnection(connection, IceSwitchReason::DATA_RECEIVED); + MaybeSwitchSelectedConnection(connection, + IceControllerEvent::DATA_RECEIVED); } } diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h index cf7de90d9e..a9a1886a1d 100644 --- a/p2p/base/p2p_transport_channel.h +++ b/p2p/base/p2p_transport_channel.h @@ -49,7 +49,6 @@ #include "p2p/base/connection.h" #include "p2p/base/ice_controller_factory_interface.h" #include "p2p/base/ice_controller_interface.h" -#include "p2p/base/ice_switch_reason.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_transport_channel_ice_field_trials.h" @@ -258,16 +257,16 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { bool ReadyToSend(const Connection* connection) const; bool PresumedWritable(const Connection* conn) const; void UpdateConnectionStates(); - void RequestSortAndStateUpdate(IceSwitchReason reason_to_sort); + void RequestSortAndStateUpdate(IceControllerEvent reason_to_sort); // Start pinging if we haven't already started, and we now have a connection // that's pingable. void MaybeStartPinging(); - void SortConnectionsAndUpdateState(IceSwitchReason reason_to_sort); + void SortConnectionsAndUpdateState(IceControllerEvent reason_to_sort); void SortConnections(); void SortConnectionsIfNeeded(); rtc::NetworkRoute ConfigureNetworkRoute(const Connection* conn); - void SwitchSelectedConnection(Connection* conn, IceSwitchReason reason); + void SwitchSelectedConnection(Connection* conn, IceControllerEvent reason); void UpdateState(); void HandleAllTimedOut(); void MaybeStopPortAllocatorSessions(); @@ -342,9 +341,9 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { // Returns true if the new_connection is selected for transmission. bool MaybeSwitchSelectedConnection(Connection* new_connection, - IceSwitchReason reason); + IceControllerEvent reason); bool MaybeSwitchSelectedConnection( - IceSwitchReason reason, + IceControllerEvent reason, IceControllerInterface::SwitchResult result); void PruneConnections(); diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 2cd1bcc2c9..aaa5f6ba87 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -6099,13 +6099,15 @@ class ForgetLearnedStateController : public cricket::BasicIceController { const cricket::IceControllerFactoryArgs& args) : cricket::BasicIceController(args) {} - SwitchResult SortAndSwitchConnection(IceSwitchReason reason) override { + SwitchResult SortAndSwitchConnection(IceControllerEvent reason) override { auto result = cricket::BasicIceController::SortAndSwitchConnection(reason); if (forget_connnection_) { result.connections_to_forget_state_on.push_back(forget_connnection_); forget_connnection_ = nullptr; } - result.recheck_event.emplace(IceSwitchReason::ICE_CONTROLLER_RECHECK, 100); + result.recheck_event = + IceControllerEvent(IceControllerEvent::ICE_CONTROLLER_RECHECK); + result.recheck_event->recheck_delay_ms = 100; return result; }