diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 8d19e755c2..e32dc1be9f 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -52,6 +52,7 @@ rtc_static_library("system_wrappers") { ":cpu_features_api", ":field_trial_api", ":metrics_api", + ":runtime_enabled_features_api", "..:webrtc_common", "../:typedefs", "../api:optional", @@ -127,6 +128,12 @@ rtc_source_set("field_trial_api") { ] } +rtc_source_set("runtime_enabled_features_api") { + sources = [ + "include/runtime_enabled_features.h", + ] +} + rtc_source_set("metrics_api") { visibility = [ "*" ] sources = [ @@ -150,6 +157,16 @@ rtc_source_set("field_trial_default") { ] } +rtc_source_set("runtime_enabled_features_default") { + sources = [ + "source/runtime_enabled_features_default.cc", + ] + deps = [ + ":runtime_enabled_features_api", + "../rtc_base:rtc_base_approved", + ] +} + rtc_source_set("metrics_default") { visibility = [ "*" ] sources = [ @@ -166,6 +183,7 @@ group("system_wrappers_default") { deps = [ ":field_trial_default", ":metrics_default", + ":runtime_enabled_features_default", ":system_wrappers", ] } diff --git a/system_wrappers/include/field_trial.h b/system_wrappers/include/field_trial.h index 399dcbc0a6..c6a6223ca9 100644 --- a/system_wrappers/include/field_trial.h +++ b/system_wrappers/include/field_trial.h @@ -69,6 +69,12 @@ inline bool IsEnabled(const char* name) { return FindFullName(name).find("Enabled") == 0; } +// Convenience method, returns true iff FindFullName(name) return a string that +// starts with "Disabled". +inline bool IsDisabled(const char* name) { + return FindFullName(name).find("Disabled") == 0; +} + } // namespace field_trial } // namespace webrtc diff --git a/system_wrappers/include/runtime_enabled_features.h b/system_wrappers/include/runtime_enabled_features.h new file mode 100644 index 0000000000..a972cdac93 --- /dev/null +++ b/system_wrappers/include/runtime_enabled_features.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 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 SYSTEM_WRAPPERS_INCLUDE_RUNTIME_ENABLED_FEATURES_H_ +#define SYSTEM_WRAPPERS_INCLUDE_RUNTIME_ENABLED_FEATURES_H_ + +#include + +// These functions for querying enabled runtime features must be implemented +// by all webrtc clients (such as Chrome). +// Default implementation is provided in: +// +// system_wrappers/system_wrappers:runtime_enabled_features_default + +// TODO(ilnik): Find a more flexible way to use Chrome features. +// This interface requires manual translation from feature name to +// Chrome feature class in third_party/webrtc_overrides. +namespace webrtc { +namespace runtime_enabled_features { +bool IsFeatureEnabled(std::string feature_name); + +} // namespace runtime_enabled_features +} // namespace webrtc + +#endif // SYSTEM_WRAPPERS_INCLUDE_RUNTIME_ENABLED_FEATURES_H_ diff --git a/system_wrappers/source/runtime_enabled_features_default.cc b/system_wrappers/source/runtime_enabled_features_default.cc new file mode 100644 index 0000000000..cd0d157d68 --- /dev/null +++ b/system_wrappers/source/runtime_enabled_features_default.cc @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 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 "system_wrappers/include/runtime_enabled_features.h" + +#include "rtc_base/flags.h" + +namespace flags { +DEFINE_bool(enable_dual_stream_mode, + false, + "Enables dual video stream mode."); +} + +namespace webrtc { +namespace runtime_enabled_features { + +bool IsFeatureEnabled(std::string feature_name) { + if (feature_name == "WebRtcDualStreamMode") + return flags::FLAG_enable_dual_stream_mode; + return false; +} + +} // namespace runtime_enabled_features +} // namespace webrtc