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_RESAMPLE_INPUT_AUDIO_FILE_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_RESAMPLE_INPUT_AUDIO_FILE_H_ 13 14 #include <string> 15 16 #include "common_audio/resampler/include/resampler.h" 17 #include "modules/audio_coding/neteq/tools/input_audio_file.h" 18 #include "rtc_base/constructor_magic.h" 19 20 namespace webrtc { 21 namespace test { 22 23 // Class for handling a looping input audio file with resampling. 24 class ResampleInputAudioFile : public InputAudioFile { 25 public: 26 ResampleInputAudioFile(const std::string file_name, 27 int file_rate_hz, 28 bool loop_at_end = true) InputAudioFile(file_name,loop_at_end)29 : InputAudioFile(file_name, loop_at_end), 30 file_rate_hz_(file_rate_hz), 31 output_rate_hz_(-1) {} 32 ResampleInputAudioFile(const std::string file_name, 33 int file_rate_hz, 34 int output_rate_hz, 35 bool loop_at_end = true) InputAudioFile(file_name,loop_at_end)36 : InputAudioFile(file_name, loop_at_end), 37 file_rate_hz_(file_rate_hz), 38 output_rate_hz_(output_rate_hz) {} 39 40 bool Read(size_t samples, int output_rate_hz, int16_t* destination); 41 bool Read(size_t samples, int16_t* destination) override; 42 void set_output_rate_hz(int rate_hz); 43 44 private: 45 const int file_rate_hz_; 46 int output_rate_hz_; 47 Resampler resampler_; 48 RTC_DISALLOW_COPY_AND_ASSIGN(ResampleInputAudioFile); 49 }; 50 51 } // namespace test 52 } // namespace webrtc 53 #endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_RESAMPLE_INPUT_AUDIO_FILE_H_ 54