OLD | NEW |
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 |
| 13 #include <memory> |
12 #include <string> | 14 #include <string> |
13 #include <vector> | 15 #include <vector> |
14 | 16 |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/scoped_ptr.h" | |
18 #include "webrtc/common_audio/channel_buffer.h" | 19 #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_coding/neteq/tools/resample_input_audio_file.h" |
20 #include "webrtc/modules/audio_processing/debug.pb.h" | 21 #include "webrtc/modules/audio_processing/debug.pb.h" |
21 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 22 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
22 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 23 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
23 #include "webrtc/modules/audio_processing/test/test_utils.h" | 24 #include "webrtc/modules/audio_processing/test/test_utils.h" |
24 #include "webrtc/test/testsupport/fileutils.h" | 25 #include "webrtc/test/testsupport/fileutils.h" |
25 | 26 |
26 namespace webrtc { | 27 namespace webrtc { |
27 namespace test { | 28 namespace test { |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 void MaybeResetBuffer(rtc::scoped_ptr<ChannelBuffer<float>>* buffer, | 32 void MaybeResetBuffer(std::unique_ptr<ChannelBuffer<float>>* buffer, |
32 const StreamConfig& config) { | 33 const StreamConfig& config) { |
33 auto& buffer_ref = *buffer; | 34 auto& buffer_ref = *buffer; |
34 if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() || | 35 if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() || |
35 buffer_ref->num_channels() != config.num_channels()) { | 36 buffer_ref->num_channels() != config.num_channels()) { |
36 buffer_ref.reset(new ChannelBuffer<float>(config.num_frames(), | 37 buffer_ref.reset(new ChannelBuffer<float>(config.num_frames(), |
37 config.num_channels())); | 38 config.num_channels())); |
38 } | 39 } |
39 } | 40 } |
40 | 41 |
41 class DebugDumpGenerator { | 42 class DebugDumpGenerator { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const std::string input_file_name_; | 95 const std::string input_file_name_; |
95 ResampleInputAudioFile input_audio_; | 96 ResampleInputAudioFile input_audio_; |
96 const int input_file_channels_; | 97 const int input_file_channels_; |
97 | 98 |
98 // Reverse file format. | 99 // Reverse file format. |
99 const std::string reverse_file_name_; | 100 const std::string reverse_file_name_; |
100 ResampleInputAudioFile reverse_audio_; | 101 ResampleInputAudioFile reverse_audio_; |
101 const int reverse_file_channels_; | 102 const int reverse_file_channels_; |
102 | 103 |
103 // Buffer for APM input/output. | 104 // Buffer for APM input/output. |
104 rtc::scoped_ptr<ChannelBuffer<float>> input_; | 105 std::unique_ptr<ChannelBuffer<float>> input_; |
105 rtc::scoped_ptr<ChannelBuffer<float>> reverse_; | 106 std::unique_ptr<ChannelBuffer<float>> reverse_; |
106 rtc::scoped_ptr<ChannelBuffer<float>> output_; | 107 std::unique_ptr<ChannelBuffer<float>> output_; |
107 | 108 |
108 rtc::scoped_ptr<AudioProcessing> apm_; | 109 std::unique_ptr<AudioProcessing> apm_; |
109 | 110 |
110 const std::string dump_file_name_; | 111 const std::string dump_file_name_; |
111 }; | 112 }; |
112 | 113 |
113 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, | 114 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, |
114 int input_rate_hz, | 115 int input_rate_hz, |
115 int input_channels, | 116 int input_channels, |
116 const std::string& reverse_file_name, | 117 const std::string& reverse_file_name, |
117 int reverse_rate_hz, | 118 int reverse_rate_hz, |
118 int reverse_channels, | 119 int reverse_channels, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // Following functions are facilities for replaying debug dumps. | 244 // Following functions are facilities for replaying debug dumps. |
244 void OnInitEvent(const audioproc::Init& msg); | 245 void OnInitEvent(const audioproc::Init& msg); |
245 void OnStreamEvent(const audioproc::Stream& msg); | 246 void OnStreamEvent(const audioproc::Stream& msg); |
246 void OnReverseStreamEvent(const audioproc::ReverseStream& msg); | 247 void OnReverseStreamEvent(const audioproc::ReverseStream& msg); |
247 void OnConfigEvent(const audioproc::Config& msg); | 248 void OnConfigEvent(const audioproc::Config& msg); |
248 | 249 |
249 void MaybeRecreateApm(const audioproc::Config& msg); | 250 void MaybeRecreateApm(const audioproc::Config& msg); |
250 void ConfigureApm(const audioproc::Config& msg); | 251 void ConfigureApm(const audioproc::Config& msg); |
251 | 252 |
252 // Buffer for APM input/output. | 253 // Buffer for APM input/output. |
253 rtc::scoped_ptr<ChannelBuffer<float>> input_; | 254 std::unique_ptr<ChannelBuffer<float>> input_; |
254 rtc::scoped_ptr<ChannelBuffer<float>> reverse_; | 255 std::unique_ptr<ChannelBuffer<float>> reverse_; |
255 rtc::scoped_ptr<ChannelBuffer<float>> output_; | 256 std::unique_ptr<ChannelBuffer<float>> output_; |
256 | 257 |
257 rtc::scoped_ptr<AudioProcessing> apm_; | 258 std::unique_ptr<AudioProcessing> apm_; |
258 | 259 |
259 StreamConfig input_config_; | 260 StreamConfig input_config_; |
260 StreamConfig reverse_config_; | 261 StreamConfig reverse_config_; |
261 StreamConfig output_config_; | 262 StreamConfig output_config_; |
262 }; | 263 }; |
263 | 264 |
264 DebugDumpTest::DebugDumpTest() | 265 DebugDumpTest::DebugDumpTest() |
265 : input_(nullptr), // will be created upon usage. | 266 : input_(nullptr), // will be created upon usage. |
266 reverse_(nullptr), | 267 reverse_(nullptr), |
267 output_(nullptr), | 268 output_(nullptr), |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 config.Set<ExperimentalNs>(new ExperimentalNs(true)); | 604 config.Set<ExperimentalNs>(new ExperimentalNs(true)); |
604 DebugDumpGenerator generator(config); | 605 DebugDumpGenerator generator(config); |
605 generator.StartRecording(); | 606 generator.StartRecording(); |
606 generator.Process(100); | 607 generator.Process(100); |
607 generator.StopRecording(); | 608 generator.StopRecording(); |
608 VerifyDebugDump(generator.dump_file_name()); | 609 VerifyDebugDump(generator.dump_file_name()); |
609 } | 610 } |
610 | 611 |
611 } // namespace test | 612 } // namespace test |
612 } // namespace webrtc | 613 } // namespace webrtc |
OLD | NEW |