123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #ifndef P2P_BASE_ICE_CONTROLLER_INTERFACE_H_
- #define P2P_BASE_ICE_CONTROLLER_INTERFACE_H_
- #include <string>
- #include <utility>
- #include <vector>
- #include "p2p/base/connection.h"
- #include "p2p/base/ice_transport_internal.h"
- namespace cricket {
- struct IceFieldTrials;
- struct IceControllerEvent {
- enum Type {
- 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,
-
-
-
- ICE_CONTROLLER_RECHECK,
- };
- IceControllerEvent(const Type& _type)
- : type(_type) {}
- std::string ToString() const;
- Type type;
- int recheck_delay_ms = 0;
- };
- class IceControllerInterface {
- public:
-
- struct SwitchResult {
-
- absl::optional<const Connection*> connection;
-
- absl::optional<IceControllerEvent> recheck_event;
-
- std::vector<const Connection*> connections_to_forget_state_on;
- };
-
- struct PingResult {
- PingResult(const Connection* conn, int _recheck_delay_ms)
- : connection(conn), recheck_delay_ms(_recheck_delay_ms) {}
-
- const absl::optional<const Connection*> connection;
-
-
-
-
-
-
-
- const int recheck_delay_ms = 0;
- };
- virtual ~IceControllerInterface() = default;
-
- virtual void SetIceConfig(const IceConfig& config) = 0;
- virtual void SetSelectedConnection(const Connection* selected_connection) = 0;
- virtual void AddConnection(const Connection* connection) = 0;
- virtual void OnConnectionDestroyed(const Connection* connection) = 0;
-
- virtual rtc::ArrayView<const Connection*> connections() const = 0;
-
-
-
- virtual bool HasPingableConnection() const = 0;
-
- virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) = 0;
-
- virtual bool GetUseCandidateAttr(const Connection* conn,
- NominationMode mode,
- IceMode remote_ice_mode) const = 0;
-
-
- virtual const Connection* FindNextPingableConnection() = 0;
- virtual void MarkConnectionPinged(const Connection* con) = 0;
-
-
-
- virtual SwitchResult ShouldSwitchConnection(IceControllerEvent reason,
- const Connection* connection) = 0;
-
- virtual SwitchResult SortAndSwitchConnection(IceControllerEvent reason) = 0;
-
- virtual std::vector<const Connection*> PruneConnections() = 0;
- };
- }
- #endif
|