OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_PROCESSOR_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_PROCESSOR_H_ |
| 13 |
| 14 #include <algorithm> |
| 15 #include <limits> |
| 16 #include <memory> |
| 17 #include <string> |
| 18 #include <vector> |
| 19 |
| 20 #include "webrtc/base/timeutils.h" |
| 21 #include "webrtc/base/optional.h" |
| 22 #include "webrtc/common_audio/channel_buffer.h" |
| 23 #include "webrtc/common_audio/wav_file.h" |
| 24 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 25 #include "webrtc/modules/audio_processing/test/audio_file_processor.h" |
| 26 #include "webrtc/modules/audio_processing/test/test_utils.h" |
| 27 |
| 28 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 29 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" |
| 30 #else |
| 31 #include "webrtc/modules/audio_processing/debug.pb.h" |
| 32 #endif |
| 33 |
| 34 namespace webrtc { |
| 35 namespace test { |
| 36 |
| 37 // Used to read from an aecdump file and write to a WavWriter. |
| 38 class AecDumpFileProcessor final : public AudioFileProcessor { |
| 39 public: |
| 40 AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap, |
| 41 FILE* dump_file, |
| 42 std::string out_filename, |
| 43 std::string reverse_out_filename, |
| 44 rtc::Optional<int> out_sample_rate_hz, |
| 45 rtc::Optional<int> out_num_channels, |
| 46 rtc::Optional<int> reverse_out_sample_rate_hz, |
| 47 rtc::Optional<int> reverse_out_num_channels, |
| 48 bool override_config_message); |
| 49 |
| 50 virtual ~AecDumpFileProcessor(); |
| 51 |
| 52 // Processes the messages in the aecdump file and returns |
| 53 // the number of forward stream chunks processed. |
| 54 size_t Process(bool verbose_logging) override; |
| 55 |
| 56 private: |
| 57 void HandleMessage(const webrtc::audioproc::Init& msg); |
| 58 void HandleMessage(const webrtc::audioproc::Stream& msg); |
| 59 void HandleMessage(const webrtc::audioproc::ReverseStream& msg); |
| 60 void HandleMessage(const webrtc::audioproc::Config& msg); |
| 61 |
| 62 enum InterfaceType { |
| 63 kIntInterface, |
| 64 kFloatInterface, |
| 65 kNotSpecified, |
| 66 }; |
| 67 |
| 68 std::unique_ptr<AudioProcessing> ap_; |
| 69 FILE* dump_file_; |
| 70 std::string out_filename_; |
| 71 std::string reverse_out_filename_; |
| 72 rtc::Optional<int> out_sample_rate_hz_; |
| 73 rtc::Optional<int> out_num_channels_; |
| 74 rtc::Optional<int> reverse_out_sample_rate_hz_; |
| 75 rtc::Optional<int> reverse_out_num_channels_; |
| 76 bool override_config_message_; |
| 77 |
| 78 std::unique_ptr<ChannelBuffer<float>> in_buf_; |
| 79 std::unique_ptr<ChannelBuffer<float>> reverse_buf_; |
| 80 std::unique_ptr<ChannelBuffer<float>> out_buf_; |
| 81 std::unique_ptr<ChannelBuffer<float>> reverse_out_buf_; |
| 82 std::unique_ptr<WavWriter> out_file_; |
| 83 std::unique_ptr<WavWriter> reverse_out_file_; |
| 84 StreamConfig input_config_; |
| 85 StreamConfig reverse_config_; |
| 86 StreamConfig output_config_; |
| 87 StreamConfig reverse_output_config_; |
| 88 std::unique_ptr<ChannelBufferWavWriter> buffer_writer_; |
| 89 std::unique_ptr<ChannelBufferWavWriter> reverse_buffer_writer_; |
| 90 AudioFrame far_frame_; |
| 91 AudioFrame near_frame_; |
| 92 InterfaceType interface_used_ = InterfaceType::kNotSpecified; |
| 93 }; |
| 94 |
| 95 } // namespace test |
| 96 } // namespace webrtc |
| 97 |
| 98 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_PROCESSOR_H_ |
OLD | NEW |