During AEC development, it is handy to be able to simulate different
orders of the ProcessStream and ProcessReverseStream API calls. This CL adds the ability to specify that call order in a file. BUG=webrtc:6018 Review-Url: https://codereview.webrtc.org/2561843003 Cr-Commit-Position: refs/heads/master@{#15503}
This commit is contained in:
parent
df80fd1259
commit
5ad5de3716
@ -81,6 +81,7 @@ struct SimulationSettings {
|
||||
rtc::Optional<std::string> aec_dump_output_filename;
|
||||
bool fixed_interface = false;
|
||||
bool store_intermediate_output = false;
|
||||
rtc::Optional<std::string> custom_call_order_filename;
|
||||
};
|
||||
|
||||
// Holds a few statistics about a series of TickIntervals.
|
||||
|
||||
@ -166,6 +166,7 @@ DEFINE_bool(discard_settings_in_aecdump,
|
||||
DEFINE_bool(store_intermediate_output,
|
||||
false,
|
||||
"Creates new output files after each init");
|
||||
DEFINE_string(custom_call_order_file, "", "Custom process API call order file");
|
||||
|
||||
void SetSettingIfSpecified(const std::string value,
|
||||
rtc::Optional<std::string>* parameter) {
|
||||
@ -257,6 +258,8 @@ SimulationSettings CreateSettings() {
|
||||
SetSettingIfSpecified(FLAGS_stream_delay, &settings.stream_delay);
|
||||
SetSettingIfSpecified(FLAGS_stream_drift_samples,
|
||||
&settings.stream_drift_samples);
|
||||
SetSettingIfSpecified(FLAGS_custom_call_order_file,
|
||||
&settings.custom_call_order_filename);
|
||||
settings.report_performance = FLAGS_performance_report;
|
||||
settings.use_verbose_logging = FLAGS_verbose;
|
||||
settings.report_bitexactness = FLAGS_bitexactness_report;
|
||||
@ -368,6 +371,11 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
|
||||
"Error: --bitexactness_report can only be used when operating on an "
|
||||
"aecdump\n");
|
||||
|
||||
ReportConditionalErrorAndExit(
|
||||
settings.custom_call_order_filename && settings.aec_dump_input_filename,
|
||||
"Error: --custom_call_order_file cannot be used when operating on an "
|
||||
"aecdump\n");
|
||||
|
||||
auto valid_wav_name = [](const std::string& wav_file_name) {
|
||||
if (wav_file_name.size() < 5) {
|
||||
return false;
|
||||
|
||||
@ -10,19 +10,57 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/test/wav_based_simulator.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/test/test_utils.h"
|
||||
#include "webrtc/test/testsupport/trace_to_stderr.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
std::vector<WavBasedSimulator::SimulationEventType>
|
||||
WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
|
||||
std::vector<WavBasedSimulator::SimulationEventType> call_chain;
|
||||
FILE* stream = OpenFile(filename.c_str(), "r");
|
||||
|
||||
RTC_CHECK(stream) << "Could not open the custom call order file, reverting "
|
||||
"to using the default call order";
|
||||
|
||||
char c;
|
||||
size_t num_read = fread(&c, sizeof(char), 1, stream);
|
||||
while (num_read > 0) {
|
||||
switch (c) {
|
||||
case 'r':
|
||||
call_chain.push_back(SimulationEventType::kProcessReverseStream);
|
||||
break;
|
||||
case 'c':
|
||||
call_chain.push_back(SimulationEventType::kProcessStream);
|
||||
break;
|
||||
case '\n':
|
||||
break;
|
||||
default:
|
||||
FATAL() << "Incorrect custom call order file, reverting to using the "
|
||||
"default call order";
|
||||
fclose(stream);
|
||||
return WavBasedSimulator::GetDefaultEventChain();
|
||||
}
|
||||
|
||||
num_read = fread(&c, sizeof(char), 1, stream);
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
return call_chain;
|
||||
}
|
||||
|
||||
WavBasedSimulator::WavBasedSimulator(const SimulationSettings& settings)
|
||||
: AudioProcessingSimulator(settings) {}
|
||||
|
||||
WavBasedSimulator::~WavBasedSimulator() = default;
|
||||
|
||||
std::vector<WavBasedSimulator::SimulationEventType>
|
||||
WavBasedSimulator::GetDefaultEventChain() const {
|
||||
WavBasedSimulator::GetDefaultEventChain() {
|
||||
std::vector<WavBasedSimulator::SimulationEventType> call_chain(2);
|
||||
call_chain[0] = SimulationEventType::kProcessStream;
|
||||
call_chain[1] = SimulationEventType::kProcessReverseStream;
|
||||
@ -59,7 +97,12 @@ void WavBasedSimulator::Process() {
|
||||
trace_to_stderr.reset(new test::TraceToStderr(true));
|
||||
}
|
||||
|
||||
call_chain_ = GetDefaultEventChain();
|
||||
if (settings_.custom_call_order_filename) {
|
||||
call_chain_ = WavBasedSimulator::GetCustomEventChain(
|
||||
*settings_.custom_call_order_filename);
|
||||
} else {
|
||||
call_chain_ = WavBasedSimulator::GetDefaultEventChain();
|
||||
}
|
||||
CreateAudioProcessor();
|
||||
|
||||
Initialize();
|
||||
|
||||
@ -40,7 +40,9 @@ class WavBasedSimulator final : public AudioProcessingSimulator {
|
||||
bool HandleProcessReverseStreamCall();
|
||||
void PrepareProcessStreamCall();
|
||||
void PrepareReverseProcessStreamCall();
|
||||
std::vector<SimulationEventType> GetDefaultEventChain() const;
|
||||
static std::vector<SimulationEventType> GetDefaultEventChain();
|
||||
static std::vector<SimulationEventType> GetCustomEventChain(
|
||||
const std::string& filename);
|
||||
|
||||
std::vector<SimulationEventType> call_chain_;
|
||||
int last_specified_microphone_level_ = 100;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user