Refactor IceControllerEvent
This change is the first step in decoupling IceControllerEvent from the ICE switch reason. Further cleanup is earmarked, and will be landed after some internal cleanup. This change - adds a new enum - IceSwitchReason - adds a member for the new enum in IceControllerEvent - uses the new enum within P2PTransportChannel - adds methods to IceControllerInterface accepting the new enum - deprecates usages of the old enum in IceControllerInterface - adds conversion between the old and new enums for compatibility Bug: webrtc:14125, webrtc:14131 Change-Id: I5b7201c3f631eb40db334dfeec842841a7e58174 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264140 Reviewed-by: Jonas Oreland <jonaso@webrtc.org> Commit-Queue: Sameer Vijaykar <samvi@google.com> Cr-Commit-Position: refs/heads/main@{#37051}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
9406c22769
commit
794e68cf3d
@ -15,7 +15,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#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 {
|
||||
@ -23,6 +25,7 @@ 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,
|
||||
@ -39,10 +42,22 @@ struct IceControllerEvent {
|
||||
ICE_CONTROLLER_RECHECK,
|
||||
};
|
||||
|
||||
IceControllerEvent(const Type& _type) // NOLINT: runtime/explicit
|
||||
: type(_type) {}
|
||||
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);
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
IceSwitchReason reason;
|
||||
// TODO(bugs.webrtc.org/14125) replace usage with IceSwitchReason.
|
||||
Type type;
|
||||
int recheck_delay_ms = 0;
|
||||
};
|
||||
@ -134,13 +149,29 @@ class IceControllerInterface {
|
||||
virtual void MarkConnectionPinged(const Connection* con) = 0;
|
||||
|
||||
// Check if we should switch to `connection`.
|
||||
// This method is called for IceControllerEvent's that can switch directly
|
||||
// This method is called for IceSwitchReasons that can switch directly
|
||||
// i.e without resorting.
|
||||
virtual SwitchResult ShouldSwitchConnection(IceControllerEvent reason,
|
||||
const Connection* connection) = 0;
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Sort connections and check if we should switch.
|
||||
virtual SwitchResult SortAndSwitchConnection(IceControllerEvent reason) = 0;
|
||||
// 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));
|
||||
}
|
||||
|
||||
// Prune connections.
|
||||
virtual std::vector<const Connection*> PruneConnections() = 0;
|
||||
|
||||
Reference in New Issue
Block a user