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