blob: e54838ee64ca5ff3b1b02ffe2cdc1f24eb346bb0 [file] [log] [blame]
Sameer Vijaykar094ee302022-09-12 14:37:541/*
2 * Copyright 2022 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef P2P_BASE_ACTIVE_ICE_CONTROLLER_INTERFACE_H_
12#define P2P_BASE_ACTIVE_ICE_CONTROLLER_INTERFACE_H_
13
14#include "absl/types/optional.h"
15#include "api/array_view.h"
16#include "p2p/base/connection.h"
17#include "p2p/base/ice_switch_reason.h"
18#include "p2p/base/ice_transport_internal.h"
19#include "p2p/base/transport_description.h"
20
21namespace cricket {
22
23// ActiveIceControllerInterface defines the methods for a module that actively
24// manages the connection used by an ICE transport.
25//
26// An active ICE controller receives updates from the ICE transport when
27// - the connections state is mutated
28// - a new connection should be selected as a result of an external event (eg.
29// a different connection nominated by the remote peer)
30//
31// The active ICE controller takes the appropriate decisions and requests the
32// ICE agent to perform the necessary actions through the IceAgentInterface.
33class ActiveIceControllerInterface {
34 public:
35 virtual ~ActiveIceControllerInterface() = default;
36
37 // Sets the current ICE configuration.
38 virtual void SetIceConfig(const IceConfig& config) = 0;
39
40 // Called when a new connection is added to the ICE transport.
41 virtual void OnConnectionAdded(const Connection* connection) = 0;
42
43 // Called when the transport switches that connection in active use.
44 virtual void OnConnectionSwitched(const Connection* connection) = 0;
45
46 // Called when a connection is destroyed.
47 virtual void OnConnectionDestroyed(const Connection* connection) = 0;
48
49 // Called when a STUN ping has been sent on a connection. This does not
50 // indicate that a STUN response has been received.
51 virtual void OnConnectionPinged(const Connection* connection) = 0;
52
53 // Called when one of the following changes for a connection.
54 // - rtt estimate
55 // - write state
56 // - receiving
57 // - connected
58 // - nominated
59 virtual void OnConnectionUpdated(const Connection* connection) = 0;
60
61 // Compute "STUN_ATTR_USE_CANDIDATE" for a STUN ping on the given connection.
62 virtual bool GetUseCandidateAttribute(const Connection* connection,
63 NominationMode mode,
64 IceMode remote_ice_mode) const = 0;
65
66 // Called to enque a request to pick and switch to the best available
67 // connection.
68 virtual void OnSortAndSwitchRequest(IceSwitchReason reason) = 0;
69
70 // Called to pick and switch to the best available connection immediately.
71 virtual void OnImmediateSortAndSwitchRequest(IceSwitchReason reason) = 0;
72
73 // Called to switch to the given connection immediately without checking for
74 // the best available connection.
75 virtual bool OnImmediateSwitchRequest(IceSwitchReason reason,
76 const Connection* selected) = 0;
77
78 // Only for unit tests
79 virtual const Connection* FindNextPingableConnection() = 0;
80};
81
82} // namespace cricket
83
84#endif // P2P_BASE_ACTIVE_ICE_CONTROLLER_INTERFACE_H_