mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Add AbslParse functions for TimeMode enum. (This allows creation of TimeMode ABSL_FLAGs.)
Bug: webrtc:14145 Change-Id: Id79c4411ba4443a3ee8a0da3990c36955cc9aa35 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264821 Commit-Queue: Björn Terelius <terelius@webrtc.org> Auto-Submit: Björn Terelius <terelius@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37090}
This commit is contained in:
parent
25361a89dd
commit
b22cabcf76
3 changed files with 39 additions and 1 deletions
|
@ -693,6 +693,7 @@ rtc_source_set("network_emulation_manager_api") {
|
|||
":time_controller",
|
||||
"../call:simulated_network",
|
||||
"../rtc_base",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:network_constants",
|
||||
"../rtc_base:threading",
|
||||
"test/network_emulation",
|
||||
|
|
|
@ -7,13 +7,40 @@
|
|||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "api/test/network_emulation_manager.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "api/test/network_emulation_manager.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
bool AbslParseFlag(absl::string_view text, TimeMode* mode, std::string* error) {
|
||||
if (text == "realtime") {
|
||||
*mode = TimeMode::kRealTime;
|
||||
return true;
|
||||
}
|
||||
if (text == "simulated") {
|
||||
*mode = TimeMode::kSimulated;
|
||||
return true;
|
||||
}
|
||||
*error =
|
||||
"Unknown value for TimeMode enum. Options are 'realtime' or 'simulated'";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string AbslUnparseFlag(TimeMode mode) {
|
||||
switch (mode) {
|
||||
case TimeMode::kRealTime:
|
||||
return "realtime";
|
||||
case TimeMode::kSimulated:
|
||||
return "simulated";
|
||||
}
|
||||
RTC_CHECK_NOTREACHED();
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
NetworkEmulationManager::SimulatedNetworkNode::Builder&
|
||||
NetworkEmulationManager::SimulatedNetworkNode::Builder::config(
|
||||
BuiltInNetworkBehaviorConfig config) {
|
||||
|
|
|
@ -148,6 +148,16 @@ class EmulatedNetworkManagerInterface {
|
|||
|
||||
enum class TimeMode { kRealTime, kSimulated };
|
||||
|
||||
// Called implicitly when parsing an ABSL_FLAG of type TimeMode.
|
||||
// from the command line flag value `text`.
|
||||
// Returns `true` and sets `*mode` on success;
|
||||
// returns `false` and sets `*error` on failure.
|
||||
bool AbslParseFlag(absl::string_view text, TimeMode* mode, std::string* error);
|
||||
|
||||
// AbslUnparseFlag returns a textual flag value corresponding to the TimeMode
|
||||
// `mode`.
|
||||
std::string AbslUnparseFlag(TimeMode mode);
|
||||
|
||||
// Provides an API for creating and configuring emulated network layer.
|
||||
// All objects returned by this API are owned by NetworkEmulationManager itself
|
||||
// and will be deleted when manager will be deleted.
|
||||
|
|
Loading…
Reference in a new issue