Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: webrtc/examples/peerconnection/server/main.cc

Issue 1789463002: Update examples GYP to avoid rtc_base_approved warning. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix usage string. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/examples/peerconnection/server/peer_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/peerconnection/server/main.cc
diff --git a/webrtc/examples/peerconnection/server/main.cc b/webrtc/examples/peerconnection/server/main.cc
index e69de9c64ac11c565fc9ed9286a578d9e59d03d4..44f42a659534f31644bd756753108bd52fa26949 100644
--- a/webrtc/examples/peerconnection/server/main.cc
+++ b/webrtc/examples/peerconnection/server/main.cc
@@ -17,10 +17,7 @@
#include "webrtc/examples/peerconnection/server/data_socket.h"
#include "webrtc/examples/peerconnection/server/peer_channel.h"
#include "webrtc/examples/peerconnection/server/utils.h"
-#include "webrtc/base/flags.h"
-
-DEFINE_bool(help, false, "Prints this message");
-DEFINE_int(port, 8888, "The port on which to listen.");
+#include "webrtc/tools/simple_command_line_parser.h"
static const size_t kMaxConnections = (FD_SETSIZE - 2);
@@ -50,16 +47,26 @@ void HandleBrowserRequest(DataSocket* ds, bool* quit) {
}
int main(int argc, char** argv) {
- rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
- if (FLAG_help) {
- rtc::FlagList::Print(NULL, false);
+ 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;
}
+ int port = strtol((parser.GetFlag("port")).c_str(), NULL, 10);
+
// Abort if the user specifies a port that is outside the allowed
// range [1, 65535].
- if ((FLAG_port < 1) || (FLAG_port > 65535)) {
- printf("Error: %i is not a valid port.\n", FLAG_port);
+ if ((port < 1) || (port > 65535)) {
+ printf("Error: %i is not a valid port.\n", port);
return -1;
}
@@ -67,12 +74,12 @@ int main(int argc, char** argv) {
if (!listener.Create()) {
printf("Failed to create server socket\n");
return -1;
- } else if (!listener.Listen(FLAG_port)) {
+ } else if (!listener.Listen(port)) {
printf("Failed to listen on server socket\n");
return -1;
}
- printf("Server listening on port %i\n", FLAG_port);
+ printf("Server listening on port %i\n", port);
PeerChannel clients;
typedef std::vector<DataSocket*> SocketArray;
« no previous file with comments | « no previous file | webrtc/examples/peerconnection/server/peer_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698