Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: webrtc/modules/audio_processing/test/debug_dump_test.cc

Issue 2864373002: Change existing aec dump tests to use webrtc::AecDump. (Closed)
Patch Set: Mini-change, forgot about DCHECK. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_processing/test/audio_processing_simulator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <stddef.h> // size_t 11 #include <stddef.h> // size_t
12 12
13 #include <memory> 13 #include <memory>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/task_queue.h"
17 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" 18 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h"
19 #include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h"
18 #include "webrtc/modules/audio_processing/test/debug_dump_replayer.h" 20 #include "webrtc/modules/audio_processing/test/debug_dump_replayer.h"
19 #include "webrtc/modules/audio_processing/test/test_utils.h" 21 #include "webrtc/modules/audio_processing/test/test_utils.h"
20 #include "webrtc/test/gtest.h" 22 #include "webrtc/test/gtest.h"
21 #include "webrtc/test/testsupport/fileutils.h" 23 #include "webrtc/test/testsupport/fileutils.h"
22 24
23 25
24 namespace webrtc { 26 namespace webrtc {
25 namespace test { 27 namespace test {
26 28
27 namespace { 29 namespace {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // Reverse file format. 99 // Reverse file format.
98 const std::string reverse_file_name_; 100 const std::string reverse_file_name_;
99 ResampleInputAudioFile reverse_audio_; 101 ResampleInputAudioFile reverse_audio_;
100 const int reverse_file_channels_; 102 const int reverse_file_channels_;
101 103
102 // Buffer for APM input/output. 104 // Buffer for APM input/output.
103 std::unique_ptr<ChannelBuffer<float>> input_; 105 std::unique_ptr<ChannelBuffer<float>> input_;
104 std::unique_ptr<ChannelBuffer<float>> reverse_; 106 std::unique_ptr<ChannelBuffer<float>> reverse_;
105 std::unique_ptr<ChannelBuffer<float>> output_; 107 std::unique_ptr<ChannelBuffer<float>> output_;
106 108
109 rtc::TaskQueue worker_queue_;
107 std::unique_ptr<AudioProcessing> apm_; 110 std::unique_ptr<AudioProcessing> apm_;
108 111
109 const std::string dump_file_name_; 112 const std::string dump_file_name_;
110 }; 113 };
111 114
112 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, 115 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name,
113 int input_rate_hz, 116 int input_rate_hz,
114 int input_channels, 117 int input_channels,
115 const std::string& reverse_file_name, 118 const std::string& reverse_file_name,
116 int reverse_rate_hz, 119 int reverse_rate_hz,
117 int reverse_channels, 120 int reverse_channels,
118 const Config& config, 121 const Config& config,
119 const std::string& dump_file_name) 122 const std::string& dump_file_name)
120 : input_config_(input_rate_hz, input_channels), 123 : input_config_(input_rate_hz, input_channels),
121 reverse_config_(reverse_rate_hz, reverse_channels), 124 reverse_config_(reverse_rate_hz, reverse_channels),
122 output_config_(input_rate_hz, input_channels), 125 output_config_(input_rate_hz, input_channels),
123 input_audio_(input_file_name, input_rate_hz, input_rate_hz), 126 input_audio_(input_file_name, input_rate_hz, input_rate_hz),
124 input_file_channels_(input_channels), 127 input_file_channels_(input_channels),
125 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz), 128 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz),
126 reverse_file_channels_(reverse_channels), 129 reverse_file_channels_(reverse_channels),
127 input_(new ChannelBuffer<float>(input_config_.num_frames(), 130 input_(new ChannelBuffer<float>(input_config_.num_frames(),
128 input_config_.num_channels())), 131 input_config_.num_channels())),
129 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(), 132 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(),
130 reverse_config_.num_channels())), 133 reverse_config_.num_channels())),
131 output_(new ChannelBuffer<float>(output_config_.num_frames(), 134 output_(new ChannelBuffer<float>(output_config_.num_frames(),
132 output_config_.num_channels())), 135 output_config_.num_channels())),
136 worker_queue_("debug_dump_generator_worker_queue"),
133 apm_(AudioProcessing::Create(config)), 137 apm_(AudioProcessing::Create(config)),
134 dump_file_name_(dump_file_name) { 138 dump_file_name_(dump_file_name) {}
135 }
136 139
137 DebugDumpGenerator::DebugDumpGenerator( 140 DebugDumpGenerator::DebugDumpGenerator(
138 const Config& config, 141 const Config& config,
139 const AudioProcessing::Config& apm_config) 142 const AudioProcessing::Config& apm_config)
140 : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"), 143 : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"),
141 32000, 144 32000,
142 2, 145 2,
143 ResourcePath("far32_stereo", "pcm"), 146 ResourcePath("far32_stereo", "pcm"),
144 32000, 147 32000,
145 2, 148 2,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 output_config_.set_sample_rate_hz(rate_hz); 183 output_config_.set_sample_rate_hz(rate_hz);
181 MaybeResetBuffer(&output_, output_config_); 184 MaybeResetBuffer(&output_, output_config_);
182 } 185 }
183 186
184 void DebugDumpGenerator::SetOutputChannels(int channels) { 187 void DebugDumpGenerator::SetOutputChannels(int channels) {
185 output_config_.set_num_channels(channels); 188 output_config_.set_num_channels(channels);
186 MaybeResetBuffer(&output_, output_config_); 189 MaybeResetBuffer(&output_, output_config_);
187 } 190 }
188 191
189 void DebugDumpGenerator::StartRecording() { 192 void DebugDumpGenerator::StartRecording() {
190 apm_->StartDebugRecording(dump_file_name_.c_str(), -1); 193 apm_->AttachAecDump(
194 AecDumpFactory::Create(dump_file_name_.c_str(), -1, &worker_queue_));
191 } 195 }
192 196
193 void DebugDumpGenerator::Process(size_t num_blocks) { 197 void DebugDumpGenerator::Process(size_t num_blocks) {
194 for (size_t i = 0; i < num_blocks; ++i) { 198 for (size_t i = 0; i < num_blocks; ++i) {
195 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_, 199 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_,
196 reverse_config_, reverse_->channels()); 200 reverse_config_, reverse_->channels());
197 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_, 201 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_,
198 input_->channels()); 202 input_->channels());
199 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100)); 203 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100));
200 apm_->set_stream_key_pressed(i % 10 == 9); 204 apm_->set_stream_key_pressed(i % 10 == 9);
201 RTC_CHECK_EQ(AudioProcessing::kNoError, 205 RTC_CHECK_EQ(AudioProcessing::kNoError,
202 apm_->ProcessStream(input_->channels(), input_config_, 206 apm_->ProcessStream(input_->channels(), input_config_,
203 output_config_, output_->channels())); 207 output_config_, output_->channels()));
204 208
205 RTC_CHECK_EQ(AudioProcessing::kNoError, 209 RTC_CHECK_EQ(AudioProcessing::kNoError,
206 apm_->ProcessReverseStream(reverse_->channels(), 210 apm_->ProcessReverseStream(reverse_->channels(),
207 reverse_config_, 211 reverse_config_,
208 reverse_config_, 212 reverse_config_,
209 reverse_->channels())); 213 reverse_->channels()));
210 } 214 }
211 } 215 }
212 216
213 void DebugDumpGenerator::StopRecording() { 217 void DebugDumpGenerator::StopRecording() {
214 apm_->StopDebugRecording(); 218 apm_->DetachAecDump();
215 } 219 }
216 220
217 void DebugDumpGenerator::ReadAndDeinterleave(ResampleInputAudioFile* audio, 221 void DebugDumpGenerator::ReadAndDeinterleave(ResampleInputAudioFile* audio,
218 int channels, 222 int channels,
219 const StreamConfig& config, 223 const StreamConfig& config,
220 float* const* buffer) { 224 float* const* buffer) {
221 const size_t num_frames = config.num_frames(); 225 const size_t num_frames = config.num_frames();
222 const int out_channels = config.num_channels(); 226 const int out_channels = config.num_channels();
223 227
224 std::vector<int16_t> signal(channels * num_frames); 228 std::vector<int16_t> signal(channels * num_frames);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 config.Set<ExperimentalNs>(new ExperimentalNs(true)); 592 config.Set<ExperimentalNs>(new ExperimentalNs(true));
589 DebugDumpGenerator generator(config, AudioProcessing::Config()); 593 DebugDumpGenerator generator(config, AudioProcessing::Config());
590 generator.StartRecording(); 594 generator.StartRecording();
591 generator.Process(100); 595 generator.Process(100);
592 generator.StopRecording(); 596 generator.StopRecording();
593 VerifyDebugDump(generator.dump_file_name()); 597 VerifyDebugDump(generator.dump_file_name());
594 } 598 }
595 599
596 } // namespace test 600 } // namespace test
597 } // namespace webrtc 601 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/audio_processing_simulator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698