diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc index 09bc4f1f5f..32febb5a33 100644 --- a/p2p/base/basic_ice_controller.cc +++ b/p2p/base/basic_ice_controller.cc @@ -92,7 +92,7 @@ bool BasicIceController::HasPingableConnection() const { }); } -std::pair BasicIceController::SelectConnectionToPing( +IceControllerInterface::PingResult BasicIceController::SelectConnectionToPing( int64_t last_ping_sent_ms) { // When the selected connection is not receiving or not writable, or any // active connection has not been pinged enough times, use the weak ping @@ -110,8 +110,8 @@ std::pair BasicIceController::SelectConnectionToPing( if (rtc::TimeMillis() >= last_ping_sent_ms + ping_interval) { conn = FindNextPingableConnection(); } - int delay = std::min(ping_interval, check_receiving_interval()); - return std::make_pair(const_cast(conn), delay); + return std::make_pair(const_cast(conn), + std::min(ping_interval, check_receiving_interval())); } void BasicIceController::MarkConnectionPinged(const Connection* conn) { diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h index ae1339fc03..2e462720f3 100644 --- a/p2p/base/basic_ice_controller.h +++ b/p2p/base/basic_ice_controller.h @@ -40,8 +40,8 @@ class BasicIceController : public IceControllerInterface { bool HasPingableConnection() const override; - std::pair SelectConnectionToPing( - int64_t last_ping_sent_ms) override; + PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) override; + bool GetUseCandidateAttr(const Connection* conn, NominationMode mode, IceMode remote_ice_mode) const override; diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h index 43bb88471b..ecfb0c845d 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -73,6 +73,10 @@ class IceControllerInterface { absl::optional recheck_event; }; + // A temporary typedef, so that we can migrate downstream + // to a new return value for SelectConnectionToPing. + typedef std::pair PingResult; + virtual ~IceControllerInterface() = default; // These setters are called when the state of P2PTransportChannel is mutated. @@ -90,8 +94,7 @@ class IceControllerInterface { virtual bool HasPingableConnection() const = 0; // Select a connection to Ping, or nullptr if none. - virtual std::pair SelectConnectionToPing( - int64_t last_ping_sent_ms) = 0; + virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) = 0; // Compute the "STUN_ATTR_USE_CANDIDATE" for |conn|. virtual bool GetUseCandidateAttr(const Connection* conn, diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 2a4ad59b55..fe6df2015f 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -1888,7 +1888,7 @@ void P2PTransportChannel::CheckAndPing() { UpdateConnectionStates(); auto result = ice_controller_->SelectConnectionToPing(last_ping_sent_ms_); - Connection* conn = result.first; + Connection* conn = const_cast(result.first); int delay = result.second; if (conn) {