aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMirko Bonadei <mbonadei@webrtc.org>2019-06-25 15:43:23 +0200
committerCommit Bot <commit-bot@chromium.org>2019-06-25 14:57:36 +0000
commit04cffe3289f74271cd0ad6b3cbf0e49453a9ff91 (patch)
tree554a49dc26845c02984dbbbe2994cb7e55bb451a /examples
parentf03b36587556934fb2b7f8125654b18e20df191d (diff)
downloadwebrtc-04cffe3289f74271cd0ad6b3cbf0e49453a9ff91.tar.gz
Switch example peerconnection server to ABSL_FLAG.
TBR=kwiberg@webrtc.org Bug: webrtc:10616 Change-Id: I611f6f67c5473b7f7ef623fa788e5403e7a8001a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143790 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28373}
Diffstat (limited to 'examples')
-rw-r--r--examples/BUILD.gn2
-rw-r--r--examples/DEPS3
-rw-r--r--examples/peerconnection/server/main.cc30
3 files changed, 17 insertions, 18 deletions
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index eed92229cc..fdff31a5c9 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -727,6 +727,8 @@ if (is_linux || is_win) {
"../rtc_tools:command_line_parser",
"../system_wrappers:field_trial",
"../test:field_trial",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
]
}
rtc_executable("relayserver") {
diff --git a/examples/DEPS b/examples/DEPS
index 114cda384b..1604a6a513 100644
--- a/examples/DEPS
+++ b/examples/DEPS
@@ -10,4 +10,7 @@ include_rules = [
"+sdk/objc",
"+system_wrappers/include",
"+third_party/libyuv",
+
+ # Abseil flags are allowed in tests and tools.
+ "+absl/flags",
]
diff --git a/examples/peerconnection/server/main.cc b/examples/peerconnection/server/main.cc
index 79b2c2ce3b..9be7685660 100644
--- a/examples/peerconnection/server/main.cc
+++ b/examples/peerconnection/server/main.cc
@@ -19,14 +19,15 @@
#include <string>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "examples/peerconnection/server/data_socket.h"
#include "examples/peerconnection/server/peer_channel.h"
-#include "rtc_base/flags.h"
-#include "rtc_tools/simple_command_line_parser.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
-WEBRTC_DEFINE_string(
+ABSL_FLAG(
+ std::string,
force_fieldtrials,
"",
"Field trials control experimental features. This flag specifies the field "
@@ -34,6 +35,7 @@ WEBRTC_DEFINE_string(
"--force_fieldtrials=WebRTC-FooFeature/Enabled/ "
"will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
"trials are separated by \"/\"");
+ABSL_FLAG(int, port, 8888, "default: 8888");
static const size_t kMaxConnections = (FD_SETSIZE - 2);
@@ -63,25 +65,17 @@ void HandleBrowserRequest(DataSocket* ds, bool* quit) {
}
int main(int argc, char* argv[]) {
- std::string program_name = argv[0];
- std::string usage = "Example usage: " + program_name + " --port=8888";
- webrtc::test::CommandLineParser parser;
- parser.Init(argc, argv);
- parser.SetUsageMessage(usage);
- parser.SetFlag("port", "8888");
- parser.SetFlag("help", "false");
- parser.ProcessFlags();
-
- if (parser.GetFlag("help") == "true") {
- parser.PrintUsageMessage();
- return 0;
- }
+ absl::ParseCommandLine(argc, argv);
+ // TODO(bugs.webrtc.org/10616): Add program usage message when Abseil
+ // flags supports it.
+ // std::string usage = "Example usage: " + program_name + " --port=8888";
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
- webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(
+ absl::GetFlag(FLAGS_force_fieldtrials).c_str());
- int port = strtol((parser.GetFlag("port")).c_str(), NULL, 10);
+ int port = absl::GetFlag(FLAGS_port);
// Abort if the user specifies a port that is outside the allowed
// range [1, 65535].