blob: 4a1fe626bd5d58b0b85e19e8d1b242f00341d048 [file] [log] [blame]
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +00001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
12#define MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000013
kwiberg88788ad2016-02-19 07:04:49 -080014#include <memory>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/audio_processing/include/aec_dump.h"
17#include "modules/audio_processing/include/audio_processing.h"
Ivo Creusen56d46092017-11-24 17:29:59 +010018#include "modules/audio_processing/include/audio_processing_statistics.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "test/gmock.h"
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000020
21namespace webrtc {
22
solenberg059fb442016-10-26 05:12:24 -070023namespace test {
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000024class MockGainControl : public GainControl {
25 public:
solenberg059fb442016-10-26 05:12:24 -070026 virtual ~MockGainControl() {}
27 MOCK_METHOD1(Enable, int(bool enable));
28 MOCK_CONST_METHOD0(is_enabled, bool());
29 MOCK_METHOD1(set_stream_analog_level, int(int level));
30 MOCK_METHOD0(stream_analog_level, int());
31 MOCK_METHOD1(set_mode, int(Mode mode));
32 MOCK_CONST_METHOD0(mode, Mode());
33 MOCK_METHOD1(set_target_level_dbfs, int(int level));
34 MOCK_CONST_METHOD0(target_level_dbfs, int());
35 MOCK_METHOD1(set_compression_gain_db, int(int gain));
36 MOCK_CONST_METHOD0(compression_gain_db, int());
37 MOCK_METHOD1(enable_limiter, int(bool enable));
38 MOCK_CONST_METHOD0(is_limiter_enabled, bool());
39 MOCK_METHOD2(set_analog_level_limits, int(int minimum, int maximum));
40 MOCK_CONST_METHOD0(analog_level_minimum, int());
41 MOCK_CONST_METHOD0(analog_level_maximum, int());
42 MOCK_CONST_METHOD0(stream_is_saturated, bool());
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000043};
44
45class MockHighPassFilter : public HighPassFilter {
46 public:
solenberg059fb442016-10-26 05:12:24 -070047 virtual ~MockHighPassFilter() {}
48 MOCK_METHOD1(Enable, int(bool enable));
49 MOCK_CONST_METHOD0(is_enabled, bool());
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000050};
51
52class MockLevelEstimator : public LevelEstimator {
53 public:
solenberg059fb442016-10-26 05:12:24 -070054 virtual ~MockLevelEstimator() {}
55 MOCK_METHOD1(Enable, int(bool enable));
56 MOCK_CONST_METHOD0(is_enabled, bool());
57 MOCK_METHOD0(RMS, int());
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000058};
59
60class MockNoiseSuppression : public NoiseSuppression {
61 public:
solenberg059fb442016-10-26 05:12:24 -070062 virtual ~MockNoiseSuppression() {}
63 MOCK_METHOD1(Enable, int(bool enable));
64 MOCK_CONST_METHOD0(is_enabled, bool());
65 MOCK_METHOD1(set_level, int(Level level));
66 MOCK_CONST_METHOD0(level, Level());
67 MOCK_CONST_METHOD0(speech_probability, float());
Alejandro Luebsfa639f02016-02-09 11:24:32 -080068 MOCK_METHOD0(NoiseEstimate, std::vector<float>());
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000069};
70
Alex Loiko5825aa62017-12-18 16:02:40 +010071class MockCustomProcessing : public CustomProcessing {
Sam Zackrisson0beac582017-09-25 12:04:02 +020072 public:
Alex Loiko5825aa62017-12-18 16:02:40 +010073 virtual ~MockCustomProcessing() {}
Sam Zackrisson0beac582017-09-25 12:04:02 +020074 MOCK_METHOD2(Initialize, void(int sample_rate_hz, int num_channels));
75 MOCK_METHOD1(Process, void(AudioBuffer* audio));
Alex Loiko73ec0192018-05-15 10:52:28 +020076 MOCK_METHOD1(SetRuntimeSetting,
77 void(AudioProcessing::RuntimeSetting setting));
Sam Zackrisson0beac582017-09-25 12:04:02 +020078 MOCK_CONST_METHOD0(ToString, std::string());
79};
80
Valeriia Nemychnikovaf06eb572018-08-29 10:37:09 +020081class MockCustomAudioAnalyzer : public CustomAudioAnalyzer {
82 public:
83 virtual ~MockCustomAudioAnalyzer() {}
84 MOCK_METHOD2(Initialize, void(int sample_rate_hz, int num_channels));
85 MOCK_METHOD1(Analyze, void(const AudioBuffer* audio));
86 MOCK_CONST_METHOD0(ToString, std::string());
87};
88
Gustaf Ullberg002ef282017-10-12 15:13:17 +020089class MockEchoControl : public EchoControl {
90 public:
91 virtual ~MockEchoControl() {}
92 MOCK_METHOD1(AnalyzeRender, void(AudioBuffer* render));
93 MOCK_METHOD1(AnalyzeCapture, void(AudioBuffer* capture));
94 MOCK_METHOD2(ProcessCapture,
95 void(AudioBuffer* capture, bool echo_path_change));
Gustaf Ullberg332150d2017-11-22 14:17:39 +010096 MOCK_CONST_METHOD0(GetMetrics, Metrics());
Per Ã…hgrend0fa8202018-04-18 09:35:13 +020097 MOCK_METHOD1(SetAudioBufferDelay, void(size_t delay_ms));
Gustaf Ullberg002ef282017-10-12 15:13:17 +020098};
99
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000100class MockVoiceDetection : public VoiceDetection {
101 public:
solenberg059fb442016-10-26 05:12:24 -0700102 virtual ~MockVoiceDetection() {}
103 MOCK_METHOD1(Enable, int(bool enable));
104 MOCK_CONST_METHOD0(is_enabled, bool());
105 MOCK_CONST_METHOD0(stream_has_voice, bool());
106 MOCK_METHOD1(set_stream_has_voice, int(bool has_voice));
107 MOCK_METHOD1(set_likelihood, int(Likelihood likelihood));
108 MOCK_CONST_METHOD0(likelihood, Likelihood());
109 MOCK_METHOD1(set_frame_size_ms, int(int size));
110 MOCK_CONST_METHOD0(frame_size_ms, int());
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000111};
112
Sebastian Jansson41f16be2018-02-22 11:09:56 +0100113class MockAudioProcessing : public testing::NiceMock<AudioProcessing> {
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000114 public:
115 MockAudioProcessing()
sazabe490b22018-10-03 17:03:13 +0200116 : gain_control_(new testing::NiceMock<MockGainControl>()),
solenberg059fb442016-10-26 05:12:24 -0700117 high_pass_filter_(new testing::NiceMock<MockHighPassFilter>()),
118 level_estimator_(new testing::NiceMock<MockLevelEstimator>()),
119 noise_suppression_(new testing::NiceMock<MockNoiseSuppression>()),
Yves Gerey665174f2018-06-19 15:03:05 +0200120 voice_detection_(new testing::NiceMock<MockVoiceDetection>()) {}
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000121
solenberg059fb442016-10-26 05:12:24 -0700122 virtual ~MockAudioProcessing() {}
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000123
solenberg059fb442016-10-26 05:12:24 -0700124 MOCK_METHOD0(Initialize, int());
Yves Gerey665174f2018-06-19 15:03:05 +0200125 MOCK_METHOD6(Initialize,
126 int(int capture_input_sample_rate_hz,
127 int capture_output_sample_rate_hz,
128 int render_sample_rate_hz,
129 ChannelLayout capture_input_layout,
130 ChannelLayout capture_output_layout,
131 ChannelLayout render_input_layout));
solenberg059fb442016-10-26 05:12:24 -0700132 MOCK_METHOD1(Initialize, int(const ProcessingConfig& processing_config));
peah88ac8532016-09-12 16:47:25 -0700133 MOCK_METHOD1(ApplyConfig, void(const Config& config));
134 MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config));
solenberg059fb442016-10-26 05:12:24 -0700135 MOCK_CONST_METHOD0(proc_sample_rate_hz, int());
136 MOCK_CONST_METHOD0(proc_split_sample_rate_hz, int());
137 MOCK_CONST_METHOD0(num_input_channels, size_t());
138 MOCK_CONST_METHOD0(num_proc_channels, size_t());
139 MOCK_CONST_METHOD0(num_output_channels, size_t());
140 MOCK_CONST_METHOD0(num_reverse_channels, size_t());
141 MOCK_METHOD1(set_output_will_be_muted, void(bool muted));
Alessio Bazzicac054e782018-04-16 12:10:09 +0200142 MOCK_METHOD1(SetRuntimeSetting, void(RuntimeSetting setting));
solenberg059fb442016-10-26 05:12:24 -0700143 MOCK_METHOD1(ProcessStream, int(AudioFrame* frame));
Yves Gerey665174f2018-06-19 15:03:05 +0200144 MOCK_METHOD7(ProcessStream,
145 int(const float* const* src,
146 size_t samples_per_channel,
147 int input_sample_rate_hz,
148 ChannelLayout input_layout,
149 int output_sample_rate_hz,
150 ChannelLayout output_layout,
151 float* const* dest));
152 MOCK_METHOD4(ProcessStream,
153 int(const float* const* src,
154 const StreamConfig& input_config,
155 const StreamConfig& output_config,
156 float* const* dest));
ekmeyerson60d9b332015-08-14 10:35:55 -0700157 MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame));
Yves Gerey665174f2018-06-19 15:03:05 +0200158 MOCK_METHOD4(AnalyzeReverseStream,
159 int(const float* const* data,
160 size_t samples_per_channel,
161 int sample_rate_hz,
162 ChannelLayout layout));
163 MOCK_METHOD4(ProcessReverseStream,
164 int(const float* const* src,
165 const StreamConfig& input_config,
166 const StreamConfig& output_config,
167 float* const* dest));
solenberg059fb442016-10-26 05:12:24 -0700168 MOCK_METHOD1(set_stream_delay_ms, int(int delay));
169 MOCK_CONST_METHOD0(stream_delay_ms, int());
170 MOCK_CONST_METHOD0(was_stream_delay_set, bool());
171 MOCK_METHOD1(set_stream_key_pressed, void(bool key_pressed));
172 MOCK_METHOD1(set_delay_offset_ms, void(int offset));
173 MOCK_CONST_METHOD0(delay_offset_ms, int());
aleloi868f32f2017-05-23 07:20:05 -0700174
175 virtual void AttachAecDump(std::unique_ptr<AecDump> aec_dump) {}
176 MOCK_METHOD0(DetachAecDump, void());
177
Sam Zackrisson4d364492018-03-02 16:03:21 +0100178 virtual void AttachPlayoutAudioGenerator(
179 std::unique_ptr<AudioGenerator> audio_generator) {}
180 MOCK_METHOD0(DetachPlayoutAudioGenerator, void());
181
Bjorn Volcker4e7aa432015-07-07 11:50:05 +0200182 MOCK_METHOD0(UpdateHistogramsOnCallEnd, void());
ivoc3e9a5372016-10-28 07:55:33 -0700183 MOCK_CONST_METHOD0(GetStatistics, AudioProcessingStatistics());
Ivo Creusen56d46092017-11-24 17:29:59 +0100184 MOCK_CONST_METHOD1(GetStatistics, AudioProcessingStats(bool));
Yves Gerey665174f2018-06-19 15:03:05 +0200185 virtual MockGainControl* gain_control() const { return gain_control_.get(); }
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000186 virtual MockHighPassFilter* high_pass_filter() const {
187 return high_pass_filter_.get();
andrew@webrtc.org17e40642014-03-04 20:58:13 +0000188 }
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000189 virtual MockLevelEstimator* level_estimator() const {
190 return level_estimator_.get();
andrew@webrtc.org17e40642014-03-04 20:58:13 +0000191 }
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000192 virtual MockNoiseSuppression* noise_suppression() const {
193 return noise_suppression_.get();
andrew@webrtc.org17e40642014-03-04 20:58:13 +0000194 }
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000195 virtual MockVoiceDetection* voice_detection() const {
196 return voice_detection_.get();
andrew@webrtc.org17e40642014-03-04 20:58:13 +0000197 }
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000198
henrik.lundinadf06352017-04-05 05:48:24 -0700199 MOCK_CONST_METHOD0(GetConfig, AudioProcessing::Config());
200
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000201 private:
kwiberg88788ad2016-02-19 07:04:49 -0800202 std::unique_ptr<MockGainControl> gain_control_;
203 std::unique_ptr<MockHighPassFilter> high_pass_filter_;
204 std::unique_ptr<MockLevelEstimator> level_estimator_;
205 std::unique_ptr<MockNoiseSuppression> noise_suppression_;
206 std::unique_ptr<MockVoiceDetection> voice_detection_;
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000207};
208
solenberg059fb442016-10-26 05:12:24 -0700209} // namespace test
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000210} // namespace webrtc
211
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200212#endif // MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_