tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

output_wav_file.h (1498B)


      1 /*
      2 *  Copyright (c) 2014 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_CODING_NETEQ_TOOLS_OUTPUT_WAV_FILE_H_
     12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_OUTPUT_WAV_FILE_H_
     13 
     14 #include <cstddef>
     15 #include <cstdint>
     16 
     17 #include "absl/strings/string_view.h"
     18 #include "common_audio/wav_file.h"
     19 #include "modules/audio_coding/neteq/tools/audio_sink.h"
     20 
     21 namespace webrtc {
     22 namespace test {
     23 
     24 class OutputWavFile : public AudioSink {
     25 public:
     26  // Creates an OutputWavFile, opening a file named `file_name` for writing.
     27  // The output file is a PCM encoded wav file.
     28  OutputWavFile(absl::string_view file_name,
     29                int sample_rate_hz,
     30                int num_channels = 1)
     31      : wav_writer_(file_name, sample_rate_hz, num_channels) {}
     32 
     33  OutputWavFile(const OutputWavFile&) = delete;
     34  OutputWavFile& operator=(const OutputWavFile&) = delete;
     35 
     36  bool WriteArray(const int16_t* audio, size_t num_samples) override {
     37    wav_writer_.WriteSamples(audio, num_samples);
     38    return true;
     39  }
     40 
     41 private:
     42  WavWriter wav_writer_;
     43 };
     44 
     45 }  // namespace test
     46 }  // namespace webrtc
     47 #endif  // MODULES_AUDIO_CODING_NETEQ_TOOLS_OUTPUT_WAV_FILE_H_