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