1 /* 2 * Copyright (c) 2019 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 TEST_TESTSUPPORT_COPY_TO_FILE_AUDIO_CAPTURER_H_ 12 #define TEST_TESTSUPPORT_COPY_TO_FILE_AUDIO_CAPTURER_H_ 13 14 #include <memory> 15 #include <string> 16 17 #include "absl/types/optional.h" 18 #include "api/array_view.h" 19 #include "common_audio/wav_file.h" 20 #include "modules/audio_device/include/test_audio_device.h" 21 #include "rtc_base/buffer.h" 22 23 namespace webrtc { 24 namespace test { 25 26 // TestAudioDeviceModule::Capturer that will store audio data, captured by 27 // delegate to the specified output file. Can be used to create a copy of 28 // generated audio data to be able then to compare it as a reference with 29 // audio on the TestAudioDeviceModule::Renderer side. 30 class CopyToFileAudioCapturer : public TestAudioDeviceModule::Capturer { 31 public: 32 CopyToFileAudioCapturer( 33 std::unique_ptr<TestAudioDeviceModule::Capturer> delegate, 34 std::string stream_dump_file_name); 35 ~CopyToFileAudioCapturer() override; 36 37 int SamplingFrequency() const override; 38 int NumChannels() const override; 39 bool Capture(rtc::BufferT<int16_t>* buffer) override; 40 41 private: 42 std::unique_ptr<TestAudioDeviceModule::Capturer> delegate_; 43 std::unique_ptr<WavWriter> wav_writer_; 44 }; 45 46 } // namespace test 47 } // namespace webrtc 48 49 #endif // TEST_TESTSUPPORT_COPY_TO_FILE_AUDIO_CAPTURER_H_ 50