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

Side by Side Diff: webrtc/modules/audio_processing/test/audio_processing_simulator.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
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 for (size_t ch = 0; ch < dest->num_channels_; ++ch) { 73 for (size_t ch = 0; ch < dest->num_channels_; ++ch) {
73 for (size_t sample = 0; sample < dest->samples_per_channel_; ++sample) { 74 for (size_t sample = 0; sample < dest->samples_per_channel_; ++sample) {
74 dest_data[sample * dest->num_channels_ + ch] = 75 dest_data[sample * dest->num_channels_ + ch] =
75 src.channels()[ch][sample] * 32767; 76 src.channels()[ch][sample] * 32767;
76 } 77 }
77 } 78 }
78 } 79 }
79 80
80 AudioProcessingSimulator::AudioProcessingSimulator( 81 AudioProcessingSimulator::AudioProcessingSimulator(
81 const SimulationSettings& settings) 82 const SimulationSettings& settings)
82 : settings_(settings) { 83 : settings_(settings), worker_queue_("file_writer_task_queue") {
83 if (settings_.ed_graph_output_filename && 84 if (settings_.ed_graph_output_filename &&
84 settings_.ed_graph_output_filename->size() > 0) { 85 settings_.ed_graph_output_filename->size() > 0) {
85 residual_echo_likelihood_graph_writer_.open( 86 residual_echo_likelihood_graph_writer_.open(
86 *settings_.ed_graph_output_filename); 87 *settings_.ed_graph_output_filename);
87 RTC_CHECK(residual_echo_likelihood_graph_writer_.is_open()); 88 RTC_CHECK(residual_echo_likelihood_graph_writer_.is_open());
88 WriteEchoLikelihoodGraphFileHeader(&residual_echo_likelihood_graph_writer_); 89 WriteEchoLikelihoodGraphFileHeader(&residual_echo_likelihood_graph_writer_);
89 } 90 }
90 } 91 }
91 92
92 AudioProcessingSimulator::~AudioProcessingSimulator() { 93 AudioProcessingSimulator::~AudioProcessingSimulator() {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 static_cast<size_t>(reverse_out_config_.num_channels()))); 243 static_cast<size_t>(reverse_out_config_.num_channels())));
243 reverse_buffer_writer_.reset( 244 reverse_buffer_writer_.reset(
244 new ChannelBufferWavWriter(std::move(reverse_out_file))); 245 new ChannelBufferWavWriter(std::move(reverse_out_file)));
245 } 246 }
246 247
247 ++output_reset_counter_; 248 ++output_reset_counter_;
248 } 249 }
249 250
250 void AudioProcessingSimulator::DestroyAudioProcessor() { 251 void AudioProcessingSimulator::DestroyAudioProcessor() {
251 if (settings_.aec_dump_output_filename) { 252 if (settings_.aec_dump_output_filename) {
252 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->StopDebugRecording()); 253 ap_->DetachAecDump();
253 } 254 }
254 } 255 }
255 256
256 void AudioProcessingSimulator::CreateAudioProcessor() { 257 void AudioProcessingSimulator::CreateAudioProcessor() {
257 Config config; 258 Config config;
258 AudioProcessing::Config apm_config; 259 AudioProcessing::Config apm_config;
259 if (settings_.use_bf && *settings_.use_bf) { 260 if (settings_.use_bf && *settings_.use_bf) {
260 config.Set<Beamforming>(new Beamforming( 261 config.Set<Beamforming>(new Beamforming(
261 true, ParseArrayGeometry(*settings_.microphone_positions), 262 true, ParseArrayGeometry(*settings_.microphone_positions),
262 SphericalPointf(DegreesToRadians(settings_.target_angle_degrees), 0.f, 263 SphericalPointf(DegreesToRadians(settings_.target_angle_degrees), 0.f,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 AudioProcessing::kNoError, 383 AudioProcessing::kNoError,
383 ap_->noise_suppression()->set_level( 384 ap_->noise_suppression()->set_level(
384 static_cast<NoiseSuppression::Level>(*settings_.ns_level))); 385 static_cast<NoiseSuppression::Level>(*settings_.ns_level)));
385 } 386 }
386 387
387 if (settings_.use_ts) { 388 if (settings_.use_ts) {
388 ap_->set_stream_key_pressed(*settings_.use_ts); 389 ap_->set_stream_key_pressed(*settings_.use_ts);
389 } 390 }
390 391
391 if (settings_.aec_dump_output_filename) { 392 if (settings_.aec_dump_output_filename) {
392 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; 393 ap_->AttachAecDump(AecDumpFactory::Create(
393 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); 394 *settings_.aec_dump_output_filename, -1, &worker_queue_));
394 RTC_CHECK_EQ(AudioProcessing::kNoError,
395 ap_->StartDebugRecording(
396 settings_.aec_dump_output_filename->c_str(), -1));
397 } 395 }
398 } 396 }
399 397
400 } // namespace test 398 } // namespace test
401 } // namespace webrtc 399 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698