• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2017 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_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_FACTORY_H_
12 #define MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_FACTORY_H_
13 
14 #include <map>
15 #include <memory>
16 #include <string>
17 
18 #include "modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h"
19 #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h"
20 #include "test/gmock.h"
21 
22 namespace webrtc {
23 namespace test {
24 namespace conversational_speech {
25 
26 class MockWavReaderFactory : public WavReaderAbstractFactory {
27  public:
28   struct Params {
29     int sample_rate;
30     size_t num_channels;
31     size_t num_samples;
32   };
33 
34   MockWavReaderFactory(const Params& default_params,
35                        const std::map<std::string, const Params>& params);
36   explicit MockWavReaderFactory(const Params& default_params);
37   ~MockWavReaderFactory();
38 
39   MOCK_METHOD(std::unique_ptr<WavReaderInterface>,
40               Create,
41               (const std::string&),
42               (const, override));
43 
44  private:
45   // Creates a MockWavReader instance using the parameters in
46   // audiotrack_names_params_ if the entry corresponding to filepath exists,
47   // otherwise creates a MockWavReader instance using the default parameters.
48   std::unique_ptr<WavReaderInterface> CreateMock(const std::string& filepath);
49 
50   const Params& default_params_;
51   std::map<std::string, const Params> audiotrack_names_params_;
52 };
53 
54 }  // namespace conversational_speech
55 }  // namespace test
56 }  // namespace webrtc
57 
58 #endif  // MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_FACTORY_H_
59