Bump to WebRTC M120 release
Some API deprecation -- ExperimentalAgc and ExperimentalNs are gone. We're continuing to carry iSAC even though it's gone upstream, but maybe we'll want to drop that soon.
This commit is contained in:
@ -13,9 +13,13 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "experiments/registered_field_trials.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/containers/flat_set.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/string_encode.h"
|
||||
|
||||
@ -26,9 +30,15 @@ namespace field_trial {
|
||||
|
||||
static const char* trials_init_string = NULL;
|
||||
|
||||
#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
|
||||
namespace {
|
||||
|
||||
constexpr char kPersistentStringSeparator = '/';
|
||||
|
||||
flat_set<std::string>& TestKeys() {
|
||||
static auto* test_keys = new flat_set<std::string>();
|
||||
return *test_keys;
|
||||
}
|
||||
|
||||
// Validates the given field trial string.
|
||||
// E.g.:
|
||||
// "WebRTC-experimentFoo/Enabled/WebRTC-experimentBar/Enabled100kbps/"
|
||||
@ -68,9 +78,10 @@ bool FieldTrialsStringIsValidInternal(const absl::string_view trials) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool FieldTrialsStringIsValid(const char* trials_string) {
|
||||
bool FieldTrialsStringIsValid(absl::string_view trials_string) {
|
||||
return FieldTrialsStringIsValidInternal(trials_string);
|
||||
}
|
||||
|
||||
@ -78,18 +89,19 @@ void InsertOrReplaceFieldTrialStringsInMap(
|
||||
std::map<std::string, std::string>* fieldtrial_map,
|
||||
const absl::string_view trials_string) {
|
||||
if (FieldTrialsStringIsValidInternal(trials_string)) {
|
||||
std::vector<std::string> tokens;
|
||||
rtc::split(std::string(trials_string), '/', &tokens);
|
||||
std::vector<absl::string_view> tokens = rtc::split(trials_string, '/');
|
||||
// Skip last token which is empty due to trailing '/'.
|
||||
for (size_t idx = 0; idx < tokens.size() - 1; idx += 2) {
|
||||
(*fieldtrial_map)[tokens[idx]] = tokens[idx + 1];
|
||||
(*fieldtrial_map)[std::string(tokens[idx])] =
|
||||
std::string(tokens[idx + 1]);
|
||||
}
|
||||
} else {
|
||||
RTC_DCHECK(false) << "Invalid field trials string:" << trials_string;
|
||||
RTC_DCHECK_NOTREACHED() << "Invalid field trials string:" << trials_string;
|
||||
}
|
||||
}
|
||||
|
||||
std::string MergeFieldTrialsStrings(const char* first, const char* second) {
|
||||
std::string MergeFieldTrialsStrings(absl::string_view first,
|
||||
absl::string_view second) {
|
||||
std::map<std::string, std::string> fieldtrial_map;
|
||||
InsertOrReplaceFieldTrialStringsInMap(&fieldtrial_map, first);
|
||||
InsertOrReplaceFieldTrialStringsInMap(&fieldtrial_map, second);
|
||||
@ -102,11 +114,23 @@ std::string MergeFieldTrialsStrings(const char* first, const char* second) {
|
||||
return merged;
|
||||
}
|
||||
|
||||
std::string FindFullName(const std::string& name) {
|
||||
#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
|
||||
std::string FindFullName(absl::string_view name) {
|
||||
#if WEBRTC_STRICT_FIELD_TRIALS == 1
|
||||
RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, name) ||
|
||||
TestKeys().contains(name))
|
||||
<< name << " is not registered, see g3doc/field-trials.md.";
|
||||
#elif WEBRTC_STRICT_FIELD_TRIALS == 2
|
||||
RTC_LOG_IF(LS_WARNING,
|
||||
!(absl::c_linear_search(kRegisteredFieldTrials, name) ||
|
||||
TestKeys().contains(name)))
|
||||
<< name << " is not registered, see g3doc/field-trials.md.";
|
||||
#endif
|
||||
|
||||
if (trials_init_string == NULL)
|
||||
return std::string();
|
||||
|
||||
std::string trials_string(trials_init_string);
|
||||
absl::string_view trials_string(trials_init_string);
|
||||
if (trials_string.empty())
|
||||
return std::string();
|
||||
|
||||
@ -122,14 +146,14 @@ std::string FindFullName(const std::string& name) {
|
||||
if (field_value_end == trials_string.npos ||
|
||||
field_value_end == field_name_end + 1)
|
||||
break;
|
||||
std::string field_name(trials_string, next_item,
|
||||
field_name_end - next_item);
|
||||
std::string field_value(trials_string, field_name_end + 1,
|
||||
field_value_end - field_name_end - 1);
|
||||
absl::string_view field_name =
|
||||
trials_string.substr(next_item, field_name_end - next_item);
|
||||
absl::string_view field_value = trials_string.substr(
|
||||
field_name_end + 1, field_value_end - field_name_end - 1);
|
||||
next_item = field_value_end + 1;
|
||||
|
||||
if (name == field_name)
|
||||
return field_value;
|
||||
return std::string(field_value);
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
@ -138,12 +162,10 @@ std::string FindFullName(const std::string& name) {
|
||||
// Optionally initialize field trial from a string.
|
||||
void InitFieldTrialsFromString(const char* trials_string) {
|
||||
RTC_LOG(LS_INFO) << "Setting field trial string:" << trials_string;
|
||||
#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
|
||||
if (trials_string) {
|
||||
RTC_DCHECK(FieldTrialsStringIsValidInternal(trials_string))
|
||||
<< "Invalid field trials string:" << trials_string;
|
||||
};
|
||||
#endif // WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT
|
||||
trials_init_string = trials_string;
|
||||
}
|
||||
|
||||
@ -151,5 +173,14 @@ const char* GetFieldTrialString() {
|
||||
return trials_init_string;
|
||||
}
|
||||
|
||||
FieldTrialsAllowedInScopeForTesting::FieldTrialsAllowedInScopeForTesting(
|
||||
flat_set<std::string> keys) {
|
||||
TestKeys() = std::move(keys);
|
||||
}
|
||||
|
||||
FieldTrialsAllowedInScopeForTesting::~FieldTrialsAllowedInScopeForTesting() {
|
||||
TestKeys().clear();
|
||||
}
|
||||
|
||||
} // namespace field_trial
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user