From a36ad6929dda9cb7af2d035c9f12230e5d433f99 Mon Sep 17 00:00:00 2001 From: "andresp@webrtc.org" Date: Wed, 14 May 2014 12:24:04 +0000 Subject: [PATCH] Add webrtc field trials API. From now on it is expected that code linking system_wrappers.gyp:system_wrappers provides an implementation for field_trial API or links with the default one in system_wrappers.gyp:field_trial_default. Note: Since there is no use of webrtc::field_trial API inside webrtc this CL on itself does not forces the clients to actually define it. It however lays the API and updates the gyp rules to link with so that it is ready to use. Tested: Introduced a use of field trial in system wrappers and make sure all bots were building successfully. BUG=crbug/367114 R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/14489004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6147 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/acm2/audio_coding_module.gypi | 2 + .../audio_coding/neteq4/neteq_tests.gypi | 1 + .../remote_bitrate_estimator.gypi | 2 + .../codecs/tools/video_codecs_tools.gypi | 1 + .../main/source/video_coding_test.gypi | 1 + .../system_wrappers/interface/field_trial.h | 71 +++++++++++++++++++ .../source/field_trial_default.cc | 22 ++++++ .../source/system_wrappers.gyp | 10 +++ webrtc/test/test.gyp | 12 ++++ webrtc/tools/tools.gyp | 2 + .../test/auto_test/vie_auto_test.gypi | 1 + webrtc/voice_engine/voice_engine.gyp | 2 + webrtc/webrtc_examples.gyp | 1 + webrtc/webrtc_tests.gypi | 5 +- 14 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 webrtc/system_wrappers/interface/field_trial.h create mode 100644 webrtc/system_wrappers/source/field_trial_default.cc diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi index 07fe7272e7..459313bb24 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi @@ -124,6 +124,7 @@ '<(DEPTH)/testing/gtest.gyp:gtest', '<(webrtc_root)/test/test.gyp:test_support', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', ], 'sources': [ @@ -141,6 +142,7 @@ '<(DEPTH)/testing/gtest.gyp:gtest', '<(webrtc_root)/test/test.gyp:test_support', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', ], 'sources': [ diff --git a/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi b/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi index d19c6b226d..2be4737961 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi +++ b/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi @@ -88,6 +88,7 @@ 'neteq_unittest_tools', '<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', ], 'sources': [ 'tools/rtp_analyze.cc', diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi index 7292caea35..c2f1b3da47 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi @@ -45,6 +45,7 @@ ], 'dependencies': [ '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', 'bwe_tools_util', 'rtp_rtcp', ], @@ -67,6 +68,7 @@ ], 'dependencies': [ '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', 'bwe_tools_util', 'rtp_rtcp', ], diff --git a/webrtc/modules/video_coding/codecs/tools/video_codecs_tools.gypi b/webrtc/modules/video_coding/codecs/tools/video_codecs_tools.gypi index cdae0afeaa..8f15b28504 100644 --- a/webrtc/modules/video_coding/codecs/tools/video_codecs_tools.gypi +++ b/webrtc/modules/video_coding/codecs/tools/video_codecs_tools.gypi @@ -17,6 +17,7 @@ 'video_codecs_test_framework', 'webrtc_video_coding', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(webrtc_root)/test/metrics.gyp:metrics', '<(webrtc_vp8_dir)/vp8.gyp:webrtc_vp8', ], diff --git a/webrtc/modules/video_coding/main/source/video_coding_test.gypi b/webrtc/modules/video_coding/main/source/video_coding_test.gypi index a64e02d02c..b0fe510cf9 100644 --- a/webrtc/modules/video_coding/main/source/video_coding_test.gypi +++ b/webrtc/modules/video_coding/main/source/video_coding_test.gypi @@ -20,6 +20,7 @@ '<(webrtc_root)/test/test.gyp:test_support', '<(webrtc_root)/test/metrics.gyp:metrics', '<(webrtc_root)/common_video/common_video.gyp:common_video', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', ], 'sources': [ # headers diff --git a/webrtc/system_wrappers/interface/field_trial.h b/webrtc/system_wrappers/interface/field_trial.h new file mode 100644 index 0000000000..d38df26cc2 --- /dev/null +++ b/webrtc/system_wrappers/interface/field_trial.h @@ -0,0 +1,71 @@ +// +// Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// + +#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_ + +#include + +#include "webrtc/common_types.h" + +// Field trials allow webrtc clients (such as Chrome) to turn on feature code +// in binaries out in the field and gather information with that. +// +// WebRTC clients MUST provide an implementation of: +// +// std::string webrtc::field_trial::FindFullName(const std::string& trial). +// +// Or link with a default one provided in: +// +// system_wrappers/source/system_wrappers.gyp:field_trial_default +// +// +// They are designed to wire up directly to chrome field trials and to speed up +// developers by reducing the need to wire APIs to control whether a feature is +// on/off. E.g. to experiment with a new method that could lead to a different +// trade-off between CPU/bandwidth: +// +// 1 - Develop the feature with default behaviour off: +// +// if (FieldTrial::FindFullName("WebRTCExperimenMethod2") == "Enabled") +// method2(); +// else +// method1(); +// +// 2 - Once the changes are rolled to chrome, the new code path can be +// controlled as normal chrome field trials. +// +// 3 - Evaluate the new feature and clean the code paths. +// +// Notes: +// - NOT every feature is a candidate to be controlled by this mechanism as +// it may require negotation between involved parties (e.g. SDP). +// +// TODO(andresp): since chrome --force-fieldtrials does not marks the trial +// as active it does not gets propaged to renderer process. For now one +// needs to push a config with start_active:true or run a local finch +// server. +// +// TODO(andresp): support --force_fieldtirals from webrtc tests. +// TODO(andresp): find out how to get bots to run tests with trials enabled. + +namespace webrtc { +namespace field_trial { + +// Returns the group name chosen for the named trial, or the empty string +// if the trial does not exists. +// +// Note: To keep things tidy append all the trial names with WebRTC. +std::string FindFullName(const std::string& name); + +} // namespace field_trial +} // namespace webrtc + +#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_ diff --git a/webrtc/system_wrappers/source/field_trial_default.cc b/webrtc/system_wrappers/source/field_trial_default.cc new file mode 100644 index 0000000000..892623cef5 --- /dev/null +++ b/webrtc/system_wrappers/source/field_trial_default.cc @@ -0,0 +1,22 @@ +// Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. An additional intellectual property rights grant can be found +// in the file PATENTS. All contributing project authors may +// be found in the AUTHORS file in the root of the source tree. +// + +#include "webrtc/system_wrappers/interface/field_trial.h" + +// Clients of webrtc that do not want to configure field trials can link with +// this instead of providing their own implementation. +namespace webrtc { +namespace field_trial { + +std::string FindFullName(const std::string& name) { + return std::string(); +} + +} // namespace field_trial +} // namespace webrtc diff --git a/webrtc/system_wrappers/source/system_wrappers.gyp b/webrtc/system_wrappers/source/system_wrappers.gyp index dba963ce8a..66b34356c2 100644 --- a/webrtc/system_wrappers/source/system_wrappers.gyp +++ b/webrtc/system_wrappers/source/system_wrappers.gyp @@ -38,6 +38,7 @@ '../interface/data_log_impl.h', '../interface/event_tracer.h', '../interface/event_wrapper.h', + '../interface/field_trial.h', '../interface/file_wrapper.h', '../interface/fix_interlocked_exchange_pointer_win.h', '../interface/logcat_trace_context.h', @@ -194,6 +195,15 @@ 4267, # size_t to int truncation. 4334, # Ignore warning on shift operator promotion. ], + }, { + 'target_name': 'field_trial_default', + 'type': 'static_library', + 'sources': [ + 'field_trial_default.cc', + ], + 'dependencies': [ + 'system_wrappers', + ] }, ], # targets 'conditions': [ diff --git a/webrtc/test/test.gyp b/webrtc/test/test.gyp index e920d6ea66..5be3c10640 100644 --- a/webrtc/test/test.gyp +++ b/webrtc/test/test.gyp @@ -63,6 +63,17 @@ '<(webrtc_root)/modules/modules.gyp:rtp_rtcp', ], }, + { + 'target_name': 'test_main', + 'type': 'static_library', + 'sources': [ + 'test_main.cc', + ], + 'dependencies': [ + '<(DEPTH)/testing/gtest.gyp:gtest', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', + ], + }, { 'target_name': 'test_support', 'type': 'static_library', @@ -118,6 +129,7 @@ 'type': 'static_library', 'dependencies': [ 'test_support', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', ], 'sources': [ 'run_all_unittests.cc', diff --git a/webrtc/tools/tools.gyp b/webrtc/tools/tools.gyp index b8dc4c142d..77238095d9 100644 --- a/webrtc/tools/tools.gyp +++ b/webrtc/tools/tools.gyp @@ -91,6 +91,7 @@ 'type': 'executable', 'dependencies': [ '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', ], 'sources': [ 'force_mic_volume_max/force_mic_volume_max.cc', @@ -106,6 +107,7 @@ 'dependencies': [ '<(webrtc_root)/test/test.gyp:channel_transport', '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', ], diff --git a/webrtc/video_engine/test/auto_test/vie_auto_test.gypi b/webrtc/video_engine/test/auto_test/vie_auto_test.gypi index 7ceef0fa88..fb611b00d7 100644 --- a/webrtc/video_engine/test/auto_test/vie_auto_test.gypi +++ b/webrtc/video_engine/test/auto_test/vie_auto_test.gypi @@ -13,6 +13,7 @@ 'type': 'executable', 'dependencies': [ '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(webrtc_root)/modules/modules.gyp:video_render_module', '<(webrtc_root)/modules/modules.gyp:video_capture_module', '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine', diff --git a/webrtc/voice_engine/voice_engine.gyp b/webrtc/voice_engine/voice_engine.gyp index ead8819963..a2de46df9b 100644 --- a/webrtc/voice_engine/voice_engine.gyp +++ b/webrtc/voice_engine/voice_engine.gyp @@ -146,6 +146,7 @@ '<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(webrtc_root)/test/test.gyp:channel_transport', '<(webrtc_root)/test/test.gyp:test_support', ], @@ -211,6 +212,7 @@ '<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(webrtc_root)/test/test.gyp:channel_transport', '<(webrtc_root)/test/test.gyp:test_support', ], diff --git a/webrtc/webrtc_examples.gyp b/webrtc/webrtc_examples.gyp index e880c11d39..56a0e9efd6 100644 --- a/webrtc/webrtc_examples.gyp +++ b/webrtc/webrtc_examples.gyp @@ -16,6 +16,7 @@ 'dependencies': [ '<(DEPTH)/third_party/icu/icu.gyp:icuuc', '<(webrtc_root)/modules/modules.gyp:*', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', '<(webrtc_root)/test/test.gyp:channel_transport', '<(webrtc_root)/video_engine/video_engine.gyp:video_engine_core', '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine', diff --git a/webrtc/webrtc_tests.gypi b/webrtc/webrtc_tests.gypi index 384f57cc93..3160967053 100644 --- a/webrtc/webrtc_tests.gypi +++ b/webrtc/webrtc_tests.gypi @@ -26,6 +26,7 @@ '<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', 'test/webrtc_test_common.gyp:webrtc_test_common', + '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default', 'webrtc', ], }, @@ -39,13 +40,13 @@ 'video/video_send_stream_tests.cc', 'test/common_unittest.cc', 'test/testsupport/metrics/video_metrics_unittest.cc', - 'test/test_main.cc', ], 'dependencies': [ '<(DEPTH)/testing/gtest.gyp:gtest', 'modules/modules.gyp:rtp_rtcp', 'test/metrics.gyp:metrics', 'test/webrtc_test_common.gyp:webrtc_test_common', + 'test/test.gyp:test_main', 'webrtc', ], }, @@ -54,7 +55,6 @@ 'type': '<(gtest_target_type)', 'sources': [ 'modules/audio_coding/neteq4/test/neteq_performance_unittest.cc', - 'test/test_main.cc', 'video/call_perf_tests.cc', 'video/full_stack.cc', 'video/rampup_tests.cc', @@ -64,6 +64,7 @@ 'modules/modules.gyp:neteq_test_support', # Needed by neteq_performance_unittest. 'modules/modules.gyp:rtp_rtcp', 'test/webrtc_test_common.gyp:webrtc_test_common', + 'test/test.gyp:test_main', 'webrtc', ], },