Add runtime enabled features API to webrtc.
API is not used anywhere for now. When depending projects implement it or build with default implementation, it will be used. Bug: webrtc:8287 Change-Id: I9e2aa922c2bb2b543793cd0561d797b02288ea6c Reviewed-on: https://webrtc-review.googlesource.com/39042 Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21611}
This commit is contained in:

committed by
Commit Bot

parent
ce5c19add1
commit
8cf45e99c5
@ -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",
|
||||
]
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
31
system_wrappers/include/runtime_enabled_features.h
Normal file
31
system_wrappers/include/runtime_enabled_features.h
Normal file
@ -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 <string>
|
||||
|
||||
// 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_
|
31
system_wrappers/source/runtime_enabled_features_default.cc
Normal file
31
system_wrappers/source/runtime_enabled_features_default.cc
Normal file
@ -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
|
Reference in New Issue
Block a user