Switch pc client and stunprober to ABSL_FLAG.
Bug: webrtc:10616 Change-Id: I74e65a527da88a7f723c5000e5097dc1766826dd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144624 Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28588}
This commit is contained in:

committed by
Commit Bot

parent
f43cc6905f
commit
0be40bf53f
@ -707,6 +707,8 @@ if (is_linux || is_win) {
|
|||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
"../rtc_base:rtc_json",
|
"../rtc_base:rtc_json",
|
||||||
"../test:video_test_common",
|
"../test:video_test_common",
|
||||||
|
"//third_party/abseil-cpp/absl/flags:flag",
|
||||||
|
"//third_party/abseil-cpp/absl/flags:parse",
|
||||||
"//third_party/libyuv",
|
"//third_party/libyuv",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -870,6 +872,8 @@ if (!build_with_chromium) {
|
|||||||
"../rtc_base",
|
"../rtc_base",
|
||||||
"../rtc_base:checks",
|
"../rtc_base:checks",
|
||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
|
"//third_party/abseil-cpp/absl/flags:flag",
|
||||||
|
"//third_party/abseil-cpp/absl/flags:parse",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
#ifndef EXAMPLES_PEERCONNECTION_CLIENT_FLAG_DEFS_H_
|
#ifndef EXAMPLES_PEERCONNECTION_CLIENT_FLAG_DEFS_H_
|
||||||
#define EXAMPLES_PEERCONNECTION_CLIENT_FLAG_DEFS_H_
|
#define EXAMPLES_PEERCONNECTION_CLIENT_FLAG_DEFS_H_
|
||||||
|
|
||||||
#include "rtc_base/flags.h"
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/flags/flag.h"
|
||||||
|
|
||||||
extern const uint16_t kDefaultServerPort; // From defaults.[h|cc]
|
extern const uint16_t kDefaultServerPort; // From defaults.[h|cc]
|
||||||
|
|
||||||
@ -19,23 +21,26 @@ extern const uint16_t kDefaultServerPort; // From defaults.[h|cc]
|
|||||||
// header file so that they can be shared across the different main.cc's
|
// header file so that they can be shared across the different main.cc's
|
||||||
// for each platform.
|
// for each platform.
|
||||||
|
|
||||||
WEBRTC_DEFINE_bool(help, false, "Prints this message");
|
ABSL_FLAG(bool,
|
||||||
WEBRTC_DEFINE_bool(autoconnect,
|
autoconnect,
|
||||||
false,
|
false,
|
||||||
"Connect to the server without user "
|
"Connect to the server without user "
|
||||||
"intervention.");
|
"intervention.");
|
||||||
WEBRTC_DEFINE_string(server, "localhost", "The server to connect to.");
|
ABSL_FLAG(std::string, server, "localhost", "The server to connect to.");
|
||||||
WEBRTC_DEFINE_int(port,
|
ABSL_FLAG(int,
|
||||||
kDefaultServerPort,
|
port,
|
||||||
"The port on which the server is listening.");
|
kDefaultServerPort,
|
||||||
WEBRTC_DEFINE_bool(
|
"The port on which the server is listening.");
|
||||||
|
ABSL_FLAG(
|
||||||
|
bool,
|
||||||
autocall,
|
autocall,
|
||||||
false,
|
false,
|
||||||
"Call the first available other client on "
|
"Call the first available other client on "
|
||||||
"the server without user intervention. Note: this flag should only be set "
|
"the server without user intervention. Note: this flag should only be set "
|
||||||
"to true on one of the two clients.");
|
"to true on one of the two clients.");
|
||||||
|
|
||||||
WEBRTC_DEFINE_string(
|
ABSL_FLAG(
|
||||||
|
std::string,
|
||||||
force_fieldtrials,
|
force_fieldtrials,
|
||||||
"",
|
"",
|
||||||
"Field trials control experimental features. This flag specifies the field "
|
"Field trials control experimental features. This flag specifies the field "
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "absl/flags/parse.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "examples/peerconnection/client/conductor.h"
|
#include "examples/peerconnection/client/conductor.h"
|
||||||
#include "examples/peerconnection/client/flag_defs.h"
|
#include "examples/peerconnection/client/flag_defs.h"
|
||||||
#include "examples/peerconnection/client/linux/main_wnd.h"
|
#include "examples/peerconnection/client/linux/main_wnd.h"
|
||||||
#include "examples/peerconnection/client/peer_connection_client.h"
|
#include "examples/peerconnection/client/peer_connection_client.h"
|
||||||
#include "rtc_base/flags.h"
|
|
||||||
#include "rtc_base/message_queue.h"
|
#include "rtc_base/message_queue.h"
|
||||||
#include "rtc_base/physical_socket_server.h"
|
#include "rtc_base/physical_socket_server.h"
|
||||||
#include "rtc_base/ref_counted_object.h"
|
#include "rtc_base/ref_counted_object.h"
|
||||||
@ -77,24 +77,25 @@ int main(int argc, char* argv[]) {
|
|||||||
g_thread_init(NULL);
|
g_thread_init(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
|
absl::ParseCommandLine(argc, argv);
|
||||||
if (FLAG_help) {
|
|
||||||
rtc::FlagList::Print(NULL, false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
||||||
// the application.
|
// the application.
|
||||||
webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
|
const std::string forced_field_trials =
|
||||||
|
absl::GetFlag(FLAGS_force_fieldtrials);
|
||||||
|
webrtc::field_trial::InitFieldTrialsFromString(forced_field_trials.c_str());
|
||||||
|
|
||||||
// Abort if the user specifies a port that is outside the allowed
|
// Abort if the user specifies a port that is outside the allowed
|
||||||
// range [1, 65535].
|
// range [1, 65535].
|
||||||
if ((FLAG_port < 1) || (FLAG_port > 65535)) {
|
if ((absl::GetFlag(FLAGS_port) < 1) || (absl::GetFlag(FLAGS_port) > 65535)) {
|
||||||
printf("Error: %i is not a valid port.\n", FLAG_port);
|
printf("Error: %i is not a valid port.\n", absl::GetFlag(FLAGS_port));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkMainWnd wnd(FLAG_server, FLAG_port, FLAG_autoconnect, FLAG_autocall);
|
const std::string server = absl::GetFlag(FLAGS_server);
|
||||||
|
GtkMainWnd wnd(server.c_str(), absl::GetFlag(FLAGS_port),
|
||||||
|
absl::GetFlag(FLAGS_autoconnect),
|
||||||
|
absl::GetFlag(FLAGS_autocall));
|
||||||
wnd.Create();
|
wnd.Create();
|
||||||
|
|
||||||
CustomSocketServer socket_server(&wnd);
|
CustomSocketServer socket_server(&wnd);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/flags/parse.h"
|
||||||
#include "examples/peerconnection/client/conductor.h"
|
#include "examples/peerconnection/client/conductor.h"
|
||||||
#include "examples/peerconnection/client/flag_defs.h"
|
#include "examples/peerconnection/client/flag_defs.h"
|
||||||
#include "examples/peerconnection/client/main_wnd.h"
|
#include "examples/peerconnection/client/main_wnd.h"
|
||||||
@ -41,13 +42,13 @@ class WindowsCommandLineArguments {
|
|||||||
WindowsCommandLineArguments();
|
WindowsCommandLineArguments();
|
||||||
|
|
||||||
int argc() { return argv_.size(); }
|
int argc() { return argv_.size(); }
|
||||||
const char** argv() { return argv_.data(); }
|
char** argv() { return argv_.data(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Owned argument strings.
|
// Owned argument strings.
|
||||||
std::vector<std::string> args_;
|
std::vector<std::string> args_;
|
||||||
// Pointers, to get layout compatible with char** argv.
|
// Pointers, to get layout compatible with char** argv.
|
||||||
std::vector<const char*> argv_;
|
std::vector<char*> argv_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(WindowsCommandLineArguments);
|
RTC_DISALLOW_COPY_AND_ASSIGN(WindowsCommandLineArguments);
|
||||||
@ -64,7 +65,7 @@ WindowsCommandLineArguments::WindowsCommandLineArguments() {
|
|||||||
for (int i = 0; i < argc; ++i) {
|
for (int i = 0; i < argc; ++i) {
|
||||||
args_.push_back(rtc::ToUtf8(wide_argv[i], wcslen(wide_argv[i])));
|
args_.push_back(rtc::ToUtf8(wide_argv[i], wcslen(wide_argv[i])));
|
||||||
// make sure the argv array points to the string data.
|
// make sure the argv array points to the string data.
|
||||||
argv_.push_back(args_.back().c_str());
|
argv_.push_back(const_cast<char*>(args_.back().c_str()));
|
||||||
}
|
}
|
||||||
LocalFree(wide_argv);
|
LocalFree(wide_argv);
|
||||||
}
|
}
|
||||||
@ -81,26 +82,26 @@ int PASCAL wWinMain(HINSTANCE instance,
|
|||||||
|
|
||||||
WindowsCommandLineArguments win_args;
|
WindowsCommandLineArguments win_args;
|
||||||
int argc = win_args.argc();
|
int argc = win_args.argc();
|
||||||
const char** argv = win_args.argv();
|
char** argv = win_args.argv();
|
||||||
|
|
||||||
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
|
absl::ParseCommandLine(argc, argv);
|
||||||
if (FLAG_help) {
|
|
||||||
rtc::FlagList::Print(NULL, false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
||||||
// the application.
|
// the application.
|
||||||
webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
|
const std::string forced_field_trials =
|
||||||
|
absl::GetFlag(FLAGS_force_fieldtrials);
|
||||||
|
webrtc::field_trial::InitFieldTrialsFromString(forced_field_trials.c_str());
|
||||||
|
|
||||||
// Abort if the user specifies a port that is outside the allowed
|
// Abort if the user specifies a port that is outside the allowed
|
||||||
// range [1, 65535].
|
// range [1, 65535].
|
||||||
if ((FLAG_port < 1) || (FLAG_port > 65535)) {
|
if ((absl::GetFlag(FLAGS_port) < 1) || (absl::GetFlag(FLAGS_port) > 65535)) {
|
||||||
printf("Error: %i is not a valid port.\n", FLAG_port);
|
printf("Error: %i is not a valid port.\n", absl::GetFlag(FLAGS_port));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWnd wnd(FLAG_server, FLAG_port, FLAG_autoconnect, FLAG_autocall);
|
const std::string server = absl::GetFlag(FLAGS_server);
|
||||||
|
MainWnd wnd(server.c_str(), absl::GetFlag(FLAGS_port),
|
||||||
|
absl::GetFlag(FLAGS_autoconnect), absl::GetFlag(FLAGS_autocall));
|
||||||
if (!wnd.Create()) {
|
if (!wnd.Create()) {
|
||||||
RTC_NOTREACHED();
|
RTC_NOTREACHED();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -72,8 +72,8 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
||||||
// the application.
|
// the application.
|
||||||
webrtc::field_trial::InitFieldTrialsFromString(
|
const std::string force_field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
|
||||||
absl::GetFlag(FLAGS_force_fieldtrials).c_str());
|
webrtc::field_trial::InitFieldTrialsFromString(force_field_trials.c_str());
|
||||||
|
|
||||||
int port = absl::GetFlag(FLAGS_port);
|
int port = absl::GetFlag(FLAGS_port);
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/flags/flag.h"
|
||||||
|
#include "absl/flags/parse.h"
|
||||||
#include "p2p/base/basic_packet_socket_factory.h"
|
#include "p2p/base/basic_packet_socket_factory.h"
|
||||||
#include "p2p/stunprober/stun_prober.h"
|
#include "p2p/stunprober/stun_prober.h"
|
||||||
#include "rtc_base/flags.h"
|
|
||||||
#include "rtc_base/helpers.h"
|
#include "rtc_base/helpers.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/network.h"
|
#include "rtc_base/network.h"
|
||||||
@ -28,21 +29,24 @@
|
|||||||
using stunprober::AsyncCallback;
|
using stunprober::AsyncCallback;
|
||||||
using stunprober::StunProber;
|
using stunprober::StunProber;
|
||||||
|
|
||||||
WEBRTC_DEFINE_bool(help, false, "Prints this message");
|
ABSL_FLAG(int,
|
||||||
WEBRTC_DEFINE_int(interval,
|
interval,
|
||||||
10,
|
10,
|
||||||
"Interval of consecutive stun pings in milliseconds");
|
"Interval of consecutive stun pings in milliseconds");
|
||||||
WEBRTC_DEFINE_bool(shared_socket,
|
ABSL_FLAG(bool,
|
||||||
false,
|
shared_socket,
|
||||||
"Share socket mode for different remote IPs");
|
false,
|
||||||
WEBRTC_DEFINE_int(pings_per_ip,
|
"Share socket mode for different remote IPs");
|
||||||
10,
|
ABSL_FLAG(int,
|
||||||
"Number of consecutive stun pings to send for each IP");
|
pings_per_ip,
|
||||||
WEBRTC_DEFINE_int(
|
10,
|
||||||
timeout,
|
"Number of consecutive stun pings to send for each IP");
|
||||||
1000,
|
ABSL_FLAG(int,
|
||||||
"Milliseconds of wait after the last ping sent before exiting");
|
timeout,
|
||||||
WEBRTC_DEFINE_string(
|
1000,
|
||||||
|
"Milliseconds of wait after the last ping sent before exiting");
|
||||||
|
ABSL_FLAG(
|
||||||
|
std::string,
|
||||||
servers,
|
servers,
|
||||||
"stun.l.google.com:19302,stun1.l.google.com:19302,stun2.l.google.com:19302",
|
"stun.l.google.com:19302,stun1.l.google.com:19302,stun2.l.google.com:19302",
|
||||||
"Comma separated STUN server addresses with ports");
|
"Comma separated STUN server addresses with ports");
|
||||||
@ -102,14 +106,10 @@ void StopTrial(rtc::Thread* thread, StunProber* prober, int result) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
|
absl::ParseCommandLine(argc, argv);
|
||||||
if (FLAG_help) {
|
|
||||||
rtc::FlagList::Print(nullptr, false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<rtc::SocketAddress> server_addresses;
|
std::vector<rtc::SocketAddress> server_addresses;
|
||||||
std::istringstream servers(FLAG_servers);
|
std::istringstream servers(absl::GetFlag(FLAGS_servers));
|
||||||
std::string server;
|
std::string server;
|
||||||
while (getline(servers, server, ',')) {
|
while (getline(servers, server, ',')) {
|
||||||
rtc::SocketAddress addr;
|
rtc::SocketAddress addr;
|
||||||
@ -134,8 +134,9 @@ int main(int argc, char* argv[]) {
|
|||||||
auto finish_callback = [thread](StunProber* prober, int result) {
|
auto finish_callback = [thread](StunProber* prober, int result) {
|
||||||
StopTrial(thread, prober, result);
|
StopTrial(thread, prober, result);
|
||||||
};
|
};
|
||||||
prober->Start(server_addresses, FLAG_shared_socket, FLAG_interval,
|
prober->Start(server_addresses, absl::GetFlag(FLAGS_shared_socket),
|
||||||
FLAG_pings_per_ip, FLAG_timeout,
|
absl::GetFlag(FLAGS_interval),
|
||||||
|
absl::GetFlag(FLAGS_pings_per_ip), absl::GetFlag(FLAGS_timeout),
|
||||||
AsyncCallback(finish_callback));
|
AsyncCallback(finish_callback));
|
||||||
thread->Run();
|
thread->Run();
|
||||||
delete prober;
|
delete prober;
|
||||||
|
Reference in New Issue
Block a user