1 /* 2 * Copyright (c) 2013 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_INCLUDE_MOCK_AUDIO_PROCESSING_H_ 12 #define MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ 13 14 #include <memory> 15 16 #include "modules/audio_processing/include/aec_dump.h" 17 #include "modules/audio_processing/include/audio_processing.h" 18 #include "modules/audio_processing/include/audio_processing_statistics.h" 19 #include "test/gmock.h" 20 21 namespace webrtc { 22 23 namespace test { 24 class MockCustomProcessing : public CustomProcessing { 25 public: ~MockCustomProcessing()26 virtual ~MockCustomProcessing() {} 27 MOCK_METHOD(void, 28 Initialize, 29 (int sample_rate_hz, int num_channels), 30 (override)); 31 MOCK_METHOD(void, Process, (AudioBuffer * audio), (override)); 32 MOCK_METHOD(void, 33 SetRuntimeSetting, 34 (AudioProcessing::RuntimeSetting setting), 35 (override)); 36 MOCK_METHOD(std::string, ToString, (), (const, override)); 37 }; 38 39 class MockCustomAudioAnalyzer : public CustomAudioAnalyzer { 40 public: ~MockCustomAudioAnalyzer()41 virtual ~MockCustomAudioAnalyzer() {} 42 MOCK_METHOD(void, 43 Initialize, 44 (int sample_rate_hz, int num_channels), 45 (override)); 46 MOCK_METHOD(void, Analyze, (const AudioBuffer* audio), (override)); 47 MOCK_METHOD(std::string, ToString, (), (const, override)); 48 }; 49 50 class MockEchoControl : public EchoControl { 51 public: ~MockEchoControl()52 virtual ~MockEchoControl() {} 53 MOCK_METHOD(void, AnalyzeRender, (AudioBuffer * render), (override)); 54 MOCK_METHOD(void, AnalyzeCapture, (AudioBuffer * capture), (override)); 55 MOCK_METHOD(void, 56 ProcessCapture, 57 (AudioBuffer * capture, bool echo_path_change), 58 (override)); 59 MOCK_METHOD(void, 60 ProcessCapture, 61 (AudioBuffer * capture, 62 AudioBuffer* linear_output, 63 bool echo_path_change), 64 (override)); 65 MOCK_METHOD(Metrics, GetMetrics, (), (const, override)); 66 MOCK_METHOD(void, SetAudioBufferDelay, (int delay_ms), (override)); 67 MOCK_METHOD(bool, ActiveProcessing, (), (const, override)); 68 }; 69 70 class MockAudioProcessing : public ::testing::NiceMock<AudioProcessing> { 71 public: MockAudioProcessing()72 MockAudioProcessing() {} 73 ~MockAudioProcessing()74 virtual ~MockAudioProcessing() {} 75 76 MOCK_METHOD(int, Initialize, (), (override)); 77 MOCK_METHOD(int, 78 Initialize, 79 (int capture_input_sample_rate_hz, 80 int capture_output_sample_rate_hz, 81 int render_sample_rate_hz, 82 ChannelLayout capture_input_layout, 83 ChannelLayout capture_output_layout, 84 ChannelLayout render_input_layout), 85 (override)); 86 MOCK_METHOD(int, 87 Initialize, 88 (const ProcessingConfig& processing_config), 89 (override)); 90 MOCK_METHOD(void, ApplyConfig, (const Config& config), (override)); 91 MOCK_METHOD(void, 92 SetExtraOptions, 93 (const webrtc::Config& config), 94 (override)); 95 MOCK_METHOD(int, proc_sample_rate_hz, (), (const, override)); 96 MOCK_METHOD(int, proc_split_sample_rate_hz, (), (const, override)); 97 MOCK_METHOD(size_t, num_input_channels, (), (const, override)); 98 MOCK_METHOD(size_t, num_proc_channels, (), (const, override)); 99 MOCK_METHOD(size_t, num_output_channels, (), (const, override)); 100 MOCK_METHOD(size_t, num_reverse_channels, (), (const, override)); 101 MOCK_METHOD(void, set_output_will_be_muted, (bool muted), (override)); 102 MOCK_METHOD(void, SetRuntimeSetting, (RuntimeSetting setting), (override)); 103 MOCK_METHOD(int, 104 ProcessStream, 105 (const int16_t* const src, 106 const StreamConfig& input_config, 107 const StreamConfig& output_config, 108 int16_t* const dest), 109 (override)); 110 MOCK_METHOD(int, 111 ProcessStream, 112 (const float* const* src, 113 const StreamConfig& input_config, 114 const StreamConfig& output_config, 115 float* const* dest), 116 (override)); 117 MOCK_METHOD(int, 118 ProcessReverseStream, 119 (const int16_t* const src, 120 const StreamConfig& input_config, 121 const StreamConfig& output_config, 122 int16_t* const dest), 123 (override)); 124 MOCK_METHOD(int, 125 AnalyzeReverseStream, 126 (const float* const* data, const StreamConfig& reverse_config), 127 (override)); 128 MOCK_METHOD(int, 129 ProcessReverseStream, 130 (const float* const* src, 131 const StreamConfig& input_config, 132 const StreamConfig& output_config, 133 float* const* dest), 134 (override)); 135 MOCK_METHOD(bool, 136 GetLinearAecOutput, 137 ((rtc::ArrayView<std::array<float, 160>> linear_output)), 138 (const, override)); 139 MOCK_METHOD(int, set_stream_delay_ms, (int delay), (override)); 140 MOCK_METHOD(int, stream_delay_ms, (), (const, override)); 141 MOCK_METHOD(void, set_stream_key_pressed, (bool key_pressed), (override)); 142 MOCK_METHOD(void, set_stream_analog_level, (int), (override)); 143 MOCK_METHOD(int, recommended_stream_analog_level, (), (const, override)); 144 MOCK_METHOD(bool, 145 CreateAndAttachAecDump, 146 (const std::string& file_name, 147 int64_t max_log_size_bytes, 148 rtc::TaskQueue* worker_queue), 149 (override)); 150 MOCK_METHOD(bool, 151 CreateAndAttachAecDump, 152 (FILE * handle, 153 int64_t max_log_size_bytes, 154 rtc::TaskQueue* worker_queue), 155 (override)); 156 MOCK_METHOD(void, AttachAecDump, (std::unique_ptr<AecDump>), (override)); 157 MOCK_METHOD(void, DetachAecDump, (), (override)); 158 159 MOCK_METHOD(AudioProcessingStats, GetStatistics, (), (override)); 160 MOCK_METHOD(AudioProcessingStats, GetStatistics, (bool), (override)); 161 162 MOCK_METHOD(AudioProcessing::Config, GetConfig, (), (const, override)); 163 }; 164 165 } // namespace test 166 } // namespace webrtc 167 168 #endif // MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ 169