Change existing aec dump tests to use webrtc::AecDump.
Currently the debug dump functionality of WebRTC (a log of all
AudioProcessing operations) was tested by the following tests:
1. ApmTest.VerifyDebugDump* which configures and runs AudioProcessing
from a debug dump, and verifies that the same debug dump is
recorded.
2. DebugDumpTest.* which is a comprehensive test of the debug dump
operations. AudioProcessing configuration is changed, and the dump
is scanned for the change.
3. ApmTest::{DebugDump, DebugDumpFromFileHandle} that verify that
debug dumping can be started and files written.
This CL replaces the debug dump mechanism in all these tests to
webrtc::AecDump. Some of the tests are adapted to the chenges of the
new API to AecDump {Start,Stop}DebugRecording: the old functions
signal errors when a file cannot be opened. With AecDump, the
AecDumpFactory instead returns a nullptr.
The CL also changes audioproc_f to use AecDump.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2864373002
Cr-Commit-Position: refs/heads/master@{#18605}
This commit is contained in:
@ -595,6 +595,9 @@ if (rtc_include_tests) {
|
||||
":audioproc_debug_proto",
|
||||
":audioproc_protobuf_utils",
|
||||
":audioproc_unittest_proto",
|
||||
"../../base:rtc_task_queue",
|
||||
"aec_dump",
|
||||
"aec_dump:aec_dump_unittests",
|
||||
]
|
||||
sources += [
|
||||
"aec3/adaptive_fir_filter_unittest.cc",
|
||||
@ -745,10 +748,13 @@ if (rtc_include_tests) {
|
||||
":audioproc_test_utils",
|
||||
"../../base:protobuf_utils",
|
||||
"../../base:rtc_base_approved",
|
||||
"../../base:rtc_task_queue",
|
||||
"../../common_audio:common_audio",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:system_wrappers_default",
|
||||
"../../test:test_support",
|
||||
"aec_dump",
|
||||
"aec_dump:aec_dump_impl",
|
||||
"//testing/gtest",
|
||||
"//third_party/gflags:gflags",
|
||||
]
|
||||
|
||||
@ -22,10 +22,13 @@
|
||||
#include "webrtc/base/ignore_wundef.h"
|
||||
#include "webrtc/base/protobuf_utils.h"
|
||||
#include "webrtc/base/safe_minmax.h"
|
||||
#include "webrtc/base/task_queue.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/resampler/include/push_resampler.h"
|
||||
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h"
|
||||
#include "webrtc/modules/audio_processing/audio_processing_impl.h"
|
||||
#include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h"
|
||||
#include "webrtc/modules/audio_processing/common.h"
|
||||
@ -1709,6 +1712,7 @@ void ApmTest::ProcessDebugDump(const std::string& in_filename,
|
||||
const std::string& out_filename,
|
||||
Format format,
|
||||
int max_size_bytes) {
|
||||
rtc::TaskQueue worker_queue("ApmTest_worker_queue");
|
||||
FILE* in_file = fopen(in_filename.c_str(), "rb");
|
||||
ASSERT_TRUE(in_file != NULL);
|
||||
audioproc::Event event_msg;
|
||||
@ -1734,10 +1738,12 @@ void ApmTest::ProcessDebugDump(const std::string& in_filename,
|
||||
msg.num_reverse_channels(),
|
||||
false);
|
||||
if (first_init) {
|
||||
// StartDebugRecording() writes an additional init message. Don't start
|
||||
// AttachAecDump() writes an additional init message. Don't start
|
||||
// recording until after the first init to avoid the extra message.
|
||||
EXPECT_NOERR(
|
||||
apm_->StartDebugRecording(out_filename.c_str(), max_size_bytes));
|
||||
auto aec_dump =
|
||||
AecDumpFactory::Create(out_filename, max_size_bytes, &worker_queue);
|
||||
EXPECT_TRUE(aec_dump);
|
||||
apm_->AttachAecDump(std::move(aec_dump));
|
||||
first_init = false;
|
||||
}
|
||||
|
||||
@ -1794,7 +1800,7 @@ void ApmTest::ProcessDebugDump(const std::string& in_filename,
|
||||
ProcessStreamChooser(format);
|
||||
}
|
||||
}
|
||||
EXPECT_NOERR(apm_->StopDebugRecording());
|
||||
apm_->DetachAecDump();
|
||||
fclose(in_file);
|
||||
}
|
||||
|
||||
@ -1874,19 +1880,24 @@ TEST_F(ApmTest, VerifyDebugDumpFloat) {
|
||||
|
||||
// TODO(andrew): expand test to verify output.
|
||||
TEST_F(ApmTest, DebugDump) {
|
||||
rtc::TaskQueue worker_queue("ApmTest_worker_queue");
|
||||
const std::string filename =
|
||||
test::TempFilename(test::OutputPath(), "debug_aec");
|
||||
EXPECT_EQ(apm_->kNullPointerError,
|
||||
apm_->StartDebugRecording(static_cast<const char*>(NULL), -1));
|
||||
{
|
||||
auto aec_dump = AecDumpFactory::Create("", -1, &worker_queue);
|
||||
EXPECT_FALSE(aec_dump);
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
// Stopping without having started should be OK.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
apm_->DetachAecDump();
|
||||
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str(), -1));
|
||||
auto aec_dump = AecDumpFactory::Create(filename, -1, &worker_queue);
|
||||
EXPECT_TRUE(aec_dump);
|
||||
apm_->AttachAecDump(std::move(aec_dump));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
apm_->DetachAecDump();
|
||||
|
||||
// Verify the file has been written.
|
||||
FILE* fid = fopen(filename.c_str(), "r");
|
||||
@ -1896,10 +1907,6 @@ TEST_F(ApmTest, DebugDump) {
|
||||
ASSERT_EQ(0, fclose(fid));
|
||||
ASSERT_EQ(0, remove(filename.c_str()));
|
||||
#else
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError,
|
||||
apm_->StartDebugRecording(filename.c_str(), -1));
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError, apm_->StopDebugRecording());
|
||||
|
||||
// Verify the file has NOT been written.
|
||||
ASSERT_TRUE(fopen(filename.c_str(), "r") == NULL);
|
||||
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
@ -1907,21 +1914,23 @@ TEST_F(ApmTest, DebugDump) {
|
||||
|
||||
// TODO(andrew): expand test to verify output.
|
||||
TEST_F(ApmTest, DebugDumpFromFileHandle) {
|
||||
FILE* fid = NULL;
|
||||
EXPECT_EQ(apm_->kNullPointerError, apm_->StartDebugRecording(fid, -1));
|
||||
rtc::TaskQueue worker_queue("ApmTest_worker_queue");
|
||||
|
||||
const std::string filename =
|
||||
test::TempFilename(test::OutputPath(), "debug_aec");
|
||||
fid = fopen(filename.c_str(), "w");
|
||||
FILE* fid = fopen(filename.c_str(), "w");
|
||||
ASSERT_TRUE(fid);
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
// Stopping without having started should be OK.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
apm_->DetachAecDump();
|
||||
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid, -1));
|
||||
auto aec_dump = AecDumpFactory::Create(fid, -1, &worker_queue);
|
||||
EXPECT_TRUE(aec_dump);
|
||||
apm_->AttachAecDump(std::move(aec_dump));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
apm_->DetachAecDump();
|
||||
|
||||
// Verify the file has been written.
|
||||
fid = fopen(filename.c_str(), "r");
|
||||
@ -1931,10 +1940,6 @@ TEST_F(ApmTest, DebugDumpFromFileHandle) {
|
||||
ASSERT_EQ(0, fclose(fid));
|
||||
ASSERT_EQ(0, remove(filename.c_str()));
|
||||
#else
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError,
|
||||
apm_->StartDebugRecording(fid, -1));
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError, apm_->StopDebugRecording());
|
||||
|
||||
ASSERT_EQ(0, fclose(fid));
|
||||
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -79,7 +80,7 @@ void CopyToAudioFrame(const ChannelBuffer<float>& src, AudioFrame* dest) {
|
||||
|
||||
AudioProcessingSimulator::AudioProcessingSimulator(
|
||||
const SimulationSettings& settings)
|
||||
: settings_(settings) {
|
||||
: settings_(settings), worker_queue_("file_writer_task_queue") {
|
||||
if (settings_.ed_graph_output_filename &&
|
||||
settings_.ed_graph_output_filename->size() > 0) {
|
||||
residual_echo_likelihood_graph_writer_.open(
|
||||
@ -249,7 +250,7 @@ void AudioProcessingSimulator::SetupOutput() {
|
||||
|
||||
void AudioProcessingSimulator::DestroyAudioProcessor() {
|
||||
if (settings_.aec_dump_output_filename) {
|
||||
RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->StopDebugRecording());
|
||||
ap_->DetachAecDump();
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,11 +390,8 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
||||
}
|
||||
|
||||
if (settings_.aec_dump_output_filename) {
|
||||
size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize;
|
||||
RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize);
|
||||
RTC_CHECK_EQ(AudioProcessing::kNoError,
|
||||
ap_->StartDebugRecording(
|
||||
settings_.aec_dump_output_filename->c_str(), -1));
|
||||
ap_->AttachAecDump(AecDumpFactory::Create(
|
||||
*settings_.aec_dump_output_filename, -1, &worker_queue_));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,9 +17,10 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/base/task_queue.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/common_audio/channel_buffer.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/audio_processing/test/test_utils.h"
|
||||
@ -177,6 +178,8 @@ class AudioProcessingSimulator {
|
||||
TickIntervalStats proc_time_;
|
||||
std::ofstream residual_echo_likelihood_graph_writer_;
|
||||
|
||||
rtc::TaskQueue worker_queue_;
|
||||
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioProcessingSimulator);
|
||||
};
|
||||
|
||||
|
||||
@ -14,7 +14,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/task_queue.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h"
|
||||
#include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h"
|
||||
#include "webrtc/modules/audio_processing/test/debug_dump_replayer.h"
|
||||
#include "webrtc/modules/audio_processing/test/test_utils.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
@ -104,6 +106,7 @@ class DebugDumpGenerator {
|
||||
std::unique_ptr<ChannelBuffer<float>> reverse_;
|
||||
std::unique_ptr<ChannelBuffer<float>> output_;
|
||||
|
||||
rtc::TaskQueue worker_queue_;
|
||||
std::unique_ptr<AudioProcessing> apm_;
|
||||
|
||||
const std::string dump_file_name_;
|
||||
@ -130,9 +133,9 @@ DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name,
|
||||
reverse_config_.num_channels())),
|
||||
output_(new ChannelBuffer<float>(output_config_.num_frames(),
|
||||
output_config_.num_channels())),
|
||||
worker_queue_("debug_dump_generator_worker_queue"),
|
||||
apm_(AudioProcessing::Create(config)),
|
||||
dump_file_name_(dump_file_name) {
|
||||
}
|
||||
dump_file_name_(dump_file_name) {}
|
||||
|
||||
DebugDumpGenerator::DebugDumpGenerator(
|
||||
const Config& config,
|
||||
@ -187,7 +190,8 @@ void DebugDumpGenerator::SetOutputChannels(int channels) {
|
||||
}
|
||||
|
||||
void DebugDumpGenerator::StartRecording() {
|
||||
apm_->StartDebugRecording(dump_file_name_.c_str(), -1);
|
||||
apm_->AttachAecDump(
|
||||
AecDumpFactory::Create(dump_file_name_.c_str(), -1, &worker_queue_));
|
||||
}
|
||||
|
||||
void DebugDumpGenerator::Process(size_t num_blocks) {
|
||||
@ -211,7 +215,7 @@ void DebugDumpGenerator::Process(size_t num_blocks) {
|
||||
}
|
||||
|
||||
void DebugDumpGenerator::StopRecording() {
|
||||
apm_->StopDebugRecording();
|
||||
apm_->DetachAecDump();
|
||||
}
|
||||
|
||||
void DebugDumpGenerator::ReadAndDeinterleave(ResampleInputAudioFile* audio,
|
||||
|
||||
Reference in New Issue
Block a user