Support forcing field trial in audioproc_f simulator
This allows the user to run audioproc_f with various field trials set.
The approach is copied from test/test_main_lib.cc.
Tested:
1. Verified bitexactness vs ToT audioproc_f on a large dataset of aecdumps
2. Ran it with flags --aec=1 --force_fieldtrials="WebRTC-Aec3ClampInstQualityToZeroKillSwitch/Enabled/WebRTC-Aec3ClampInstQualityToOneKillSwitch/Enabled/" and verified in GDB that the AEC3 config was changed accordingly.
No-Try: True
Bug: webrtc:5298
Change-Id: I70eec7777f70893b36af33794a5842f67d56af31
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172623
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30976}
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 6e9f584..2c7b73b 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -542,6 +542,7 @@
"../../rtc_base:task_queue_for_test",
"../../rtc_base/system:file_wrapper",
"../../system_wrappers",
+ "../../system_wrappers:field_trial",
"../../test:test_support",
"aec_dump",
"aec_dump:aec_dump_impl",
diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc
index a37856e..d9a4227 100644
--- a/modules/audio_processing/test/audioproc_float_impl.cc
+++ b/modules/audio_processing/test/audioproc_float_impl.cc
@@ -27,6 +27,7 @@
#include "modules/audio_processing/test/wav_based_simulator.h"
#include "rtc_base/checks.h"
#include "rtc_base/strings/string_builder.h"
+#include "system_wrappers/include/field_trial.h"
constexpr int kParameterNotSpecifiedValue = -10000;
@@ -256,6 +257,13 @@
false,
"Produce floating point wav output files.");
+ABSL_FLAG(std::string,
+ force_fieldtrials,
+ "",
+ "Field trials control experimental feature code which can be forced. "
+ "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
+ " will assign the group Enable to field trial WebRTC-FooFeature.");
+
namespace webrtc {
namespace test {
namespace {
@@ -631,6 +639,11 @@
return 1;
}
+ // InitFieldTrialsFromString stores the char*, so the char array must
+ // outlive the application.
+ const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
+
SimulationSettings settings = CreateSettings();
if (!input_aecdump.empty()) {
settings.aec_dump_input_string = input_aecdump;