• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "test/testsupport/copy_to_file_audio_capturer.h"
12 
13 #include <memory>
14 #include <utility>
15 
16 namespace webrtc {
17 namespace test {
18 
CopyToFileAudioCapturer(std::unique_ptr<TestAudioDeviceModule::Capturer> delegate,std::string stream_dump_file_name)19 CopyToFileAudioCapturer::CopyToFileAudioCapturer(
20     std::unique_ptr<TestAudioDeviceModule::Capturer> delegate,
21     std::string stream_dump_file_name)
22     : delegate_(std::move(delegate)),
23       wav_writer_(std::make_unique<WavWriter>(std::move(stream_dump_file_name),
24                                               delegate_->SamplingFrequency(),
25                                               delegate_->NumChannels())) {}
26 CopyToFileAudioCapturer::~CopyToFileAudioCapturer() = default;
27 
SamplingFrequency() const28 int CopyToFileAudioCapturer::SamplingFrequency() const {
29   return delegate_->SamplingFrequency();
30 }
31 
NumChannels() const32 int CopyToFileAudioCapturer::NumChannels() const {
33   return delegate_->NumChannels();
34 }
35 
Capture(rtc::BufferT<int16_t> * buffer)36 bool CopyToFileAudioCapturer::Capture(rtc::BufferT<int16_t>* buffer) {
37   bool result = delegate_->Capture(buffer);
38   if (result) {
39     wav_writer_->WriteSamples(buffer->data(), buffer->size());
40   }
41   return result;
42 }
43 
44 }  // namespace test
45 }  // namespace webrtc
46