In AudioProcessing Simulator move AudioProcessing construction closer to api layer
Removing AudioProcessingBuilder from few layers would simplify replacing with BuiltinAudioProcessingFactory in the upcoming patches. While doing cleanup also removed extra always empty parameters and run iwyu. Bug: webrtc:369904700 Change-Id: I54d44993701c30ca8f4cf38e822af08531fba310 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/366260 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43306}
This commit is contained in:
parent
1d2f85d1ce
commit
2b36b37d21
@ -29,9 +29,7 @@ int AudioprocFloat(rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
int AudioprocFloat(std::unique_ptr<AudioProcessingBuilder> ap_builder,
|
||||
int argc,
|
||||
char* argv[]) {
|
||||
return AudioprocFloatImpl(std::move(ap_builder), argc, argv,
|
||||
/*input_aecdump=*/"",
|
||||
/*processed_capture_samples=*/nullptr);
|
||||
return AudioprocFloatImpl(std::move(ap_builder), argc, argv);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
@ -445,7 +445,6 @@ if (rtc_include_tests) {
|
||||
"test/echo_canceller_test_tools.h",
|
||||
"test/echo_canceller_test_tools_unittest.cc",
|
||||
"test/echo_control_mock.h",
|
||||
"test/test_utils.h",
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -518,26 +517,22 @@ if (rtc_include_tests) {
|
||||
":audioproc_debug_proto",
|
||||
":audioproc_protobuf_utils",
|
||||
":audioproc_test_utils",
|
||||
":runtime_settings_protobuf_utils",
|
||||
"../../api:field_trials",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/audio:aec3_config",
|
||||
"../../api/audio:aec3_factory",
|
||||
"../../api/audio:audio_processing",
|
||||
"../../api/audio:echo_detector_creator",
|
||||
"../../common_audio",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:logging",
|
||||
"../../rtc_base:protobuf_utils",
|
||||
"../../rtc_base:rtc_json",
|
||||
"../../rtc_base:safe_conversions",
|
||||
"../../rtc_base:stringutils",
|
||||
"../../rtc_base:task_queue_for_test",
|
||||
"../../rtc_base:timeutils",
|
||||
"../../rtc_base/system:file_wrapper",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial",
|
||||
"../../test:test_support",
|
||||
"aec_dump",
|
||||
"aec_dump:aec_dump_impl",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/base:nullability",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
|
||||
@ -10,13 +10,29 @@
|
||||
|
||||
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "common_audio/channel_buffer.h"
|
||||
#include "common_audio/wav_file.h"
|
||||
#include "modules/audio_processing/debug.pb.h"
|
||||
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
#include "modules/audio_processing/test/protobuf_utils.h"
|
||||
#include "modules/audio_processing/test/test_utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
@ -80,11 +96,8 @@ bool ReadNextMessage(bool use_dump_file,
|
||||
|
||||
AecDumpBasedSimulator::AecDumpBasedSimulator(
|
||||
const SimulationSettings& settings,
|
||||
rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder)
|
||||
: AudioProcessingSimulator(settings,
|
||||
std::move(audio_processing),
|
||||
std::move(ap_builder)) {
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing)
|
||||
: AudioProcessingSimulator(settings, std::move(audio_processing)) {
|
||||
MaybeOpenCallOrderFile();
|
||||
}
|
||||
|
||||
|
||||
@ -11,10 +11,16 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "common_audio/channel_buffer.h"
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
#include "modules/audio_processing/test/test_utils.h"
|
||||
|
||||
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
|
||||
#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
|
||||
@ -28,9 +34,9 @@ namespace test {
|
||||
// Used to perform an audio processing simulation from an aec dump.
|
||||
class AecDumpBasedSimulator final : public AudioProcessingSimulator {
|
||||
public:
|
||||
AecDumpBasedSimulator(const SimulationSettings& settings,
|
||||
rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder);
|
||||
AecDumpBasedSimulator(
|
||||
const SimulationSettings& settings,
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing);
|
||||
|
||||
AecDumpBasedSimulator() = delete;
|
||||
AecDumpBasedSimulator(const AecDumpBasedSimulator&) = delete;
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@ -18,48 +19,26 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/audio/echo_canceller3_factory.h"
|
||||
#include "api/audio/echo_detector_creator.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "common_audio/channel_buffer.h"
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "common_audio/wav_file.h"
|
||||
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
|
||||
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
#include "modules/audio_processing/test/echo_canceller3_config_json.h"
|
||||
#include "modules/audio_processing/test/api_call_statistics.h"
|
||||
#include "modules/audio_processing/test/fake_recording_device.h"
|
||||
#include "modules/audio_processing/test/test_utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/strings/json.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
// Helper for reading JSON from a file and parsing it to an AEC3 configuration.
|
||||
EchoCanceller3Config ReadAec3ConfigFromJsonFile(absl::string_view filename) {
|
||||
std::string json_string;
|
||||
std::string s;
|
||||
std::ifstream f(std::string(filename).c_str());
|
||||
if (f.fail()) {
|
||||
std::cout << "Failed to open the file " << filename << std::endl;
|
||||
RTC_CHECK_NOTREACHED();
|
||||
}
|
||||
while (std::getline(f, s)) {
|
||||
json_string += s;
|
||||
}
|
||||
|
||||
bool parsing_successful;
|
||||
EchoCanceller3Config cfg;
|
||||
Aec3ConfigFromJsonString(json_string, &cfg, &parsing_successful);
|
||||
if (!parsing_successful) {
|
||||
std::cout << "Parsing of json string failed: " << std::endl
|
||||
<< json_string << std::endl;
|
||||
RTC_CHECK_NOTREACHED();
|
||||
}
|
||||
RTC_CHECK(EchoCanceller3Config::Validate(&cfg));
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
std::string GetIndexedOutputWavFilename(absl::string_view wav_name,
|
||||
int counter) {
|
||||
@ -114,8 +93,7 @@ SimulationSettings::~SimulationSettings() = default;
|
||||
|
||||
AudioProcessingSimulator::AudioProcessingSimulator(
|
||||
const SimulationSettings& settings,
|
||||
rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder)
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing)
|
||||
: settings_(settings),
|
||||
ap_(std::move(audio_processing)),
|
||||
applied_input_volume_(settings.initial_mic_level),
|
||||
@ -149,55 +127,6 @@ AudioProcessingSimulator::AudioProcessingSimulator(
|
||||
|
||||
if (settings_.simulate_mic_gain)
|
||||
RTC_LOG(LS_VERBOSE) << "Simulating analog mic gain";
|
||||
|
||||
// Create the audio processing object.
|
||||
RTC_CHECK(!(ap_ && ap_builder))
|
||||
<< "The AudioProcessing and the AudioProcessingBuilder cannot both be "
|
||||
"specified at the same time.";
|
||||
|
||||
if (ap_) {
|
||||
RTC_CHECK(!settings_.aec_settings_filename);
|
||||
RTC_CHECK(!settings_.print_aec_parameter_values);
|
||||
} else {
|
||||
// Use specied builder if such is provided, otherwise create a new builder.
|
||||
std::unique_ptr<AudioProcessingBuilder> builder =
|
||||
!!ap_builder ? std::move(ap_builder)
|
||||
: std::make_unique<AudioProcessingBuilder>();
|
||||
|
||||
// Create and set an EchoCanceller3Factory if needed.
|
||||
const bool use_aec = settings_.use_aec && *settings_.use_aec;
|
||||
if (use_aec) {
|
||||
EchoCanceller3Config cfg;
|
||||
if (settings_.aec_settings_filename) {
|
||||
if (settings_.use_verbose_logging) {
|
||||
std::cout << "Reading AEC Parameters from JSON input." << std::endl;
|
||||
}
|
||||
cfg = ReadAec3ConfigFromJsonFile(*settings_.aec_settings_filename);
|
||||
}
|
||||
|
||||
if (settings_.linear_aec_output_filename) {
|
||||
cfg.filter.export_linear_aec_output = true;
|
||||
}
|
||||
|
||||
if (settings_.print_aec_parameter_values) {
|
||||
if (!settings_.use_quiet_output) {
|
||||
std::cout << "AEC settings:" << std::endl;
|
||||
}
|
||||
std::cout << Aec3ConfigToJsonString(cfg) << std::endl;
|
||||
}
|
||||
|
||||
auto echo_control_factory = std::make_unique<EchoCanceller3Factory>(cfg);
|
||||
builder->SetEchoControlFactory(std::move(echo_control_factory));
|
||||
}
|
||||
|
||||
if (settings_.use_ed && *settings.use_ed) {
|
||||
builder->SetEchoDetector(CreateEchoDetector());
|
||||
}
|
||||
|
||||
// Create an audio processing object.
|
||||
ap_ = builder->Create();
|
||||
RTC_CHECK(ap_);
|
||||
}
|
||||
}
|
||||
|
||||
AudioProcessingSimulator::~AudioProcessingSimulator() {
|
||||
|
||||
@ -11,21 +11,27 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "common_audio/channel_buffer.h"
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "common_audio/wav_file.h"
|
||||
#include "modules/audio_processing/test/api_call_statistics.h"
|
||||
#include "modules/audio_processing/test/fake_recording_device.h"
|
||||
#include "modules/audio_processing/test/test_utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/task_queue_for_test.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -158,9 +164,9 @@ struct SimulationSettings {
|
||||
// Provides common functionality for performing audioprocessing simulations.
|
||||
class AudioProcessingSimulator {
|
||||
public:
|
||||
AudioProcessingSimulator(const SimulationSettings& settings,
|
||||
rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder);
|
||||
AudioProcessingSimulator(
|
||||
const SimulationSettings& settings,
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing);
|
||||
|
||||
AudioProcessingSimulator() = delete;
|
||||
AudioProcessingSimulator(const AudioProcessingSimulator&) = delete;
|
||||
|
||||
@ -10,24 +10,33 @@
|
||||
|
||||
#include "modules/audio_processing/test/audioproc_float_impl.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
#include "api/audio/echo_canceller3_factory.h"
|
||||
#include "api/audio/echo_detector_creator.h"
|
||||
#include "api/field_trials.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "common_audio/wav_file.h"
|
||||
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
#include "modules/audio_processing/test/echo_canceller3_config_json.h"
|
||||
#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;
|
||||
|
||||
@ -533,10 +542,8 @@ void ReportConditionalErrorAndExit(bool condition, absl::string_view message) {
|
||||
}
|
||||
}
|
||||
|
||||
void PerformBasicParameterSanityChecks(
|
||||
const SimulationSettings& settings,
|
||||
bool pre_constructed_ap_provided,
|
||||
bool pre_constructed_ap_builder_provided) {
|
||||
void PerformBasicParameterSanityChecks(const SimulationSettings& settings,
|
||||
bool pre_constructed_ap_provided) {
|
||||
if (settings.input_filename || settings.reverse_input_filename) {
|
||||
ReportConditionalErrorAndExit(
|
||||
!!settings.aec_dump_input_filename,
|
||||
@ -722,18 +729,13 @@ void PerformBasicParameterSanityChecks(
|
||||
"Error: --pre_amplifier_gain_factor needs --pre_amplifier to be "
|
||||
"specified and set.\n");
|
||||
|
||||
ReportConditionalErrorAndExit(
|
||||
pre_constructed_ap_provided && pre_constructed_ap_builder_provided,
|
||||
"Error: The AudioProcessing and the AudioProcessingBuilder cannot both "
|
||||
"be specified at the same time.\n");
|
||||
|
||||
ReportConditionalErrorAndExit(
|
||||
settings.aec_settings_filename && pre_constructed_ap_provided,
|
||||
"Error: The aec_settings_filename cannot be specified when a "
|
||||
"pre-constructed audio processing object is provided.\n");
|
||||
|
||||
ReportConditionalErrorAndExit(
|
||||
settings.aec_settings_filename && pre_constructed_ap_provided,
|
||||
settings.print_aec_parameter_values && pre_constructed_ap_provided,
|
||||
"Error: The print_aec_parameter_values cannot be set when a "
|
||||
"pre-constructed audio processing object is provided.\n");
|
||||
|
||||
@ -745,37 +747,112 @@ void PerformBasicParameterSanityChecks(
|
||||
}
|
||||
}
|
||||
|
||||
int RunSimulation(rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder,
|
||||
int argc,
|
||||
char* argv[],
|
||||
absl::string_view input_aecdump,
|
||||
std::vector<float>* processed_capture_samples) {
|
||||
// Helper for reading JSON from a file and parsing it to an AEC3 configuration.
|
||||
EchoCanceller3Config ReadAec3ConfigFromJsonFile(absl::string_view filename) {
|
||||
std::string json_string;
|
||||
std::string s;
|
||||
std::ifstream f(std::string(filename).c_str());
|
||||
if (f.fail()) {
|
||||
std::cout << "Failed to open the file " << filename << std::endl;
|
||||
RTC_CHECK_NOTREACHED();
|
||||
}
|
||||
while (std::getline(f, s)) {
|
||||
json_string += s;
|
||||
}
|
||||
|
||||
bool parsing_successful;
|
||||
EchoCanceller3Config cfg;
|
||||
Aec3ConfigFromJsonString(json_string, &cfg, &parsing_successful);
|
||||
if (!parsing_successful) {
|
||||
std::cout << "Parsing of json string failed: " << std::endl
|
||||
<< json_string << std::endl;
|
||||
RTC_CHECK_NOTREACHED();
|
||||
}
|
||||
RTC_CHECK(EchoCanceller3Config::Validate(&cfg));
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void SetDependencies(const SimulationSettings& settings,
|
||||
AudioProcessingBuilder& builder) {
|
||||
// Create and set an EchoCanceller3Factory if needed.
|
||||
if (settings.use_aec && *settings.use_aec) {
|
||||
EchoCanceller3Config cfg;
|
||||
if (settings.aec_settings_filename) {
|
||||
if (settings.use_verbose_logging) {
|
||||
std::cout << "Reading AEC Parameters from JSON input." << std::endl;
|
||||
}
|
||||
cfg = ReadAec3ConfigFromJsonFile(*settings.aec_settings_filename);
|
||||
}
|
||||
|
||||
if (settings.linear_aec_output_filename) {
|
||||
cfg.filter.export_linear_aec_output = true;
|
||||
}
|
||||
|
||||
if (settings.print_aec_parameter_values) {
|
||||
if (!settings.use_quiet_output) {
|
||||
std::cout << "AEC settings:" << std::endl;
|
||||
}
|
||||
std::cout << Aec3ConfigToJsonString(cfg) << std::endl;
|
||||
}
|
||||
|
||||
builder.SetEchoControlFactory(std::make_unique<EchoCanceller3Factory>(cfg));
|
||||
}
|
||||
|
||||
if (settings.use_ed && *settings.use_ed) {
|
||||
builder.SetEchoDetector(CreateEchoDetector());
|
||||
}
|
||||
}
|
||||
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> Provide(
|
||||
const SimulationSettings& settings,
|
||||
absl::Nullable<std::unique_ptr<AudioProcessingBuilder>> ap_builder) {
|
||||
PerformBasicParameterSanityChecks(settings,
|
||||
/*pre_constructed_ap_provided=*/false);
|
||||
if (ap_builder == nullptr) {
|
||||
ap_builder = std::make_unique<AudioProcessingBuilder>();
|
||||
}
|
||||
SetDependencies(settings, *ap_builder);
|
||||
scoped_refptr<AudioProcessing> ap = ap_builder->Create();
|
||||
RTC_CHECK(ap);
|
||||
return ap;
|
||||
}
|
||||
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> Provide(
|
||||
const SimulationSettings& settings,
|
||||
absl::Nullable<scoped_refptr<AudioProcessing>> ap_provider) {
|
||||
if (ap_provider == nullptr) {
|
||||
return Provide(settings, std::make_unique<AudioProcessingBuilder>());
|
||||
}
|
||||
|
||||
PerformBasicParameterSanityChecks(settings,
|
||||
/*pre_constructed_ap_provided=*/true);
|
||||
return ap_provider;
|
||||
}
|
||||
|
||||
template <typename AudioProcessingProvider>
|
||||
int RunSimulation(AudioProcessingProvider ap_provider, int argc, char* argv[]) {
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
if (args.size() != 1) {
|
||||
printf("%s", kUsageDescription);
|
||||
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());
|
||||
// TODO: bugs.webrtc.org/369904700 - Propagate these field trials to construct
|
||||
// audio_processing when AudioProcessingImpl will be able to accept propagated
|
||||
// field trials through Environment.
|
||||
FieldTrials field_trials(absl::GetFlag(FLAGS_force_fieldtrials));
|
||||
|
||||
SimulationSettings settings = CreateSettings();
|
||||
if (!input_aecdump.empty()) {
|
||||
settings.aec_dump_input_string = input_aecdump;
|
||||
settings.processed_capture_samples = processed_capture_samples;
|
||||
RTC_CHECK(settings.processed_capture_samples);
|
||||
}
|
||||
PerformBasicParameterSanityChecks(settings, !!audio_processing, !!ap_builder);
|
||||
std::unique_ptr<AudioProcessingSimulator> processor;
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing =
|
||||
Provide(settings, std::move(ap_provider));
|
||||
|
||||
std::unique_ptr<AudioProcessingSimulator> processor;
|
||||
if (settings.aec_dump_input_filename || settings.aec_dump_input_string) {
|
||||
processor.reset(new AecDumpBasedSimulator(
|
||||
settings, std::move(audio_processing), std::move(ap_builder)));
|
||||
processor = std::make_unique<AecDumpBasedSimulator>(
|
||||
settings, std::move(audio_processing));
|
||||
} else {
|
||||
processor.reset(new WavBasedSimulator(settings, std::move(audio_processing),
|
||||
std::move(ap_builder)));
|
||||
processor = std::make_unique<WavBasedSimulator>(
|
||||
settings, std::move(audio_processing));
|
||||
}
|
||||
|
||||
if (settings.analysis_only) {
|
||||
@ -799,27 +876,23 @@ int RunSimulation(rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::cout << "The processing was not bitexact.";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int AudioprocFloatImpl(rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
int argc,
|
||||
char* argv[]) {
|
||||
return RunSimulation(
|
||||
std::move(audio_processing), /*ap_builder=*/nullptr, argc, argv,
|
||||
/*input_aecdump=*/"", /*processed_capture_samples=*/nullptr);
|
||||
int AudioprocFloatImpl(
|
||||
absl::Nullable<scoped_refptr<AudioProcessing>> audio_processing,
|
||||
int argc,
|
||||
char* argv[]) {
|
||||
return RunSimulation(std::move(audio_processing), argc, argv);
|
||||
}
|
||||
|
||||
int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder,
|
||||
int argc,
|
||||
char* argv[],
|
||||
absl::string_view input_aecdump,
|
||||
std::vector<float>* processed_capture_samples) {
|
||||
return RunSimulation(/*audio_processing=*/nullptr, std::move(ap_builder),
|
||||
argc, argv, input_aecdump, processed_capture_samples);
|
||||
int AudioprocFloatImpl(
|
||||
absl::Nullable<std::unique_ptr<AudioProcessingBuilder>> ap_builder,
|
||||
int argc,
|
||||
char* argv[]) {
|
||||
return RunSimulation(std::move(ap_builder), argc, argv);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
@ -13,37 +13,22 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
// This function implements the audio processing simulation utility. Pass
|
||||
// `input_aecdump` to provide the content of an AEC dump file as a string; if
|
||||
// `input_aecdump` is not passed, a WAV or AEC input dump file must be specified
|
||||
// via the `argv` argument. Pass `processed_capture_samples` to write in it the
|
||||
// samples processed on the capture side; if `processed_capture_samples` is not
|
||||
// passed, the output file can optionally be specified via the `argv` argument.
|
||||
// Any audio_processing object specified in the input is used for the
|
||||
// simulation. Note that when the audio_processing object is specified all
|
||||
// functionality that relies on using the internal builder is deactivated,
|
||||
// since the AudioProcessing object is already created and the builder is not
|
||||
// used in the simulation.
|
||||
int AudioprocFloatImpl(rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
int AudioprocFloatImpl(
|
||||
absl::Nullable<scoped_refptr<AudioProcessing>> audio_processing,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
|
||||
// This function implements the audio processing simulation utility. Pass
|
||||
// `input_aecdump` to provide the content of an AEC dump file as a string; if
|
||||
// `input_aecdump` is not passed, a WAV or AEC input dump file must be specified
|
||||
// via the `argv` argument. Pass `processed_capture_samples` to write in it the
|
||||
// samples processed on the capture side; if `processed_capture_samples` is not
|
||||
// passed, the output file can optionally be specified via the `argv` argument.
|
||||
int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder,
|
||||
int argc,
|
||||
char* argv[],
|
||||
absl::string_view input_aecdump,
|
||||
std::vector<float>* processed_capture_samples);
|
||||
int AudioprocFloatImpl(
|
||||
absl::Nullable<std::unique_ptr<AudioProcessingBuilder>> ap_builder,
|
||||
int argc,
|
||||
char* argv[]);
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -13,9 +13,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "common_audio/wav_file.h"
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
#include "modules/audio_processing/test/test_utils.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/system/file_wrapper.h"
|
||||
@ -56,11 +63,8 @@ WavBasedSimulator::GetCustomEventChain(absl::string_view filename) {
|
||||
|
||||
WavBasedSimulator::WavBasedSimulator(
|
||||
const SimulationSettings& settings,
|
||||
rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder)
|
||||
: AudioProcessingSimulator(settings,
|
||||
std::move(audio_processing),
|
||||
std::move(ap_builder)) {
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing)
|
||||
: AudioProcessingSimulator(settings, std::move(audio_processing)) {
|
||||
if (settings_.call_order_input_filename) {
|
||||
call_chain_ = WavBasedSimulator::GetCustomEventChain(
|
||||
*settings_.call_order_input_filename);
|
||||
|
||||
@ -13,7 +13,10 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/audio/audio_processing.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -22,9 +25,9 @@ namespace test {
|
||||
// Used to perform an audio processing simulation from wav files.
|
||||
class WavBasedSimulator final : public AudioProcessingSimulator {
|
||||
public:
|
||||
WavBasedSimulator(const SimulationSettings& settings,
|
||||
rtc::scoped_refptr<AudioProcessing> audio_processing,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder);
|
||||
WavBasedSimulator(
|
||||
const SimulationSettings& settings,
|
||||
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing);
|
||||
|
||||
WavBasedSimulator() = delete;
|
||||
WavBasedSimulator(const WavBasedSimulator&) = delete;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user