Move NetworkSlice enum to network_constants. Alongside AdapterType, this allows referencing NetworkSlice from api/ and elsewhere via a smaller, cleaner library. Bug: webrtc:494142581 Change-Id: I5dffd985eda37b582de942deb74aa879989ef312 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/461560 Reviewed-by: Jonas Oreland <jonaso@webrtc.org> Commit-Queue: Sameer Vijaykar <samvi@google.com> Cr-Commit-Position: refs/heads/main@{#47330}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 380090a..f895f0b 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn
@@ -1141,7 +1141,10 @@ "network_constants.cc", "network_constants.h", ] - deps = [ ":checks" ] + deps = [ + ":checks", + "//third_party/abseil-cpp/absl/strings:string_view", + ] } if (is_android) {
diff --git a/rtc_base/network_constants.cc b/rtc_base/network_constants.cc index 9c56660..3192636 100644 --- a/rtc_base/network_constants.cc +++ b/rtc_base/network_constants.cc
@@ -12,6 +12,7 @@ #include <string> +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -46,4 +47,13 @@ } } +absl::string_view NetworkSliceToString(NetworkSlice network_slice) { + switch (network_slice) { + case NetworkSlice::NO_SLICE: + return "NO_SLICE"; + case NetworkSlice::UNIFIED_COMMUNICATIONS: + return "UNIFIED_COMMUNICATIONS"; + } +} + } // namespace webrtc
diff --git a/rtc_base/network_constants.h b/rtc_base/network_constants.h index 8c43576..8511405 100644 --- a/rtc_base/network_constants.h +++ b/rtc_base/network_constants.h
@@ -15,6 +15,8 @@ #include <string> +#include "absl/strings/string_view.h" + namespace webrtc { constexpr uint16_t kNetworkCostMax = 999; @@ -85,6 +87,18 @@ ADAPTER_TYPE_CELLULAR_5G, }; +// Network slice is a property of a network, primarily used in 5G and beyond. +// It allows for the creation of multiple logical networks on a shared physical +// infrastructure, each optimized for specific use cases. This is not about +// whether the network is 3G/4G/5G/6G, but rather a feature available within +// some of those network generations (e.g., 5G). +enum class NetworkSlice { + NO_SLICE = 0, + UNIFIED_COMMUNICATIONS = 1, +}; + +absl::string_view NetworkSliceToString(NetworkSlice network_slice); + } // namespace webrtc
diff --git a/rtc_base/network_monitor.cc b/rtc_base/network_monitor.cc index 2595b68..bf44635 100644 --- a/rtc_base/network_monitor.cc +++ b/rtc_base/network_monitor.cc
@@ -23,15 +23,6 @@ } } -absl::string_view NetworkSliceToString(NetworkSlice network_slice) { - switch (network_slice) { - case NetworkSlice::NO_SLICE: - return "NO_SLICE"; - case NetworkSlice::UNIFIED_COMMUNICATIONS: - return "UNIFIED_COMMUNICATIONS"; - } -} - NetworkMonitorInterface::NetworkMonitorInterface() {} NetworkMonitorInterface::~NetworkMonitorInterface() {}
diff --git a/rtc_base/network_monitor.h b/rtc_base/network_monitor.h index 10889af..8489f7a 100644 --- a/rtc_base/network_monitor.h +++ b/rtc_base/network_monitor.h
@@ -36,18 +36,7 @@ NOT_PREFERRED = -1, }; -// Network slice is a property of a network, primarily used in 5G and beyond. -// It allows for the creation of multiple logical networks on a shared physical -// infrastructure, each optimized for specific use cases. This is not about -// whether the network is 3G/4G/5G/6G, but rather a feature available within -// some of those network generations (e.g., 5G). -enum class NetworkSlice { - NO_SLICE = 0, - UNIFIED_COMMUNICATIONS = 1, -}; - absl::string_view NetworkPreferenceToString(NetworkPreference preference); -absl::string_view NetworkSliceToString(NetworkSlice network_slice); // This interface is set onto a socket server, // where only the ip address is known at the time of binding.