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 MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_ 12 #define MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_ 13 14 #include <fstream> 15 #include <string> 16 17 #include "modules/audio_processing/test/audio_processing_simulator.h" 18 #include "rtc_base/constructor_magic.h" 19 #include "rtc_base/ignore_wundef.h" 20 21 RTC_PUSH_IGNORING_WUNDEF() 22 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 23 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" 24 #else 25 #include "modules/audio_processing/debug.pb.h" 26 #endif RTC_POP_IGNORING_WUNDEF()27RTC_POP_IGNORING_WUNDEF() 28 29 namespace webrtc { 30 namespace test { 31 32 // Used to perform an audio processing simulation from an aec dump. 33 class AecDumpBasedSimulator final : public AudioProcessingSimulator { 34 public: 35 AecDumpBasedSimulator(const SimulationSettings& settings, 36 rtc::scoped_refptr<AudioProcessing> audio_processing, 37 std::unique_ptr<AudioProcessingBuilder> ap_builder); 38 ~AecDumpBasedSimulator() override; 39 40 // Processes the messages in the aecdump file. 41 void Process() override; 42 43 private: 44 void HandleEvent(const webrtc::audioproc::Event& event_msg, 45 int* num_forward_chunks_processed); 46 void HandleMessage(const webrtc::audioproc::Init& msg); 47 void HandleMessage(const webrtc::audioproc::Stream& msg); 48 void HandleMessage(const webrtc::audioproc::ReverseStream& msg); 49 void HandleMessage(const webrtc::audioproc::Config& msg); 50 void HandleMessage(const webrtc::audioproc::RuntimeSetting& msg); 51 void PrepareProcessStreamCall(const webrtc::audioproc::Stream& msg); 52 void PrepareReverseProcessStreamCall( 53 const webrtc::audioproc::ReverseStream& msg); 54 void VerifyProcessStreamBitExactness(const webrtc::audioproc::Stream& msg); 55 void MaybeOpenCallOrderFile(); 56 enum InterfaceType { 57 kFixedInterface, 58 kFloatInterface, 59 kNotSpecified, 60 }; 61 62 FILE* dump_input_file_; 63 std::unique_ptr<ChannelBuffer<float>> artificial_nearend_buf_; 64 std::unique_ptr<ChannelBufferWavReader> artificial_nearend_buffer_reader_; 65 bool artificial_nearend_eof_reported_ = false; 66 InterfaceType interface_used_ = InterfaceType::kNotSpecified; 67 std::unique_ptr<std::ofstream> call_order_output_file_; 68 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AecDumpBasedSimulator); 69 }; 70 71 } // namespace test 72 } // namespace webrtc 73 74 #endif // MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_ 75