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

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

Issue 1393353003: Adding debug dump tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: after Andrew's review Created 5 years, 1 month 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 | « no previous file | webrtc/modules/modules.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <stddef.h> // size_t
Andrew MacDonald 2015/10/24 00:42:06 nit: I prefer cstddef, but up to you.
minyue-webrtc 2015/10/26 12:40:31 I don't actually know the pros and cons. here I fo
12 #include <string>
13 #include <vector>
14
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/common_audio/channel_buffer.h"
19 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h"
20 #include "webrtc/modules/audio_processing/include/audio_processing.h"
21 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
22 #include "webrtc/modules/audio_processing/test/test_utils.h"
23 #include "webrtc/test/testsupport/fileutils.h"
24
25 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
26 #include "webrtc/audio_processing/debug.pb.h"
27 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
28
29 namespace webrtc {
30 namespace test {
31
32 namespace {
33
34 static void MaybeResetBuffer(rtc::scoped_ptr<ChannelBuffer<float>>& buffer,
Andrew MacDonald 2015/10/24 00:42:05 Remove static. The unnamed namespace gives it inte
minyue-webrtc 2015/10/26 12:40:31 Thanks! I actually wanted to consult you about thi
Andrew MacDonald 2015/10/30 01:56:08 Yes, you can dereference the scoped_ptr<T>*: void
minyue-webrtc 2015/10/30 11:07:07 Cool! It works!
35 const StreamConfig& config) {
36 if (!buffer.get() || buffer->num_frames() != config.num_frames() ||
37 buffer->num_channels() != config.num_channels()) {
38 buffer.reset(new ChannelBuffer<float>(config.num_frames(),
39 config.num_channels()));
40 }
41 }
42
43 } // namespace
44
45 class DebugDumpGenerator {
46 public:
47 DebugDumpGenerator(std::string input_file_name,
Andrew MacDonald 2015/10/24 00:42:06 const std::string& and below.
minyue-webrtc 2015/10/26 12:40:31 Done.
48 int input_file_rate_hz,
49 int input_channels,
50 std::string reverse_file_name,
51 int reverse_file_rate_hz,
52 int reverse_channels,
53 const Config& config,
54 std::string dump_file_name);
55
56 // Constructor that uses default input files.
57 explicit DebugDumpGenerator(const Config& config);
58
59 ~DebugDumpGenerator();
60
61 // Changes the sample rate of the input audio to the APM.
62 void SetInputRate(int rate_hz);
63
64 // Sets if converts stereo input signal to mono by discarding other channels.
65 void ForceInputMono(bool mono);
66
67 // Changes the sample rate of the reverse audio to the APM.
68 void SetReverseRate(int rate_hz);
69
70 // Sets if converts stereo reverse signal to mono by discarding other
71 // channels.
72 void ForceReverseMono(bool mono);
73
74 // Sets the required sample rate of the APM output.
75 void SetOutputRate(int rate_hz);
76
77 // Sets the required channels of the APM output.
78 void SetOutputChannels(int channels);
79
80 std::string dump_file_name() const { return dump_file_name_; }
81
82 void StartRecording();
83 void Process(size_t num_blocks);
84 void StopRecording();
85 AudioProcessing* apm() const { return apm_.get(); }
86
87 private:
88 void ReadAndDeinterleave(ResampleInputAudioFile* audio, int channels,
89 const StreamConfig& config, float* const* buffer);
90
91 void MonoToStereo(float* const* buffer, size_t frames_per_channel);
92
93 // APM input/output settings
94 StreamConfig input_config_;
95 StreamConfig reverse_config_;
96 StreamConfig output_config_;
97
98 // Input file format.
99 ResampleInputAudioFile input_audio_;
100 const int input_file_channels_;
101
102 // Reverse file format.
103 ResampleInputAudioFile reverse_audio_;
104 const int reverse_file_channels_;
105
106 // Buffer for APM input/output.
107 rtc::scoped_ptr<ChannelBuffer<float>> input_;
108 rtc::scoped_ptr<ChannelBuffer<float>> reverse_;
109 rtc::scoped_ptr<ChannelBuffer<float>> output_;
110
111 rtc::scoped_ptr<AudioProcessing> apm_;
112
113 const std::string dump_file_name_;
114
115 // Buffer for reading audio files.
116 std::vector<int16_t> signal_;
117 };
118
119 class DebugDumpTest : public ::testing::Test {
120 public:
121 DebugDumpTest();
122
123 // VerifyDebugDump replays a debug dump using APM and verifies that the result
124 // is bit-exact-identical to the output channel in the dump. This is only
125 // guaranteed if the debug dump is started on the first frame.
126 void VerifyDebugDump(const std::string& dump_file_name);
127
128 private:
129 // Following functions are facilities for replaying debug dumps.
130 void OnInitEvent(const audioproc::Init& msg);
131 void OnStreamEvent(const audioproc::Stream& msg);
132 void OnReverseStreamEvent(const audioproc::ReverseStream& msg);
133 void OnConfigEvent(const audioproc::Config& msg);
134
135 void MaybeRecreateApm(const audioproc::Config& msg);
136 void ConfigureApm(const audioproc::Config& msg);
137
138 // Buffer for APM input/output.
139 rtc::scoped_ptr<ChannelBuffer<float>> input_;
140 rtc::scoped_ptr<ChannelBuffer<float>> reverse_;
141 rtc::scoped_ptr<ChannelBuffer<float>> output_;
142
143 rtc::scoped_ptr<AudioProcessing> apm_;
144
145 StreamConfig input_config_;
146 StreamConfig reverse_config_;
147 StreamConfig output_config_;
148 };
149
150 DebugDumpGenerator::DebugDumpGenerator(std::string input_file_name,
151 int input_rate_hz,
152 int input_channels,
153 std::string reverse_file_name,
154 int reverse_rate_hz,
155 int reverse_channels,
156 const Config& config,
157 std::string dump_file_name)
158 : input_config_(input_rate_hz, input_channels),
159 reverse_config_(reverse_rate_hz, reverse_channels),
160 output_config_(input_rate_hz, input_channels),
161 input_audio_(input_file_name, input_rate_hz, input_rate_hz),
162 input_file_channels_(input_channels),
163 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz),
164 reverse_file_channels_(reverse_channels),
165 input_(new ChannelBuffer<float>(input_config_.num_frames(),
166 input_config_.num_channels())),
167 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(),
168 reverse_config_.num_channels())),
169 output_(new ChannelBuffer<float>(output_config_.num_frames(),
170 output_config_.num_channels())),
171 apm_(AudioProcessing::Create(config)),
172 dump_file_name_(dump_file_name) {
173 }
174
175 DebugDumpGenerator::DebugDumpGenerator(const Config& config)
176 : DebugDumpGenerator(test::ResourcePath("near32_stereo", "pcm"),
177 32000,
178 2,
179 test::ResourcePath("far32_stereo", "pcm"),
180 32000,
181 2,
182 config,
183 test::TempFilename(test::OutputPath(), "debug_aec")) {
184 }
185
186 DebugDumpGenerator::~DebugDumpGenerator() {
187 remove(dump_file_name_.c_str());
188 }
189
190 void DebugDumpGenerator::SetInputRate(int rate_hz) {
191 input_audio_.set_output_rate_hz(rate_hz);
192 input_config_.set_sample_rate_hz(rate_hz);
193 MaybeResetBuffer(input_, input_config_);
194 }
195
196 void DebugDumpGenerator::ForceInputMono(bool mono) {
197 const int channels = mono ? 1 : input_file_channels_;
198 input_config_.set_num_channels(channels);
199 MaybeResetBuffer(input_, input_config_);
200 }
201
202 void DebugDumpGenerator::SetReverseRate(int rate_hz) {
203 reverse_audio_.set_output_rate_hz(rate_hz);
204 reverse_config_.set_sample_rate_hz(rate_hz);
205 MaybeResetBuffer(reverse_, reverse_config_);
206 }
207
208 void DebugDumpGenerator::ForceReverseMono(bool mono) {
209 const int channels = mono ? 1 : reverse_file_channels_;
210 reverse_config_.set_num_channels(channels);
211 MaybeResetBuffer(reverse_, reverse_config_);
212 }
213
214 void DebugDumpGenerator::SetOutputRate(int rate_hz) {
215 output_config_.set_sample_rate_hz(rate_hz);
216 MaybeResetBuffer(output_, output_config_);
217 }
218
219 void DebugDumpGenerator::SetOutputChannels(int channels) {
220 output_config_.set_num_channels(channels);
221 MaybeResetBuffer(output_, output_config_);
222 }
223
224 void DebugDumpGenerator::StartRecording() {
225 apm_->StartDebugRecording(dump_file_name_.c_str());
226 }
227
228 void DebugDumpGenerator::Process(size_t num_blocks) {
229 for (size_t i = 0; i < num_blocks; ++i) {
230 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_,
231 reverse_config_, reverse_->channels());
232 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_,
233 input_->channels());
234 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100));
235 apm_->set_stream_key_pressed(i % 10 == 9);
236 RTC_CHECK_EQ(AudioProcessing::kNoError,
237 apm_->ProcessStream(input_->channels(), input_config_,
238 output_config_, output_->channels()));
239
240 RTC_CHECK_EQ(AudioProcessing::kNoError,
241 apm_->ProcessReverseStream(reverse_->channels(),
242 reverse_config_,
243 reverse_config_,
244 reverse_->channels()));
245 }
246 }
247
248 void DebugDumpGenerator::StopRecording() {
249 apm_->StopDebugRecording();
250 }
251
252 void DebugDumpGenerator::ReadAndDeinterleave(ResampleInputAudioFile* audio,
253 int channels,
254 const StreamConfig& config,
255 float* const* buffer) {
256 const size_t frames_per_channel = config.num_frames();
Andrew MacDonald 2015/10/24 00:42:06 No. frames == samples_per_channel. Use num_frames.
minyue-webrtc 2015/10/26 12:40:31 Done.
257 const int out_channels = config.num_channels();
258
259 // Make sure the buffer for reading the file is large enough.
260 if (channels * frames_per_channel > signal_.size()) {
261 signal_.resize(frames_per_channel * channels);
262 }
263
264 audio->Read(frames_per_channel * channels, &signal_[0]);
265
266 // We only allow reducing number channel by discarding some channels.
Andrew MacDonald 2015/10/24 00:42:05 number of channels
minyue-webrtc 2015/10/26 12:40:31 Done.
267 RTC_CHECK_LE(out_channels, channels);
268 for (int channel = 0; channel < out_channels; ++channel) {
269 for (size_t i = 0; i < frames_per_channel; ++i) {
270 buffer[channel][i] = S16ToFloat(signal_[i * channels + channel]);
271 }
272 }
273 }
274
275 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
276
277 DebugDumpTest::DebugDumpTest()
278 : input_(nullptr), // will be created upon usage.
279 reverse_(nullptr),
280 output_(nullptr),
281 apm_(nullptr) {
282 }
283
284 void DebugDumpTest::VerifyDebugDump(const std::string& in_filename) {
285 FILE* in_file = fopen(in_filename.c_str(), "rb");
286 ASSERT_TRUE(in_file);
287 audioproc::Event event_msg;
288
289 while (ReadMessageFromFile(in_file, &event_msg)) {
290 switch (event_msg.type()) {
291 case audioproc::Event::INIT:
292 OnInitEvent(event_msg.init());
293 break;
294 case audioproc::Event::STREAM:
295 OnStreamEvent(event_msg.stream());
296 break;
297 case audioproc::Event::REVERSE_STREAM:
298 OnReverseStreamEvent(event_msg.reverse_stream());
299 break;
300 case audioproc::Event::CONFIG:
301 OnConfigEvent(event_msg.config());
302 break;
303 case audioproc::Event::UNKNOWN_EVENT:
304 // We do not expect receive UNKNOWN event currently.
305 ASSERT_TRUE(false);
306 }
307 }
308 fclose(in_file);
309 }
310
311 // OnInitEvent reset the input/output/reserve channel format.
312 void DebugDumpTest::OnInitEvent(const audioproc::Init& msg) {
313 ASSERT_TRUE(msg.has_num_input_channels());
314 ASSERT_TRUE(msg.has_output_sample_rate());
315 ASSERT_TRUE(msg.has_num_output_channels());
316 ASSERT_TRUE(msg.has_reverse_sample_rate());
317 ASSERT_TRUE(msg.has_num_reverse_channels());
318
319 input_config_ = StreamConfig(msg.sample_rate(), msg.num_input_channels());
320 output_config_ =
321 StreamConfig(msg.output_sample_rate(), msg.num_output_channels());
322 reverse_config_ =
323 StreamConfig(msg.reverse_sample_rate(), msg.num_reverse_channels());
324
325 MaybeResetBuffer(input_, input_config_);
326 MaybeResetBuffer(output_, output_config_);
327 MaybeResetBuffer(reverse_, reverse_config_);
328 }
329
330 // OnStreamEvent replays an input signal and verifies the output.
331 void DebugDumpTest::OnStreamEvent(const audioproc::Stream& msg) {
332 // APM should have been created.
333 ASSERT_TRUE(apm_.get());
334
335 EXPECT_NOERR(apm_->gain_control()->set_stream_analog_level(msg.level()));
336 EXPECT_NOERR(apm_->set_stream_delay_ms(msg.delay()));
337 apm_->echo_cancellation()->set_stream_drift_samples(msg.drift());
338 if (msg.has_keypress())
339 apm_->set_stream_key_pressed(msg.keypress());
340 else
341 apm_->set_stream_key_pressed(true);
342
343 ASSERT_EQ(input_config_.num_channels(), msg.input_channel_size());
344 ASSERT_EQ(input_config_.num_frames() * sizeof(float),
345 msg.input_channel(0).size());
346
347 for (int i = 0; i < msg.input_channel_size(); ++i) {
348 memcpy(input_->channels()[i], msg.input_channel(i).data(),
349 msg.input_channel(i).size());
350 }
351
352 ASSERT_EQ(AudioProcessing::kNoError,
353 apm_->ProcessStream(input_->channels(), input_config_,
354 output_config_, output_->channels()));
355
356 // Check that output of APM is bit-exact to the output in the dump.
357 ASSERT_EQ(output_config_.num_channels(), msg.output_channel_size());
358 ASSERT_EQ(output_config_.num_frames() * sizeof(float),
359 msg.output_channel(0).size());
360 for (int i = 0; i < msg.output_channel_size(); ++i) {
361 ASSERT_EQ(0, memcmp(output_->channels()[i], msg.output_channel(i).data(),
362 msg.output_channel(i).size()));
363 }
364 }
365
366 void DebugDumpTest::OnReverseStreamEvent(const audioproc::ReverseStream& msg) {
367 // APM should have been created.
368 ASSERT_TRUE(apm_.get());
369
370 ASSERT_GT(msg.channel_size(), 0);
371 ASSERT_EQ(reverse_config_.num_channels(), msg.channel_size());
372 ASSERT_EQ(reverse_config_.num_frames() * sizeof(float),
373 msg.channel(0).size());
374
375 for (int i = 0; i < msg.channel_size(); ++i) {
376 memcpy(reverse_->channels()[i], msg.channel(i).data(),
377 msg.channel(i).size());
378 }
379
380 ASSERT_EQ(AudioProcessing::kNoError,
381 apm_->ProcessReverseStream(reverse_->channels(),
382 reverse_config_,
383 reverse_config_,
384 reverse_->channels()));
385 }
386
387 void DebugDumpTest::OnConfigEvent(const audioproc::Config& msg) {
388 MaybeRecreateApm(msg);
389 ConfigureApm(msg);
390 }
391
392 void DebugDumpTest::MaybeRecreateApm(const audioproc::Config& msg) {
393 // These configurations cannot be changed on the fly.
394 Config config;
395 ASSERT_TRUE(msg.has_aec_delay_agnostic_enabled());
396 config.Set<DelayAgnostic>(
397 new DelayAgnostic(msg.aec_delay_agnostic_enabled()));
398
399 ASSERT_TRUE(msg.has_noise_robust_agc_enabled());
400 config.Set<ExperimentalAgc>(
401 new ExperimentalAgc(msg.noise_robust_agc_enabled()));
402
403 ASSERT_TRUE(msg.has_transient_suppression_enabled());
404 config.Set<ExperimentalNs>(
405 new ExperimentalNs(msg.transient_suppression_enabled()));
406
407 ASSERT_TRUE(msg.has_aec_extended_filter_enabled());
408 config.Set<ExtendedFilter>(new ExtendedFilter(
409 msg.aec_extended_filter_enabled()));
410
411 // We only create APM once, since changes on these fields should not
412 // happen in current implementation.
413 if (!apm_.get()) {
414 apm_.reset(AudioProcessing::Create(config));
415 }
416 }
417
418 void DebugDumpTest::ConfigureApm(const audioproc::Config& msg) {
419 // AEC configs.
420 ASSERT_TRUE(msg.has_aec_enabled());
421 EXPECT_EQ(AudioProcessing::kNoError,
422 apm_->echo_cancellation()->Enable(msg.aec_enabled()));
423
424 ASSERT_TRUE(msg.has_aec_drift_compensation_enabled());
425 EXPECT_EQ(AudioProcessing::kNoError,
426 apm_->echo_cancellation()->enable_drift_compensation(
427 msg.aec_drift_compensation_enabled()));
428
429 ASSERT_TRUE(msg.has_aec_suppression_level());
430 EXPECT_EQ(AudioProcessing::kNoError,
431 apm_->echo_cancellation()->set_suppression_level(
432 static_cast<webrtc::EchoCancellation::SuppressionLevel>(
433 msg.aec_suppression_level())));
434
435 // AECM configs.
436 ASSERT_TRUE(msg.has_aecm_enabled());
437 EXPECT_EQ(AudioProcessing::kNoError,
438 apm_->echo_control_mobile()->Enable(msg.aecm_enabled()));
439
440 ASSERT_TRUE(msg.has_aecm_comfort_noise_enabled());
441 EXPECT_EQ(AudioProcessing::kNoError,
442 apm_->echo_control_mobile()->enable_comfort_noise(
443 msg.aecm_comfort_noise_enabled()));
444
445 ASSERT_TRUE(msg.has_aecm_routing_mode());
446 EXPECT_EQ(AudioProcessing::kNoError,
447 apm_->echo_control_mobile()->set_routing_mode(
448 static_cast<webrtc::EchoControlMobile::RoutingMode>(
449 msg.aecm_routing_mode())));
450
451 // AGC configs.
452 ASSERT_TRUE(msg.has_agc_enabled());
453 EXPECT_EQ(AudioProcessing::kNoError,
454 apm_->gain_control()->Enable(msg.agc_enabled()));
455
456 ASSERT_TRUE(msg.has_agc_mode());
457 EXPECT_EQ(AudioProcessing::kNoError,
458 apm_->gain_control()->set_mode(
459 static_cast<webrtc::GainControl::Mode>(msg.agc_mode())));
460
461 ASSERT_TRUE(msg.has_agc_limiter_enabled());
462 EXPECT_EQ(AudioProcessing::kNoError,
463 apm_->gain_control()->enable_limiter(msg.agc_limiter_enabled()));
464
465 // HPF configs.
466 ASSERT_TRUE(msg.has_hpf_enabled());
467 EXPECT_EQ(AudioProcessing::kNoError,
468 apm_->high_pass_filter()->Enable(msg.hpf_enabled()));
469
470 // NS configs.
471 ASSERT_TRUE(msg.has_ns_enabled());
472 EXPECT_EQ(AudioProcessing::kNoError,
473 apm_->noise_suppression()->Enable(msg.ns_enabled()));
474
475 ASSERT_TRUE(msg.has_ns_level());
476 EXPECT_EQ(AudioProcessing::kNoError,
477 apm_->noise_suppression()->set_level(
478 static_cast<webrtc::NoiseSuppression::Level>(msg.ns_level())));
479 }
480
481 TEST_F(DebugDumpTest, SimpleCase) {
482 Config config;
483 DebugDumpGenerator generator(config);
484 generator.StartRecording();
485 generator.Process(100);
486 generator.StopRecording();
487 VerifyDebugDump(generator.dump_file_name());
488 }
489
490 TEST_F(DebugDumpTest, ChangeInputFormat) {
491 Config config;
492 DebugDumpGenerator generator(config);
493 generator.StartRecording();
494 generator.Process(100);
495 generator.SetInputRate(48000);
496
497 generator.ForceInputMono(true);
498 // #channel of out put should not be larger than that of input. APM will fail
499 // otherwise.
500 generator.SetOutputChannels(1);
501
502 generator.Process(100);
503 generator.StopRecording();
504 VerifyDebugDump(generator.dump_file_name());
505 }
506
507 TEST_F(DebugDumpTest, ChangeReverseFormat) {
508 Config config;
509 DebugDumpGenerator generator(config);
510 generator.StartRecording();
511 generator.Process(100);
512 generator.SetReverseRate(48000);
513 generator.ForceReverseMono(true);
514 generator.Process(100);
515 generator.StopRecording();
516 VerifyDebugDump(generator.dump_file_name());
517 }
518
519 TEST_F(DebugDumpTest, ChangeOutputFormat) {
520 Config config;
521 DebugDumpGenerator generator(config);
522 generator.StartRecording();
523 generator.Process(100);
524 generator.SetOutputRate(48000);
525 generator.SetOutputChannels(1);
526 generator.Process(100);
527 generator.StopRecording();
528 VerifyDebugDump(generator.dump_file_name());
529 }
530
531 TEST_F(DebugDumpTest, ToggleAec) {
532 Config config;
533 DebugDumpGenerator generator(config);
534 generator.StartRecording();
535 generator.Process(100);
536
537 EchoCancellation* aec = generator.apm()->echo_cancellation();
538 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled()));
539
540 generator.Process(100);
541 generator.StopRecording();
542 VerifyDebugDump(generator.dump_file_name());
543 }
544
545 TEST_F(DebugDumpTest, ToggleDelayAgnosticAec) {
546 Config config;
547 config.Set<DelayAgnostic>(new DelayAgnostic(true));
548 DebugDumpGenerator generator(config);
549 generator.StartRecording();
550 generator.Process(100);
551
552 EchoCancellation* aec = generator.apm()->echo_cancellation();
553 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled()));
554
555 generator.Process(100);
556 generator.StopRecording();
557 VerifyDebugDump(generator.dump_file_name());
558 }
559
560 TEST_F(DebugDumpTest, ToggleAecLevel) {
561 Config config;
562 DebugDumpGenerator generator(config);
563 EchoCancellation* aec = generator.apm()->echo_cancellation();
564 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(true));
565 EXPECT_EQ(AudioProcessing::kNoError,
566 aec->set_suppression_level(EchoCancellation::kLowSuppression));
567 generator.StartRecording();
568 generator.Process(100);
569
570 EXPECT_EQ(AudioProcessing::kNoError,
571 aec->set_suppression_level(EchoCancellation::kHighSuppression));
572 generator.Process(100);
573 generator.StopRecording();
574 VerifyDebugDump(generator.dump_file_name());
575 }
576
577 TEST_F(DebugDumpTest, ToggleAgc) {
578 Config config;
579 DebugDumpGenerator generator(config);
580 generator.StartRecording();
581 generator.Process(100);
582
583 GainControl* agc = generator.apm()->gain_control();
584 EXPECT_EQ(AudioProcessing::kNoError, agc->Enable(!agc->is_enabled()));
585
586 generator.Process(100);
587 generator.StopRecording();
588 VerifyDebugDump(generator.dump_file_name());
589 }
590
591 TEST_F(DebugDumpTest, ToggleNs) {
592 Config config;
593 DebugDumpGenerator generator(config);
594 generator.StartRecording();
595 generator.Process(100);
596
597 NoiseSuppression* ns = generator.apm()->noise_suppression();
598 EXPECT_EQ(AudioProcessing::kNoError, ns->Enable(!ns->is_enabled()));
599
600 generator.Process(100);
601 generator.StopRecording();
602 VerifyDebugDump(generator.dump_file_name());
603 }
604
605 TEST_F(DebugDumpTest, TransientSuppressionOn) {
606 Config config;
607 config.Set<ExperimentalNs>(new ExperimentalNs(true));
608 DebugDumpGenerator generator(config);
609 generator.StartRecording();
610 generator.Process(100);
611 generator.StopRecording();
612 VerifyDebugDump(generator.dump_file_name());
613 }
614
615 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
616
617 } // namespace test
618 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/modules.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698