Chromium Code Reviews| Index: webrtc/modules/audio_processing/test/debug_dump_test.cc |
| diff --git a/webrtc/modules/audio_processing/test/debug_dump_test.cc b/webrtc/modules/audio_processing/test/debug_dump_test.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..710320170b8cd27859933b666f0d997770c3d709 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_processing/test/debug_dump_test.cc |
| @@ -0,0 +1,655 @@ |
| +/* |
| + * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "webrtc/modules/audio_processing/test/debug_dump_test.h" |
| + |
| +#include "webrtc/base/checks.h" |
| +#include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
| +#include "webrtc/modules/audio_processing/test/test_utils.h" |
| +#include "webrtc/test/testsupport/fileutils.h" |
| + |
| +namespace webrtc { |
| +namespace test { |
| + |
| +namespace { |
|
Andrew MacDonald
2015/10/20 01:22:08
Blank space after this line.
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + const std::string input_file_name = |
|
Andrew MacDonald
2015/10/20 01:22:08
No indent. Use git cl format.
These strings are n
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + test::ResourcePath("near32_stereo", "pcm"); |
| + const int kInputFileRateHz = 32000; |
| + const size_t kInputFileChannels = 2; |
| + const std::string reverse_file_name = |
| + test::ResourcePath("far32_stereo", "pcm"); |
| + const int kReverseFileRateHz = 32000; |
| + const size_t kReverseFileChannels = 2; |
| +} |
|
Andrew MacDonald
2015/10/20 01:22:08
Blank space before this line.
} // namespace
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + |
| +DebugDumpGenerator::DebugDumpGenerator(std::string input_file_name, |
| + int input_file_rate_hz, |
| + size_t input_channels, |
| + std::string reverse_file_name, |
| + int reverse_file_rate_hz, |
| + size_t reverse_channels, |
| + const Config& config, |
| + std::string dump_file_name) |
| + : input_rate_hz_(input_file_rate_hz), |
| + input_mono_(false), |
| + reverse_rate_hz_(reverse_file_rate_hz), |
| + reverse_mono_(false), |
| + output_rate_hz_(input_file_rate_hz), |
| + output_channels_(input_channels), |
| + input_audio_(new ResampleInputAudioFile(input_file_name, |
| + input_file_rate_hz, |
| + input_rate_hz_)), |
| + input_channels_(input_channels), |
| + reverse_audio_(new ResampleInputAudioFile(reverse_file_name, |
| + reverse_file_rate_hz, |
| + reverse_rate_hz_)), |
| + reverse_channels_(reverse_channels), |
| + // Buffers will be created upon usage. |
|
Andrew MacDonald
2015/10/20 01:22:08
You could trigger the same InitializeFormat or wha
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
|
| + input_(nullptr), |
| + reverse_(nullptr), |
| + output_(nullptr), |
| + apm_(AudioProcessing::Create(config)), |
| + dump_file_name_(dump_file_name) { |
| +} |
| + |
| +void DebugDumpGenerator::SetInputRate(int rate_hz) { |
| + RTC_DCHECK(input_audio_.get()); |
|
Andrew MacDonald
2015/10/20 01:22:08
This is created in the constructor, so no need for
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
|
| + input_rate_hz_ = rate_hz; |
| + input_audio_->set_output_rate_hz(input_rate_hz_); |
| +} |
| + |
| +void DebugDumpGenerator::ForceInputMono(bool mono) { |
| + input_mono_ = mono; |
| + if (input_mono_) { |
| + // Output channels is set since it should be no bigger than input channels. |
| + output_channels_ = 1; |
|
Andrew MacDonald
2015/10/20 01:22:08
What if ForceInputMono(false) is called?
minyue-webrtc
2015/10/23 08:44:45
yes agreed. I think it is better not to change the
|
| + } |
| +} |
| + |
| +void DebugDumpGenerator::SetReverseRate(int rate_hz) { |
| + RTC_DCHECK(reverse_audio_.get()); |
|
Andrew MacDonald
2015/10/20 01:22:08
Not needed.
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
|
| + reverse_rate_hz_ = rate_hz; |
| + reverse_audio_->set_output_rate_hz(reverse_rate_hz_); |
| +} |
| + |
| +void DebugDumpGenerator::ForceReverseMono(bool mono) { |
| + reverse_mono_ = mono; |
| +} |
| + |
| +void DebugDumpGenerator::StartRecording() { |
| + RTC_DCHECK(apm_.get()); |
|
Andrew MacDonald
2015/10/20 01:22:08
Not needed.
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
|
| + apm_->StartDebugRecording(dump_file_name_.c_str()); |
| +} |
| + |
| +void DebugDumpGenerator::Process(size_t num_blocks) { |
| + RTC_DCHECK(apm_.get()); |
|
Andrew MacDonald
2015/10/20 01:22:08
Not needed.
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
|
| + |
| + const size_t apm_input_channels = input_mono_ ? 1 : input_channels_; |
| + const size_t apm_rev_channels = reverse_mono_ ? 1 : reverse_channels_; |
| + const size_t apm_input_frames = rtc::CheckedDivExact( |
| + AudioProcessing::kChunkSizeMs * input_rate_hz_, 1000); |
| + const size_t apm_rev_frames = rtc::CheckedDivExact( |
| + AudioProcessing::kChunkSizeMs * reverse_rate_hz_, 1000); |
| + |
| + // The following enlarges buffers when necessary. |
| + if (!input_.get() || input_->num_frames() < apm_input_frames || |
|
Andrew MacDonald
2015/10/20 01:22:08
Since this is a test, we don't care about performa
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + input_->num_channels() < static_cast<int>(apm_input_channels)) { |
| + input_.reset( |
| + new ChannelBuffer<float>(apm_input_frames, apm_input_channels)); |
| + } |
| + |
| + if (!reverse_.get() || reverse_->num_frames() < apm_rev_frames || |
| + reverse_->num_channels() < static_cast<int>(apm_rev_channels)) { |
| + reverse_.reset( |
| + new ChannelBuffer<float>(apm_rev_frames, apm_rev_channels)); |
| + } |
| + |
| + // The following effectively calculates |
| + // ceil(apm_input_frames * output_rate_hz_ / input_rate_hz_). |
| + const size_t apm_output_frames = (apm_input_frames * output_rate_hz_ + |
| + input_rate_hz_ - 1) / input_rate_hz_; |
| + |
| + if (!output_.get() || output_->num_frames() < apm_output_frames || |
| + output_->num_channels() < static_cast<int>(output_channels_)) { |
| + output_.reset( |
| + new ChannelBuffer<float>(apm_output_frames, output_channels_)); |
| + } |
| + |
| + for (size_t i = 0; i < num_blocks; ++i) { |
| + ReadAndDeinterleave(reverse_audio_.get(), reverse_channels_, apm_rev_frames, |
| + reverse_mono_, reverse_->channels()); |
| + ReadAndDeinterleave(input_audio_.get(), input_channels_, apm_input_frames, |
| + input_mono_, input_->channels()); |
| + |
| + // Set a varying stream delay. |
| + RTC_CHECK_EQ(AudioProcessing::kNoError, |
| + apm_->set_stream_delay_ms(100 + i % 10)); |
| + |
| + // A key press event is added every 10th block. |
| + apm_->set_stream_key_pressed(i % 10 == 9); |
| + |
| + RTC_CHECK_EQ(AudioProcessing::kNoError, |
| + apm_->ProcessStream(input_->channels(), |
| + apm_input_frames, |
| + input_rate_hz_, |
| + LayoutFromChannels(apm_input_channels), |
| + output_rate_hz_, |
| + LayoutFromChannels(output_channels_), |
| + output_->channels())); |
| + RTC_CHECK_EQ( |
| + AudioProcessing::kNoError, |
| + apm_->AnalyzeReverseStream(reverse_->channels(), |
| + apm_rev_frames, |
| + reverse_rate_hz_, |
| + LayoutFromChannels(apm_rev_channels))); |
| + } |
| +} |
| + |
| +void DebugDumpGenerator::StopRecording() { |
| + apm_->StopDebugRecording(); |
| +} |
| + |
| +void DebugDumpGenerator::ReadAndDeinterleave( |
| + ResampleInputAudioFile* audio, size_t channels, |
| + size_t frames_per_channel, bool force_mono, float* const* buffer) { |
| + // Make sure the buffer for reading the file is large enough. |
| + if (channels * frames_per_channel > signal_.size()) { |
| + signal_.resize(frames_per_channel * channels); |
| + } |
| + |
| + audio->Read(frames_per_channel * channels, &signal_[0]); |
| + |
| + const size_t out_channels = force_mono ? 1 : channels; |
| + for (size_t channel = 0; channel < out_channels; ++channel) { |
| + for (size_t i = 0; i < frames_per_channel; ++i) { |
| + buffer[channel][i] = S16ToFloat(signal_[i * channels + channel]); |
| + } |
| + } |
| +} |
| + |
| +#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
|
Andrew MacDonald
2015/10/20 01:22:08
This file should only be built when this is define
minyue-webrtc
2015/10/23 08:44:45
Ironically, the DebugDumpGenerator can still work,
Andrew MacDonald
2015/10/24 00:42:05
But this file is only compiled when enable_protobu
minyue-webrtc
2015/10/26 12:40:31
Now removed
|
| + |
| +DebugDumpTest::DebugDumpTest() |
| + : input_rate_hz_(-1), |
| + input_channels_(0), |
| + output_rate_hz_(-1), |
| + output_channels_(0), |
| + reverse_rate_hz_(-1), |
| + reverse_channels_(0), |
| + // Buffers will be created upon usage. |
| + input_(nullptr), |
| + reverse_(nullptr), |
| + output_(nullptr), |
| + // APM will be created upon usage. |
| + apm_(nullptr) { |
| +} |
| + |
| +void DebugDumpTest::VerifyDebugDump(const std::string in_filename) { |
|
Andrew MacDonald
2015/10/20 01:22:08
const std::string&
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + FILE* in_file = fopen(in_filename.c_str(), "rb"); |
| + ASSERT_TRUE(in_file != NULL); |
|
Andrew MacDonald
2015/10/20 01:22:08
nullptr
minyue-webrtc
2015/10/23 08:44:45
maybe better to remove !=NULL at all
|
| + audioproc::Event event_msg; |
| + |
| + while (ReadMessageFromFile(in_file, &event_msg)) { |
| + switch (event_msg.type()) { |
| + case audioproc::Event::INIT: |
| + OnInitEvent(event_msg.init()); |
| + break; |
| + case audioproc::Event::STREAM: |
| + OnStreamEvent(event_msg.stream()); |
| + break; |
| + case audioproc::Event::REVERSE_STREAM: |
| + OnReverseStreamEvent(event_msg.reverse_stream()); |
| + break; |
| + case audioproc::Event::CONFIG: |
| + OnConfigEvent(event_msg.config()); |
| + break; |
| + case audioproc::Event::UNKNOWN_EVENT: |
| + // We do not expect receive UNKNOWN event currently. |
| + ASSERT_TRUE(false); |
| + } |
| + } |
| + fclose(in_file); |
| +} |
| + |
| +// OnInitEvent reset the input/output/reserve channel format. |
| +void DebugDumpTest::OnInitEvent(const audioproc::Init& msg) { |
| + input_rate_hz_ = msg.sample_rate(); |
| + |
| + ASSERT_TRUE(msg.has_num_input_channels()); |
| + input_channels_ = msg.num_input_channels(); |
| + |
| + ASSERT_TRUE(msg.has_output_sample_rate()); |
| + output_rate_hz_ = msg.output_sample_rate(); |
| + |
| + ASSERT_TRUE(msg.has_num_output_channels()); |
| + output_channels_ = msg.num_output_channels(); |
| + |
| + ASSERT_TRUE(msg.has_reverse_sample_rate()); |
| + reverse_rate_hz_ = msg.reverse_sample_rate(); |
| + |
| + ASSERT_TRUE(msg.has_num_reverse_channels()); |
| + reverse_channels_ = msg.num_reverse_channels(); |
| +} |
| + |
| +// OnStreamEvent replays an input signal and verifies the output. |
| +void DebugDumpTest::OnStreamEvent(const audioproc::Stream& msg) { |
| + // APM should have been created. |
| + ASSERT_TRUE(apm_.get()); |
| + |
| + EXPECT_NOERR(apm_->gain_control()->set_stream_analog_level(msg.level())); |
| + EXPECT_NOERR(apm_->set_stream_delay_ms(msg.delay())); |
| + apm_->echo_cancellation()->set_stream_drift_samples(msg.drift()); |
| + if (msg.has_keypress()) |
| + apm_->set_stream_key_pressed(msg.keypress()); |
| + else |
| + apm_->set_stream_key_pressed(true); |
| + |
| + ASSERT_EQ(static_cast<int>(input_channels_), msg.input_channel_size()); |
| + |
| + const size_t frames_per_input_channel = |
| + rtc::CheckedDivExact(msg.input_channel(0).size(), sizeof(float)); |
| + |
| + // The following effectively calculates |
| + // ceil(frames_per_input_channel * output_rate_hz_ / input_rate_hz_). |
| + const size_t frames_per_output_channel = (frames_per_input_channel * |
| + output_rate_hz_ + input_rate_hz_ - 1) / input_rate_hz_; |
| + |
| + // Updates the buffers to make sure that the sizes are large enough. |
| + if (!input_.get() || input_->num_frames() < frames_per_input_channel || |
|
Andrew MacDonald
2015/10/20 01:22:08
An init event has to occur for these values to cha
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + input_->num_channels() < static_cast<int>(input_channels_)) { |
| + input_.reset( |
| + new ChannelBuffer<float>(frames_per_input_channel, input_channels_)); |
| + } |
| + |
| + if (!output_.get() || output_->num_frames() < frames_per_output_channel || |
| + output_->num_channels() < static_cast<int>(output_channels_)) { |
| + output_.reset( |
| + new ChannelBuffer<float>(frames_per_output_channel, output_channels_)); |
| + } |
| + |
| + for (int i = 0; i < msg.input_channel_size(); ++i) { |
| + memcpy(input_->channels()[i], msg.input_channel(i).data(), |
| + msg.input_channel(i).size()); |
| + } |
| + ASSERT_EQ(AudioProcessing::kNoError, |
| + apm_->ProcessStream(input_->channels(), |
|
Andrew MacDonald
2015/10/20 01:22:08
Can you use the ProcessStream overload with Stream
minyue-webrtc
2015/10/23 08:44:45
ok
|
| + frames_per_input_channel, |
| + input_rate_hz_, |
| + LayoutFromChannels(input_channels_), |
| + output_rate_hz_, |
| + LayoutFromChannels(output_channels_), |
| + output_->channels())); |
| + |
| + // Check that output of APM is bit exact identical to the output in the dump. |
|
Andrew MacDonald
2015/10/20 01:22:08
s/bit exact identical/bit-exact
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + ASSERT_EQ(static_cast<int>(output_channels_), msg.output_channel_size()); |
| + ASSERT_EQ(msg.output_channel(0).size(), |
| + frames_per_output_channel * sizeof(float)); |
| + for (int i = 0; i < msg.output_channel_size(); ++i) { |
| + ASSERT_EQ(0, memcmp(output_->channels()[i], msg.output_channel(i).data(), |
| + msg.output_channel(i).size())); |
| + } |
| +} |
| + |
| +void DebugDumpTest::OnReverseStreamEvent(const audioproc::ReverseStream& msg) { |
| + // APM should have been created. |
| + ASSERT_TRUE(apm_.get()); |
| + |
| + ASSERT_GT(msg.channel_size(), 0); |
| + ASSERT_EQ(static_cast<int>(reverse_channels_), msg.channel_size()); |
| + |
| + const size_t frames_per_channel = |
| + rtc::CheckedDivExact(msg.channel(0).size(), sizeof(float)); |
| + if (!reverse_.get() || reverse_->num_frames() < frames_per_channel || |
|
Andrew MacDonald
2015/10/20 01:22:08
Same thing: recreate this directly upon init event
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + reverse_->num_channels() < static_cast<int>(reverse_channels_)) { |
| + reverse_.reset( |
| + new ChannelBuffer<float>(frames_per_channel, reverse_channels_)); |
| + } |
| + |
| + for (int i = 0; i < msg.channel_size(); ++i) { |
| + memcpy(reverse_->channels()[i], msg.channel(i).data(), |
| + msg.channel(i).size()); |
| + } |
| + |
| + ASSERT_EQ(AudioProcessing::kNoError, |
| + apm_->AnalyzeReverseStream( |
|
Andrew MacDonald
2015/10/20 01:22:08
Can you use ProcessReverseStream instead? This is
minyue-webrtc
2015/10/23 08:44:45
ok
|
| + reverse_->channels(), |
| + frames_per_channel, |
| + reverse_rate_hz_, |
| + LayoutFromChannels(reverse_channels_))); |
| +} |
| + |
| +void DebugDumpTest::OnConfigEvent(const audioproc::Config& msg) { |
| + MaybeRecreateApm(msg); |
| + ConfigurateApm(msg); |
| +} |
| + |
| +void DebugDumpTest::MaybeRecreateApm(const audioproc::Config& msg) { |
| + if (apm_.get()) { |
| + // We only create APM once, since changes on these fields should not |
| + // happen in current implementation. |
| + return; |
| + } |
| + |
| + Config config; |
| + ASSERT_TRUE(msg.has_aec_delay_agnostic_enabled()); |
| + config.Set<DelayAgnostic>( |
| + new DelayAgnostic(msg.aec_delay_agnostic_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_noise_robust_agc_enabled()); |
| + config.Set<ExperimentalAgc>( |
| + new ExperimentalAgc(msg.noise_robust_agc_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_transient_suppression_enabled()); |
| + config.Set<ExperimentalNs>( |
| + new ExperimentalNs(msg.transient_suppression_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_aec_extended_filter_enabled()); |
| + config.Set<ExtendedFilter>(new ExtendedFilter( |
| + msg.aec_extended_filter_enabled())); |
| + |
| + apm_.reset(AudioProcessing::Create(config)); |
| +} |
| + |
| +void DebugDumpTest::ConfigurateApm(const audioproc::Config& msg) { |
|
Andrew MacDonald
2015/10/20 01:22:08
ConfigureApm
minyue-webrtc
2015/10/23 08:44:45
Done.
|
| + // AEC configs. |
| + ASSERT_TRUE(msg.has_aec_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->echo_cancellation()->Enable(msg.aec_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_aec_drift_compensation_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->echo_cancellation()->enable_drift_compensation( |
| + msg.aec_drift_compensation_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_aec_suppression_level()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->echo_cancellation()->set_suppression_level( |
| + static_cast<webrtc::EchoCancellation::SuppressionLevel>( |
| + msg.aec_suppression_level()))); |
| + |
| + // AECM configs. |
| + ASSERT_TRUE(msg.has_aecm_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->echo_control_mobile()->Enable(msg.aecm_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_aecm_comfort_noise_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->echo_control_mobile()->enable_comfort_noise( |
| + msg.aecm_comfort_noise_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_aecm_routing_mode()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->echo_control_mobile()->set_routing_mode( |
| + static_cast<webrtc::EchoControlMobile::RoutingMode>( |
| + msg.aecm_routing_mode()))); |
| + |
| + // AGC configs. |
| + ASSERT_TRUE(msg.has_agc_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->gain_control()->Enable(msg.agc_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_agc_mode()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->gain_control()->set_mode( |
| + static_cast<webrtc::GainControl::Mode>(msg.agc_mode()))); |
| + |
| + ASSERT_TRUE(msg.has_agc_limiter_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->gain_control()->enable_limiter(msg.agc_limiter_enabled())); |
| + |
| + // HPF configs. |
| + ASSERT_TRUE(msg.has_hpf_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->high_pass_filter()->Enable(msg.hpf_enabled())); |
| + |
| + // NS configs. |
| + ASSERT_TRUE(msg.has_ns_enabled()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->noise_suppression()->Enable(msg.ns_enabled())); |
| + |
| + ASSERT_TRUE(msg.has_ns_level()); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + apm_->noise_suppression()->set_level( |
| + static_cast<webrtc::NoiseSuppression::Level>(msg.ns_level()))); |
| +} |
| + |
| +#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
| + |
| +TEST_F(DebugDumpTest, SimpleCase) { |
| + Config config; |
|
Andrew MacDonald
2015/10/20 01:22:08
It looks like you never do anything with config in
minyue-webrtc
2015/10/23 08:44:45
There are tests with config modified. see Line 536
Andrew MacDonald
2015/10/24 00:42:05
Ah, OK.
|
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
|
Andrew MacDonald
2015/10/20 01:22:08
You use the same name in every test. I'd make dump
minyue-webrtc
2015/10/23 08:44:45
I made dump_file_name_ a member in the generator c
|
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ChangeInputFormat) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + generator.SetInputRate(48000); |
| + generator.ForceInputMono(true); |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ChangeReverseFormat) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + generator.SetReverseRate(48000); |
| + generator.ForceReverseMono(true); |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ChangeOutputFormat) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + generator.set_output_rate_hz(48000); |
| + generator.set_output_channels(1); |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ToggleAec) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + |
| + EchoCancellation* aec = generator.apm()->echo_cancellation(); |
| + EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled())); |
| + |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ToggleDelayAgnosticAec) { |
| + Config config; |
| + config.Set<DelayAgnostic>(new DelayAgnostic(true)); |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + |
| + EchoCancellation* aec = generator.apm()->echo_cancellation(); |
| + EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled())); |
| + |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ToggleAecLevel) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + EchoCancellation* aec = generator.apm()->echo_cancellation(); |
| + EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(true)); |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + aec->set_suppression_level(EchoCancellation::kLowSuppression)); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + |
| + EXPECT_EQ(AudioProcessing::kNoError, |
| + aec->set_suppression_level(EchoCancellation::kHighSuppression)); |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ToggleAgc) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + |
| + GainControl* agc = generator.apm()->gain_control(); |
| + EXPECT_EQ(AudioProcessing::kNoError, agc->Enable(!agc->is_enabled())); |
| + |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, ToggleNs) { |
| + Config config; |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + |
| + NoiseSuppression* ns = generator.apm()->noise_suppression(); |
| + EXPECT_EQ(AudioProcessing::kNoError, ns->Enable(!ns->is_enabled())); |
| + |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +TEST_F(DebugDumpTest, TransientSuppressionOn) { |
| + Config config; |
| + config.Set<ExperimentalNs>(new ExperimentalNs(true)); |
| + const std::string dump_file_name = |
| + test::TempFilename(test::OutputPath(), "debug_aec"); |
| + DebugDumpGenerator generator(input_file_name, |
| + kInputFileRateHz, |
| + kInputFileChannels, |
| + reverse_file_name, |
| + kReverseFileRateHz, |
| + kReverseFileChannels, |
| + config, |
| + dump_file_name); |
| + generator.StartRecording(); |
| + generator.Process(100); |
| + generator.StopRecording(); |
| + VerifyDebugDump(dump_file_name); |
| + remove(dump_file_name.c_str()); |
| +} |
| + |
| +} // namespace test |
| +} // namespace webrtc |