Chromium Code Reviews

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

Issue 2747123007: Test submission of complete AEC-dump refactoring. (Closed)
Patch Set: Changed interface and build structure after reviewer comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 "webrtc/modules/audio_processing/test/audio_processing_simulator.h" 11 #include "webrtc/modules/audio_processing/test/audio_processing_simulator.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <iostream> 14 #include <iostream>
15 #include <sstream> 15 #include <sstream>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/checks.h" 19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/stringutils.h" 20 #include "webrtc/base/stringutils.h"
21 #include "webrtc/common_audio/include/audio_util.h" 21 #include "webrtc/common_audio/include/audio_util.h"
22 #include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h"
22 #include "webrtc/modules/audio_processing/include/audio_processing.h" 23 #include "webrtc/modules/audio_processing/include/audio_processing.h"
23 24
24 namespace webrtc { 25 namespace webrtc {
25 namespace test { 26 namespace test {
26 namespace { 27 namespace {
27 28
28 void CopyFromAudioFrame(const AudioFrame& src, ChannelBuffer<float>* dest) { 29 void CopyFromAudioFrame(const AudioFrame& src, ChannelBuffer<float>* dest) {
29 RTC_CHECK_EQ(src.num_channels_, dest->num_channels()); 30 RTC_CHECK_EQ(src.num_channels_, dest->num_channels());
30 RTC_CHECK_EQ(src.samples_per_channel_, dest->num_frames()); 31 RTC_CHECK_EQ(src.samples_per_channel_, dest->num_frames());
31 // Copy the data from the input buffer. 32 // Copy the data from the input buffer.
(...skipping 39 matching lines...)
71 for (size_t ch = 0; ch < dest->num_channels_; ++ch) { 72 for (size_t ch = 0; ch < dest->num_channels_; ++ch) {
72 for (size_t sample = 0; sample < dest->samples_per_channel_; ++sample) { 73 for (size_t sample = 0; sample < dest->samples_per_channel_; ++sample) {
73 dest->data_[sample * dest->num_channels_ + ch] = 74 dest->data_[sample * dest->num_channels_ + ch] =
74 src.channels()[ch][sample] * 32767; 75 src.channels()[ch][sample] * 32767;
75 } 76 }
76 } 77 }
77 } 78 }
78 79
79 AudioProcessingSimulator::AudioProcessingSimulator( 80 AudioProcessingSimulator::AudioProcessingSimulator(
80 const SimulationSettings& settings) 81 const SimulationSettings& settings)
81 : settings_(settings) { 82 : settings_(settings), worker_queue_("file_writer_task_queue") {
82 if (settings_.ed_graph_output_filename && 83 if (settings_.ed_graph_output_filename &&
83 settings_.ed_graph_output_filename->size() > 0) { 84 settings_.ed_graph_output_filename->size() > 0) {
84 residual_echo_likelihood_graph_writer_.open( 85 residual_echo_likelihood_graph_writer_.open(
85 *settings_.ed_graph_output_filename); 86 *settings_.ed_graph_output_filename);
86 RTC_CHECK(residual_echo_likelihood_graph_writer_.is_open()); 87 RTC_CHECK(residual_echo_likelihood_graph_writer_.is_open());
87 WriteEchoLikelihoodGraphFileHeader(&residual_echo_likelihood_graph_writer_); 88 WriteEchoLikelihoodGraphFileHeader(&residual_echo_likelihood_graph_writer_);
88 } 89 }
89 } 90 }
90 91
91 AudioProcessingSimulator::~AudioProcessingSimulator() { 92 AudioProcessingSimulator::~AudioProcessingSimulator() {
(...skipping 149 matching lines...)
241 static_cast<size_t>(reverse_out_config_.num_channels()))); 242 static_cast<size_t>(reverse_out_config_.num_channels())));
242 reverse_buffer_writer_.reset( 243 reverse_buffer_writer_.reset(
243 new ChannelBufferWavWriter(std::move(reverse_out_file))); 244 new ChannelBufferWavWriter(std::move(reverse_out_file)));
244 } 245 }
245 246
246 ++output_reset_counter_; 247 ++output_reset_counter_;
247 } 248 }
248 249
249 void AudioProcessingSimulator::DestroyAudioProcessor() { 250 void AudioProcessingSimulator::DestroyAudioProcessor() {
250 if (settings_.aec_dump_output_filename) { 251 if (settings_.aec_dump_output_filename) {
251 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->StopDebugRecording()); 252 ap_->StopDebugRecording();
252 } 253 }
253 } 254 }
254 255
255 void AudioProcessingSimulator::CreateAudioProcessor() { 256 void AudioProcessingSimulator::CreateAudioProcessor() {
256 Config config; 257 Config config;
257 AudioProcessing::Config apm_config; 258 AudioProcessing::Config apm_config;
258 if (settings_.use_bf && *settings_.use_bf) { 259 if (settings_.use_bf && *settings_.use_bf) {
259 config.Set<Beamforming>(new Beamforming( 260 config.Set<Beamforming>(new Beamforming(
260 true, ParseArrayGeometry(*settings_.microphone_positions), 261 true, ParseArrayGeometry(*settings_.microphone_positions),
261 SphericalPointf(DegreesToRadians(settings_.target_angle_degrees), 0.f, 262 SphericalPointf(DegreesToRadians(settings_.target_angle_degrees), 0.f,
(...skipping 116 matching lines...)
378 AudioProcessing::kNoError, 379 AudioProcessing::kNoError,
379 ap_->noise_suppression()->set_level( 380 ap_->noise_suppression()->set_level(
380 static_cast<NoiseSuppression::Level>(*settings_.ns_level))); 381 static_cast<NoiseSuppression::Level>(*settings_.ns_level)));
381 } 382 }
382 383
383 if (settings_.use_ts) { 384 if (settings_.use_ts) {
384 ap_->set_stream_key_pressed(*settings_.use_ts); 385 ap_->set_stream_key_pressed(*settings_.use_ts);
385 } 386 }
386 387
387 if (settings_.aec_dump_output_filename) { 388 if (settings_.aec_dump_output_filename) {
388 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; 389 ap_->StartDebugRecording(AecDumpFactory::Create(
389 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); 390 *settings_.aec_dump_output_filename, -1, &worker_queue_));
390 RTC_CHECK_EQ(AudioProcessing::kNoError,
391 ap_->StartDebugRecording(
392 settings_.aec_dump_output_filename->c_str(), -1));
393 } 391 }
394 } 392 }
395 393
396 } // namespace test 394 } // namespace test
397 } // namespace webrtc 395 } // namespace webrtc
OLDNEW

Powered by Google App Engine