1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2022 The WebRTC Project Authors. All rights reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef P2P_BASE_ICE_AGENT_INTERFACE_H_ 12*d9f75844SAndroid Build Coastguard Worker #define P2P_BASE_ICE_AGENT_INTERFACE_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include "api/array_view.h" 15*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/connection.h" 16*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/ice_switch_reason.h" 17*d9f75844SAndroid Build Coastguard Worker 18*d9f75844SAndroid Build Coastguard Worker namespace cricket { 19*d9f75844SAndroid Build Coastguard Worker 20*d9f75844SAndroid Build Coastguard Worker // IceAgentInterface provides methods that allow an ICE controller to manipulate 21*d9f75844SAndroid Build Coastguard Worker // the connections available to a transport, and used by the transport to 22*d9f75844SAndroid Build Coastguard Worker // transfer data. 23*d9f75844SAndroid Build Coastguard Worker class IceAgentInterface { 24*d9f75844SAndroid Build Coastguard Worker public: 25*d9f75844SAndroid Build Coastguard Worker virtual ~IceAgentInterface() = default; 26*d9f75844SAndroid Build Coastguard Worker 27*d9f75844SAndroid Build Coastguard Worker // Get the time when the last ping was sent. 28*d9f75844SAndroid Build Coastguard Worker // This is only needed in some scenarios if the agent decides to ping on its 29*d9f75844SAndroid Build Coastguard Worker // own, eg. in some switchover scenarios. Otherwise the ICE controller could 30*d9f75844SAndroid Build Coastguard Worker // keep this state on its own. 31*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/14367): route extra pings through the ICE controller. 32*d9f75844SAndroid Build Coastguard Worker virtual int64_t GetLastPingSentMs() const = 0; 33*d9f75844SAndroid Build Coastguard Worker 34*d9f75844SAndroid Build Coastguard Worker // Get the ICE role of this ICE agent. 35*d9f75844SAndroid Build Coastguard Worker virtual IceRole GetIceRole() const = 0; 36*d9f75844SAndroid Build Coastguard Worker 37*d9f75844SAndroid Build Coastguard Worker // Called when a pingable connection first becomes available. 38*d9f75844SAndroid Build Coastguard Worker virtual void OnStartedPinging() = 0; 39*d9f75844SAndroid Build Coastguard Worker 40*d9f75844SAndroid Build Coastguard Worker // Update the state of all available connections. 41*d9f75844SAndroid Build Coastguard Worker virtual void UpdateConnectionStates() = 0; 42*d9f75844SAndroid Build Coastguard Worker 43*d9f75844SAndroid Build Coastguard Worker // Update the internal state of the ICE agent. An ICE controller should call 44*d9f75844SAndroid Build Coastguard Worker // this at the end of a sequence of actions to combine several mutations into 45*d9f75844SAndroid Build Coastguard Worker // a single state refresh. 46*d9f75844SAndroid Build Coastguard Worker // TODO(bugs.webrtc.org/14431): ICE agent state updates should be internal to 47*d9f75844SAndroid Build Coastguard Worker // the agent. If batching is necessary, use a more appropriate interface. 48*d9f75844SAndroid Build Coastguard Worker virtual void UpdateState() = 0; 49*d9f75844SAndroid Build Coastguard Worker 50*d9f75844SAndroid Build Coastguard Worker // Reset the given connections to a state of newly connected connections. 51*d9f75844SAndroid Build Coastguard Worker // - STATE_WRITE_INIT 52*d9f75844SAndroid Build Coastguard Worker // - receving = false 53*d9f75844SAndroid Build Coastguard Worker // - throw away all pending request 54*d9f75844SAndroid Build Coastguard Worker // - reset RttEstimate 55*d9f75844SAndroid Build Coastguard Worker // 56*d9f75844SAndroid Build Coastguard Worker // Keep the following unchanged: 57*d9f75844SAndroid Build Coastguard Worker // - connected 58*d9f75844SAndroid Build Coastguard Worker // - remote_candidate 59*d9f75844SAndroid Build Coastguard Worker // - statistics 60*d9f75844SAndroid Build Coastguard Worker // 61*d9f75844SAndroid Build Coastguard Worker // SignalStateChange will not be triggered. 62*d9f75844SAndroid Build Coastguard Worker virtual void ForgetLearnedStateForConnections( 63*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const Connection* const> connections) = 0; 64*d9f75844SAndroid Build Coastguard Worker 65*d9f75844SAndroid Build Coastguard Worker // Send a STUN ping request for the given connection. 66*d9f75844SAndroid Build Coastguard Worker virtual void SendPingRequest(const Connection* connection) = 0; 67*d9f75844SAndroid Build Coastguard Worker 68*d9f75844SAndroid Build Coastguard Worker // Switch the transport to use the given connection. 69*d9f75844SAndroid Build Coastguard Worker virtual void SwitchSelectedConnection(const Connection* new_connection, 70*d9f75844SAndroid Build Coastguard Worker IceSwitchReason reason) = 0; 71*d9f75844SAndroid Build Coastguard Worker 72*d9f75844SAndroid Build Coastguard Worker // Prune away the given connections. Returns true if pruning is permitted and 73*d9f75844SAndroid Build Coastguard Worker // successfully performed. 74*d9f75844SAndroid Build Coastguard Worker virtual bool PruneConnections( 75*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const Connection* const> connections) = 0; 76*d9f75844SAndroid Build Coastguard Worker }; 77*d9f75844SAndroid Build Coastguard Worker 78*d9f75844SAndroid Build Coastguard Worker } // namespace cricket 79*d9f75844SAndroid Build Coastguard Worker 80*d9f75844SAndroid Build Coastguard Worker #endif // P2P_BASE_ICE_AGENT_INTERFACE_H_ 81