From 3e67676fa64c58b08ac436aa8d3dcfa632589bf6 Mon Sep 17 00:00:00 2001 From: Bjorn Terelius Date: Mon, 29 Oct 2018 15:26:27 +0100 Subject: [PATCH] Add support for field trials in peerconnection_client|server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9935 Change-Id: Icb96123c5feb9dee309734d2a8ba88e23a467bef Reviewed-on: https://webrtc-review.googlesource.com/c/108301 Commit-Queue: Björn Terelius Reviewed-by: Niels Moller Reviewed-by: Magnus Jedvert Cr-Commit-Position: refs/heads/master@{#25431} --- examples/BUILD.gn | 4 ++++ examples/DEPS | 1 + examples/peerconnection/client/flagdefs.h | 9 +++++++++ examples/peerconnection/client/linux/main.cc | 7 +++++++ examples/peerconnection/client/main.cc | 7 +++++++ examples/peerconnection/server/main.cc | 17 +++++++++++++++++ 6 files changed, 45 insertions(+) diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 51920412b8..cd931b4beb 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -683,6 +683,8 @@ if (is_linux || is_win) { "../rtc_base:checks", "../rtc_base:stringutils", "../rtc_base/third_party/sigslot", + "../system_wrappers:field_trial", + "../test:field_trial", ] if (is_win) { sources += [ @@ -745,6 +747,8 @@ if (is_linux || is_win) { "../rtc_base:rtc_base_approved", "../rtc_base:stringutils", "../rtc_tools:command_line_parser", + "../system_wrappers:field_trial", + "../test:field_trial", ] if (!build_with_chromium && is_clang) { # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). diff --git a/examples/DEPS b/examples/DEPS index 6a9a9f09cf..5b37845590 100644 --- a/examples/DEPS +++ b/examples/DEPS @@ -8,5 +8,6 @@ include_rules = [ "+p2p", "+pc", "+sdk/objc", + "+system_wrappers/include", "+third_party/libyuv", ] diff --git a/examples/peerconnection/client/flagdefs.h b/examples/peerconnection/client/flagdefs.h index 7bbc3839e4..51f9c9a425 100644 --- a/examples/peerconnection/client/flagdefs.h +++ b/examples/peerconnection/client/flagdefs.h @@ -35,4 +35,13 @@ WEBRTC_DEFINE_bool( "the server without user intervention. Note: this flag should only be set " "to true on one of the two clients."); +WEBRTC_DEFINE_string( + force_fieldtrials, + "", + "Field trials control experimental features. This flag specifies the field " + "trials in effect. E.g. running with " + "--force_fieldtrials=WebRTC-FooFeature/Enabled/ " + "will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " + "trials are separated by \"/\""); + #endif // EXAMPLES_PEERCONNECTION_CLIENT_FLAGDEFS_H_ diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc index 50179c4ba5..6c34683d2e 100644 --- a/examples/peerconnection/client/linux/main.cc +++ b/examples/peerconnection/client/linux/main.cc @@ -17,6 +17,8 @@ #include "rtc_base/ssladapter.h" #include "rtc_base/thread.h" +#include "system_wrappers/include/field_trial.h" +#include "test/field_trial.h" class CustomSocketServer : public rtc::PhysicalSocketServer { public: @@ -75,6 +77,11 @@ int main(int argc, char* argv[]) { return 0; } + webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); + // InitFieldTrialsFromString stores the char*, so the char array must outlive + // the application. + webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); + // Abort if the user specifies a port that is outside the allowed // range [1, 65535]. if ((FLAG_port < 1) || (FLAG_port > 65535)) { diff --git a/examples/peerconnection/client/main.cc b/examples/peerconnection/client/main.cc index 25dde1ef65..f92e606c33 100644 --- a/examples/peerconnection/client/main.cc +++ b/examples/peerconnection/client/main.cc @@ -16,6 +16,8 @@ #include "rtc_base/ssladapter.h" #include "rtc_base/win32socketinit.h" #include "rtc_base/win32socketserver.h" +#include "system_wrappers/include/field_trial.h" +#include "test/field_trial.h" int PASCAL wWinMain(HINSTANCE instance, HINSTANCE prev_instance, @@ -36,6 +38,11 @@ int PASCAL wWinMain(HINSTANCE instance, return 0; } + webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); + // InitFieldTrialsFromString stores the char*, so the char array must outlive + // the application. + webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); + // Abort if the user specifies a port that is outside the allowed // range [1, 65535]. if ((FLAG_port < 1) || (FLAG_port > 65535)) { diff --git a/examples/peerconnection/server/main.cc b/examples/peerconnection/server/main.cc index 075b6ea2d3..5214ca5ca5 100644 --- a/examples/peerconnection/server/main.cc +++ b/examples/peerconnection/server/main.cc @@ -18,7 +18,19 @@ #include "examples/peerconnection/server/data_socket.h" #include "examples/peerconnection/server/peer_channel.h" #include "examples/peerconnection/server/utils.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( + force_fieldtrials, + "", + "Field trials control experimental features. This flag specifies the field " + "trials in effect. E.g. running with " + "--force_fieldtrials=WebRTC-FooFeature/Enabled/ " + "will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " + "trials are separated by \"/\""); static const size_t kMaxConnections = (FD_SETSIZE - 2); @@ -62,6 +74,11 @@ int main(int argc, char* argv[]) { return 0; } + webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); + // InitFieldTrialsFromString stores the char*, so the char array must outlive + // the application. + webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); + int port = strtol((parser.GetFlag("port")).c_str(), NULL, 10); // Abort if the user specifies a port that is outside the allowed