APM: Add ability to turn on/off dumping of internal data
This CL modifies the internal data logging and the audioproc_f tool to allow controlling that via the command line, rather than solely via a build flag. The logging of internal data is by default off. Bug: webrtc:5298 Change-Id: I96d1b4f990582938527b9039d6c2ecbb6f76e9ca Reviewed-on: https://webrtc-review.googlesource.com/c/107713 Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25352}
This commit is contained in:
@ -514,6 +514,7 @@ if (rtc_include_tests) {
|
|||||||
if (rtc_enable_protobuf) {
|
if (rtc_enable_protobuf) {
|
||||||
rtc_source_set("audioproc_f_impl") {
|
rtc_source_set("audioproc_f_impl") {
|
||||||
testonly = true
|
testonly = true
|
||||||
|
configs += [ ":apm_debug_dump" ]
|
||||||
sources = [
|
sources = [
|
||||||
"test/aec_dump_based_simulator.cc",
|
"test/aec_dump_based_simulator.cc",
|
||||||
"test/aec_dump_based_simulator.h",
|
"test/aec_dump_based_simulator.h",
|
||||||
@ -527,6 +528,7 @@ if (rtc_include_tests) {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":analog_mic_simulation",
|
":analog_mic_simulation",
|
||||||
|
":apm_logging",
|
||||||
":audio_processing",
|
":audio_processing",
|
||||||
":audioproc_debug_proto",
|
":audioproc_debug_proto",
|
||||||
":audioproc_protobuf_utils",
|
":audioproc_protobuf_utils",
|
||||||
|
@ -46,6 +46,8 @@ ApmDataDumper::ApmDataDumper(int instance_index) {}
|
|||||||
ApmDataDumper::~ApmDataDumper() {}
|
ApmDataDumper::~ApmDataDumper() {}
|
||||||
|
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
|
bool ApmDataDumper::recording_activated_ = false;
|
||||||
|
;
|
||||||
FILE* ApmDataDumper::GetRawFile(const char* name) {
|
FILE* ApmDataDumper::GetRawFile(const char* name) {
|
||||||
std::string filename =
|
std::string filename =
|
||||||
FormFileName(name, instance_index_, recording_set_index_, ".dat");
|
FormFileName(name, instance_index_, recording_set_index_, ".dat");
|
||||||
|
@ -50,6 +50,13 @@ class ApmDataDumper {
|
|||||||
|
|
||||||
~ApmDataDumper();
|
~ApmDataDumper();
|
||||||
|
|
||||||
|
// Activates or deactivate the dumping functionality.
|
||||||
|
static void SetActivated(bool activated) {
|
||||||
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
|
recording_activated_ = activated;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Reinitializes the data dumping such that new versions
|
// Reinitializes the data dumping such that new versions
|
||||||
// of all files being dumped to are created.
|
// of all files being dumped to are created.
|
||||||
void InitiateNewSetOfRecordings() {
|
void InitiateNewSetOfRecordings() {
|
||||||
@ -62,117 +69,151 @@ class ApmDataDumper {
|
|||||||
// various formats.
|
// various formats.
|
||||||
void DumpRaw(const char* name, double v) {
|
void DumpRaw(const char* name, double v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(&v, sizeof(v), 1, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(&v, sizeof(v), 1, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v_length, const double* v) {
|
void DumpRaw(const char* name, size_t v_length, const double* v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(v, sizeof(v[0]), v_length, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(v, sizeof(v[0]), v_length, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, rtc::ArrayView<const double> v) {
|
void DumpRaw(const char* name, rtc::ArrayView<const double> v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpRaw(name, v.size(), v.data());
|
if (recording_activated_) {
|
||||||
|
DumpRaw(name, v.size(), v.data());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, float v) {
|
void DumpRaw(const char* name, float v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(&v, sizeof(v), 1, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(&v, sizeof(v), 1, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v_length, const float* v) {
|
void DumpRaw(const char* name, size_t v_length, const float* v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(v, sizeof(v[0]), v_length, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(v, sizeof(v[0]), v_length, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, rtc::ArrayView<const float> v) {
|
void DumpRaw(const char* name, rtc::ArrayView<const float> v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpRaw(name, v.size(), v.data());
|
if (recording_activated_) {
|
||||||
|
DumpRaw(name, v.size(), v.data());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, bool v) {
|
void DumpRaw(const char* name, bool v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpRaw(name, static_cast<int16_t>(v));
|
if (recording_activated_) {
|
||||||
|
DumpRaw(name, static_cast<int16_t>(v));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v_length, const bool* v) {
|
void DumpRaw(const char* name, size_t v_length, const bool* v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
for (size_t k = 0; k < v_length; ++k) {
|
FILE* file = GetRawFile(name);
|
||||||
int16_t value = static_cast<int16_t>(v[k]);
|
for (size_t k = 0; k < v_length; ++k) {
|
||||||
fwrite(&value, sizeof(value), 1, file);
|
int16_t value = static_cast<int16_t>(v[k]);
|
||||||
|
fwrite(&value, sizeof(value), 1, file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, rtc::ArrayView<const bool> v) {
|
void DumpRaw(const char* name, rtc::ArrayView<const bool> v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpRaw(name, v.size(), v.data());
|
if (recording_activated_) {
|
||||||
|
DumpRaw(name, v.size(), v.data());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, int16_t v) {
|
void DumpRaw(const char* name, int16_t v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(&v, sizeof(v), 1, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(&v, sizeof(v), 1, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v_length, const int16_t* v) {
|
void DumpRaw(const char* name, size_t v_length, const int16_t* v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(v, sizeof(v[0]), v_length, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(v, sizeof(v[0]), v_length, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, rtc::ArrayView<const int16_t> v) {
|
void DumpRaw(const char* name, rtc::ArrayView<const int16_t> v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpRaw(name, v.size(), v.data());
|
if (recording_activated_) {
|
||||||
|
DumpRaw(name, v.size(), v.data());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, int32_t v) {
|
void DumpRaw(const char* name, int32_t v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(&v, sizeof(v), 1, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(&v, sizeof(v), 1, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v_length, const int32_t* v) {
|
void DumpRaw(const char* name, size_t v_length, const int32_t* v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(v, sizeof(v[0]), v_length, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(v, sizeof(v[0]), v_length, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v) {
|
void DumpRaw(const char* name, size_t v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(&v, sizeof(v), 1, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(&v, sizeof(v), 1, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, size_t v_length, const size_t* v) {
|
void DumpRaw(const char* name, size_t v_length, const size_t* v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
FILE* file = GetRawFile(name);
|
if (recording_activated_) {
|
||||||
fwrite(v, sizeof(v[0]), v_length, file);
|
FILE* file = GetRawFile(name);
|
||||||
|
fwrite(v, sizeof(v[0]), v_length, file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpRaw(const char* name, rtc::ArrayView<const int32_t> v) {
|
void DumpRaw(const char* name, rtc::ArrayView<const int32_t> v) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpRaw(name, v.size(), v.data());
|
if (recording_activated_) {
|
||||||
|
DumpRaw(name, v.size(), v.data());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,8 +223,10 @@ class ApmDataDumper {
|
|||||||
int sample_rate_hz,
|
int sample_rate_hz,
|
||||||
int num_channels) {
|
int num_channels) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels);
|
if (recording_activated_) {
|
||||||
file->WriteSamples(v, v_length);
|
WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels);
|
||||||
|
file->WriteSamples(v, v_length);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,12 +235,15 @@ class ApmDataDumper {
|
|||||||
int sample_rate_hz,
|
int sample_rate_hz,
|
||||||
int num_channels) {
|
int num_channels) {
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
DumpWav(name, v.size(), v.data(), sample_rate_hz, num_channels);
|
if (recording_activated_) {
|
||||||
|
DumpWav(name, v.size(), v.data(), sample_rate_hz, num_channels);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||||
|
static bool recording_activated_;
|
||||||
const int instance_index_;
|
const int instance_index_;
|
||||||
int recording_set_index_ = 0;
|
int recording_set_index_ = 0;
|
||||||
std::unordered_map<std::string, std::unique_ptr<FILE, RawFileCloseFunctor>>
|
std::unordered_map<std::string, std::unique_ptr<FILE, RawFileCloseFunctor>>
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "modules/audio_processing/echo_cancellation_impl.h"
|
#include "modules/audio_processing/echo_cancellation_impl.h"
|
||||||
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
||||||
#include "modules/audio_processing/include/audio_processing.h"
|
#include "modules/audio_processing/include/audio_processing.h"
|
||||||
|
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||||
#include "modules/audio_processing/test/fake_recording_device.h"
|
#include "modules/audio_processing/test/fake_recording_device.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
@ -114,6 +115,9 @@ AudioProcessingSimulator::AudioProcessingSimulator(
|
|||||||
settings.initial_mic_level,
|
settings.initial_mic_level,
|
||||||
settings_.simulate_mic_gain ? *settings.simulated_mic_kind : 0),
|
settings_.simulate_mic_gain ? *settings.simulated_mic_kind : 0),
|
||||||
worker_queue_("file_writer_task_queue") {
|
worker_queue_("file_writer_task_queue") {
|
||||||
|
RTC_CHECK(!settings_.dump_internal_data || WEBRTC_APM_DEBUG_DUMP == 1);
|
||||||
|
ApmDataDumper::SetActivated(settings_.dump_internal_data);
|
||||||
|
|
||||||
if (settings_.ed_graph_output_filename &&
|
if (settings_.ed_graph_output_filename &&
|
||||||
!settings_.ed_graph_output_filename->empty()) {
|
!settings_.ed_graph_output_filename->empty()) {
|
||||||
residual_echo_likelihood_graph_writer_.open(
|
residual_echo_likelihood_graph_writer_.open(
|
||||||
|
@ -92,6 +92,7 @@ struct SimulationSettings {
|
|||||||
bool fixed_interface = false;
|
bool fixed_interface = false;
|
||||||
bool store_intermediate_output = false;
|
bool store_intermediate_output = false;
|
||||||
bool print_aec3_parameter_values = false;
|
bool print_aec3_parameter_values = false;
|
||||||
|
bool dump_internal_data = false;
|
||||||
absl::optional<std::string> custom_call_order_filename;
|
absl::optional<std::string> custom_call_order_filename;
|
||||||
absl::optional<std::string> aec3_settings_filename;
|
absl::optional<std::string> aec3_settings_filename;
|
||||||
};
|
};
|
||||||
|
@ -200,6 +200,9 @@ WEBRTC_DEFINE_bool(print_aec3_parameter_values,
|
|||||||
WEBRTC_DEFINE_string(aec3_settings,
|
WEBRTC_DEFINE_string(aec3_settings,
|
||||||
"",
|
"",
|
||||||
"File in JSON-format with custom AEC3 settings");
|
"File in JSON-format with custom AEC3 settings");
|
||||||
|
WEBRTC_DEFINE_bool(dump_data,
|
||||||
|
false,
|
||||||
|
"Dump internal data during the call (requires build flag)");
|
||||||
WEBRTC_DEFINE_bool(help, false, "Print this message");
|
WEBRTC_DEFINE_bool(help, false, "Print this message");
|
||||||
|
|
||||||
void SetSettingIfSpecified(const std::string& value,
|
void SetSettingIfSpecified(const std::string& value,
|
||||||
@ -311,6 +314,7 @@ SimulationSettings CreateSettings() {
|
|||||||
settings.fixed_interface = FLAG_fixed_interface;
|
settings.fixed_interface = FLAG_fixed_interface;
|
||||||
settings.store_intermediate_output = FLAG_store_intermediate_output;
|
settings.store_intermediate_output = FLAG_store_intermediate_output;
|
||||||
settings.print_aec3_parameter_values = FLAG_print_aec3_parameter_values;
|
settings.print_aec3_parameter_values = FLAG_print_aec3_parameter_values;
|
||||||
|
settings.dump_internal_data = FLAG_dump_data;
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
@ -461,6 +465,10 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
|
|||||||
settings.artificial_nearend_filename &&
|
settings.artificial_nearend_filename &&
|
||||||
!valid_wav_name(*settings.artificial_nearend_filename),
|
!valid_wav_name(*settings.artificial_nearend_filename),
|
||||||
"Error: --artifical_nearend must be a valid .wav file name.\n");
|
"Error: --artifical_nearend must be a valid .wav file name.\n");
|
||||||
|
|
||||||
|
ReportConditionalErrorAndExit(
|
||||||
|
WEBRTC_APM_DEBUG_DUMP == 0 && settings.dump_internal_data,
|
||||||
|
"Error: --dump_data cannot be set without proper build support.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user