OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 16 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 17 #include "webrtc/test/gmock.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
| 21 namespace test { |
| 22 |
20 class MockEchoCancellation : public EchoCancellation { | 23 class MockEchoCancellation : public EchoCancellation { |
21 public: | 24 public: |
22 MOCK_METHOD1(Enable, | 25 virtual ~MockEchoCancellation() {} |
23 int(bool enable)); | 26 MOCK_METHOD1(Enable, int(bool enable)); |
24 MOCK_CONST_METHOD0(is_enabled, | 27 MOCK_CONST_METHOD0(is_enabled, bool()); |
25 bool()); | 28 MOCK_METHOD1(enable_drift_compensation, int(bool enable)); |
26 MOCK_METHOD1(enable_drift_compensation, | 29 MOCK_CONST_METHOD0(is_drift_compensation_enabled, bool()); |
27 int(bool enable)); | 30 MOCK_METHOD1(set_stream_drift_samples, void(int drift)); |
28 MOCK_CONST_METHOD0(is_drift_compensation_enabled, | 31 MOCK_CONST_METHOD0(stream_drift_samples, int()); |
29 bool()); | 32 MOCK_METHOD1(set_suppression_level, int(SuppressionLevel level)); |
30 MOCK_METHOD1(set_stream_drift_samples, | 33 MOCK_CONST_METHOD0(suppression_level, SuppressionLevel()); |
31 void(int drift)); | 34 MOCK_CONST_METHOD0(stream_has_echo, bool()); |
32 MOCK_CONST_METHOD0(stream_drift_samples, | 35 MOCK_METHOD1(enable_metrics, int(bool enable)); |
33 int()); | 36 MOCK_CONST_METHOD0(are_metrics_enabled, bool()); |
34 MOCK_METHOD1(set_suppression_level, | 37 MOCK_METHOD1(GetMetrics, int(Metrics* metrics)); |
35 int(SuppressionLevel level)); | 38 MOCK_METHOD1(enable_delay_logging, int(bool enable)); |
36 MOCK_CONST_METHOD0(suppression_level, | 39 MOCK_CONST_METHOD0(is_delay_logging_enabled, bool()); |
37 SuppressionLevel()); | 40 MOCK_METHOD2(GetDelayMetrics, int(int* median, int* std)); |
38 MOCK_CONST_METHOD0(stream_has_echo, | 41 MOCK_METHOD3(GetDelayMetrics, int(int* median, int* std, |
39 bool()); | 42 float* fraction_poor_delays)); |
40 MOCK_METHOD1(enable_metrics, | 43 MOCK_CONST_METHOD0(aec_core, struct AecCore*()); |
41 int(bool enable)); | |
42 MOCK_CONST_METHOD0(are_metrics_enabled, | |
43 bool()); | |
44 MOCK_METHOD1(GetMetrics, | |
45 int(Metrics* metrics)); | |
46 MOCK_METHOD1(enable_delay_logging, | |
47 int(bool enable)); | |
48 MOCK_CONST_METHOD0(is_delay_logging_enabled, | |
49 bool()); | |
50 MOCK_METHOD2(GetDelayMetrics, | |
51 int(int* median, int* std)); | |
52 MOCK_METHOD3(GetDelayMetrics, | |
53 int(int* median, int* std, float* fraction_poor_delays)); | |
54 MOCK_CONST_METHOD0(aec_core, | |
55 struct AecCore*()); | |
56 }; | 44 }; |
57 | 45 |
58 class MockEchoControlMobile : public EchoControlMobile { | 46 class MockEchoControlMobile : public EchoControlMobile { |
59 public: | 47 public: |
60 MOCK_METHOD1(Enable, | 48 virtual ~MockEchoControlMobile() {} |
61 int(bool enable)); | 49 MOCK_METHOD1(Enable, int(bool enable)); |
62 MOCK_CONST_METHOD0(is_enabled, | 50 MOCK_CONST_METHOD0(is_enabled, bool()); |
63 bool()); | 51 MOCK_METHOD1(set_routing_mode, int(RoutingMode mode)); |
64 MOCK_METHOD1(set_routing_mode, | 52 MOCK_CONST_METHOD0(routing_mode, RoutingMode()); |
65 int(RoutingMode mode)); | 53 MOCK_METHOD1(enable_comfort_noise, int(bool enable)); |
66 MOCK_CONST_METHOD0(routing_mode, | 54 MOCK_CONST_METHOD0(is_comfort_noise_enabled, bool()); |
67 RoutingMode()); | 55 MOCK_METHOD2(SetEchoPath, int(const void* echo_path, size_t size_bytes)); |
68 MOCK_METHOD1(enable_comfort_noise, | 56 MOCK_CONST_METHOD2(GetEchoPath, int(void* echo_path, size_t size_bytes)); |
69 int(bool enable)); | |
70 MOCK_CONST_METHOD0(is_comfort_noise_enabled, | |
71 bool()); | |
72 MOCK_METHOD2(SetEchoPath, | |
73 int(const void* echo_path, size_t size_bytes)); | |
74 MOCK_CONST_METHOD2(GetEchoPath, | |
75 int(void* echo_path, size_t size_bytes)); | |
76 }; | 57 }; |
77 | 58 |
78 class MockGainControl : public GainControl { | 59 class MockGainControl : public GainControl { |
79 public: | 60 public: |
80 MOCK_METHOD1(Enable, | 61 virtual ~MockGainControl() {} |
81 int(bool enable)); | 62 MOCK_METHOD1(Enable, int(bool enable)); |
82 MOCK_CONST_METHOD0(is_enabled, | 63 MOCK_CONST_METHOD0(is_enabled, bool()); |
83 bool()); | 64 MOCK_METHOD1(set_stream_analog_level, int(int level)); |
84 MOCK_METHOD1(set_stream_analog_level, | 65 MOCK_METHOD0(stream_analog_level, int()); |
85 int(int level)); | 66 MOCK_METHOD1(set_mode, int(Mode mode)); |
86 MOCK_METHOD0(stream_analog_level, | 67 MOCK_CONST_METHOD0(mode, Mode()); |
87 int()); | 68 MOCK_METHOD1(set_target_level_dbfs, int(int level)); |
88 MOCK_METHOD1(set_mode, | 69 MOCK_CONST_METHOD0(target_level_dbfs, int()); |
89 int(Mode mode)); | 70 MOCK_METHOD1(set_compression_gain_db, int(int gain)); |
90 MOCK_CONST_METHOD0(mode, | 71 MOCK_CONST_METHOD0(compression_gain_db, int()); |
91 Mode()); | 72 MOCK_METHOD1(enable_limiter, int(bool enable)); |
92 MOCK_METHOD1(set_target_level_dbfs, | 73 MOCK_CONST_METHOD0(is_limiter_enabled, bool()); |
93 int(int level)); | 74 MOCK_METHOD2(set_analog_level_limits, int(int minimum, int maximum)); |
94 MOCK_CONST_METHOD0(target_level_dbfs, | 75 MOCK_CONST_METHOD0(analog_level_minimum, int()); |
95 int()); | 76 MOCK_CONST_METHOD0(analog_level_maximum, int()); |
96 MOCK_METHOD1(set_compression_gain_db, | 77 MOCK_CONST_METHOD0(stream_is_saturated, bool()); |
97 int(int gain)); | |
98 MOCK_CONST_METHOD0(compression_gain_db, | |
99 int()); | |
100 MOCK_METHOD1(enable_limiter, | |
101 int(bool enable)); | |
102 MOCK_CONST_METHOD0(is_limiter_enabled, | |
103 bool()); | |
104 MOCK_METHOD2(set_analog_level_limits, | |
105 int(int minimum, int maximum)); | |
106 MOCK_CONST_METHOD0(analog_level_minimum, | |
107 int()); | |
108 MOCK_CONST_METHOD0(analog_level_maximum, | |
109 int()); | |
110 MOCK_CONST_METHOD0(stream_is_saturated, | |
111 bool()); | |
112 }; | 78 }; |
113 | 79 |
114 class MockHighPassFilter : public HighPassFilter { | 80 class MockHighPassFilter : public HighPassFilter { |
115 public: | 81 public: |
116 MOCK_METHOD1(Enable, | 82 virtual ~MockHighPassFilter() {} |
117 int(bool enable)); | 83 MOCK_METHOD1(Enable, int(bool enable)); |
118 MOCK_CONST_METHOD0(is_enabled, | 84 MOCK_CONST_METHOD0(is_enabled, bool()); |
119 bool()); | |
120 }; | 85 }; |
121 | 86 |
122 class MockLevelEstimator : public LevelEstimator { | 87 class MockLevelEstimator : public LevelEstimator { |
123 public: | 88 public: |
124 MOCK_METHOD1(Enable, | 89 virtual ~MockLevelEstimator() {} |
125 int(bool enable)); | 90 MOCK_METHOD1(Enable, int(bool enable)); |
126 MOCK_CONST_METHOD0(is_enabled, | 91 MOCK_CONST_METHOD0(is_enabled, bool()); |
127 bool()); | 92 MOCK_METHOD0(RMS, int()); |
128 MOCK_METHOD0(RMS, | |
129 int()); | |
130 }; | 93 }; |
131 | 94 |
132 class MockNoiseSuppression : public NoiseSuppression { | 95 class MockNoiseSuppression : public NoiseSuppression { |
133 public: | 96 public: |
134 MOCK_METHOD1(Enable, | 97 virtual ~MockNoiseSuppression() {} |
135 int(bool enable)); | 98 MOCK_METHOD1(Enable, int(bool enable)); |
136 MOCK_CONST_METHOD0(is_enabled, | 99 MOCK_CONST_METHOD0(is_enabled, bool()); |
137 bool()); | 100 MOCK_METHOD1(set_level, int(Level level)); |
138 MOCK_METHOD1(set_level, | 101 MOCK_CONST_METHOD0(level, Level()); |
139 int(Level level)); | 102 MOCK_CONST_METHOD0(speech_probability, float()); |
140 MOCK_CONST_METHOD0(level, | |
141 Level()); | |
142 MOCK_CONST_METHOD0(speech_probability, | |
143 float()); | |
144 MOCK_METHOD0(NoiseEstimate, std::vector<float>()); | 103 MOCK_METHOD0(NoiseEstimate, std::vector<float>()); |
145 }; | 104 }; |
146 | 105 |
147 class MockVoiceDetection : public VoiceDetection { | 106 class MockVoiceDetection : public VoiceDetection { |
148 public: | 107 public: |
149 MOCK_METHOD1(Enable, | 108 virtual ~MockVoiceDetection() {} |
150 int(bool enable)); | 109 MOCK_METHOD1(Enable, int(bool enable)); |
151 MOCK_CONST_METHOD0(is_enabled, | 110 MOCK_CONST_METHOD0(is_enabled, bool()); |
152 bool()); | 111 MOCK_CONST_METHOD0(stream_has_voice, bool()); |
153 MOCK_CONST_METHOD0(stream_has_voice, | 112 MOCK_METHOD1(set_stream_has_voice, int(bool has_voice)); |
154 bool()); | 113 MOCK_METHOD1(set_likelihood, int(Likelihood likelihood)); |
155 MOCK_METHOD1(set_stream_has_voice, | 114 MOCK_CONST_METHOD0(likelihood, Likelihood()); |
156 int(bool has_voice)); | 115 MOCK_METHOD1(set_frame_size_ms, int(int size)); |
157 MOCK_METHOD1(set_likelihood, | 116 MOCK_CONST_METHOD0(frame_size_ms, int()); |
158 int(Likelihood likelihood)); | |
159 MOCK_CONST_METHOD0(likelihood, | |
160 Likelihood()); | |
161 MOCK_METHOD1(set_frame_size_ms, | |
162 int(int size)); | |
163 MOCK_CONST_METHOD0(frame_size_ms, | |
164 int()); | |
165 }; | 117 }; |
166 | 118 |
167 class MockAudioProcessing : public AudioProcessing { | 119 class MockAudioProcessing : public AudioProcessing { |
168 public: | 120 public: |
169 MockAudioProcessing() | 121 MockAudioProcessing() |
170 : echo_cancellation_(new MockEchoCancellation), | 122 : echo_cancellation_(new testing::NiceMock<MockEchoCancellation>()), |
171 echo_control_mobile_(new MockEchoControlMobile), | 123 echo_control_mobile_(new testing::NiceMock<MockEchoControlMobile>()), |
172 gain_control_(new MockGainControl), | 124 gain_control_(new testing::NiceMock<MockGainControl>()), |
173 high_pass_filter_(new MockHighPassFilter), | 125 high_pass_filter_(new testing::NiceMock<MockHighPassFilter>()), |
174 level_estimator_(new MockLevelEstimator), | 126 level_estimator_(new testing::NiceMock<MockLevelEstimator>()), |
175 noise_suppression_(new MockNoiseSuppression), | 127 noise_suppression_(new testing::NiceMock<MockNoiseSuppression>()), |
176 voice_detection_(new MockVoiceDetection) { | 128 voice_detection_(new testing::NiceMock<MockVoiceDetection>()) { |
177 } | 129 } |
178 | 130 |
179 virtual ~MockAudioProcessing() { | 131 virtual ~MockAudioProcessing() {} |
180 } | |
181 | 132 |
182 MOCK_METHOD0(Initialize, | 133 MOCK_METHOD0(Initialize, int()); |
183 int()); | 134 MOCK_METHOD6(Initialize, int(int capture_input_sample_rate_hz, |
184 MOCK_METHOD6(Initialize, | 135 int capture_output_sample_rate_hz, |
185 int(int capture_input_sample_rate_hz, | 136 int render_sample_rate_hz, |
186 int capture_output_sample_rate_hz, | 137 ChannelLayout capture_input_layout, |
187 int render_sample_rate_hz, | 138 ChannelLayout capture_output_layout, |
188 ChannelLayout capture_input_layout, | 139 ChannelLayout render_input_layout)); |
189 ChannelLayout capture_output_layout, | 140 MOCK_METHOD1(Initialize, int(const ProcessingConfig& processing_config)); |
190 ChannelLayout render_input_layout)); | |
191 MOCK_METHOD1(Initialize, | |
192 int(const ProcessingConfig& processing_config)); | |
193 MOCK_METHOD1(ApplyConfig, void(const Config& config)); | 141 MOCK_METHOD1(ApplyConfig, void(const Config& config)); |
194 MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config)); | 142 MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config)); |
195 MOCK_METHOD1(set_sample_rate_hz, | 143 MOCK_CONST_METHOD0(proc_sample_rate_hz, int()); |
196 int(int rate)); | 144 MOCK_CONST_METHOD0(proc_split_sample_rate_hz, int()); |
197 MOCK_CONST_METHOD0(input_sample_rate_hz, | 145 MOCK_CONST_METHOD0(num_input_channels, size_t()); |
198 int()); | 146 MOCK_CONST_METHOD0(num_proc_channels, size_t()); |
199 MOCK_CONST_METHOD0(sample_rate_hz, | 147 MOCK_CONST_METHOD0(num_output_channels, size_t()); |
200 int()); | 148 MOCK_CONST_METHOD0(num_reverse_channels, size_t()); |
201 MOCK_CONST_METHOD0(proc_sample_rate_hz, | 149 MOCK_METHOD1(set_output_will_be_muted, void(bool muted)); |
202 int()); | 150 MOCK_METHOD1(ProcessStream, int(AudioFrame* frame)); |
203 MOCK_CONST_METHOD0(proc_split_sample_rate_hz, | 151 MOCK_METHOD7(ProcessStream, int(const float* const* src, |
204 int()); | 152 size_t samples_per_channel, |
205 MOCK_CONST_METHOD0(num_input_channels, | 153 int input_sample_rate_hz, |
206 size_t()); | 154 ChannelLayout input_layout, |
207 MOCK_CONST_METHOD0(num_output_channels, | 155 int output_sample_rate_hz, |
208 size_t()); | 156 ChannelLayout output_layout, |
209 MOCK_CONST_METHOD0(num_reverse_channels, | 157 float* const* dest)); |
210 size_t()); | 158 MOCK_METHOD4(ProcessStream, int(const float* const* src, |
211 MOCK_METHOD1(set_output_will_be_muted, | 159 const StreamConfig& input_config, |
212 void(bool muted)); | 160 const StreamConfig& output_config, |
213 MOCK_CONST_METHOD0(output_will_be_muted, | 161 float* const* dest)); |
214 bool()); | |
215 MOCK_METHOD1(ProcessStream, | |
216 int(AudioFrame* frame)); | |
217 MOCK_METHOD7(ProcessStream, | |
218 int(const float* const* src, | |
219 size_t samples_per_channel, | |
220 int input_sample_rate_hz, | |
221 ChannelLayout input_layout, | |
222 int output_sample_rate_hz, | |
223 ChannelLayout output_layout, | |
224 float* const* dest)); | |
225 MOCK_METHOD4(ProcessStream, | |
226 int(const float* const* src, | |
227 const StreamConfig& input_config, | |
228 const StreamConfig& output_config, | |
229 float* const* dest)); | |
230 MOCK_METHOD1(AnalyzeReverseStream, | |
231 int(AudioFrame* frame)); | |
232 MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame)); | 162 MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame)); |
233 MOCK_METHOD4(AnalyzeReverseStream, | 163 MOCK_METHOD4(AnalyzeReverseStream, int(const float* const* data, |
234 int(const float* const* data, | 164 size_t samples_per_channel, |
235 size_t samples_per_channel, | 165 int sample_rate_hz, |
236 int sample_rate_hz, | 166 ChannelLayout layout)); |
237 ChannelLayout layout)); | 167 MOCK_METHOD4(ProcessReverseStream, int(const float* const* src, |
238 MOCK_METHOD4(ProcessReverseStream, | 168 const StreamConfig& input_config, |
239 int(const float* const* src, | 169 const StreamConfig& output_config, |
240 const StreamConfig& input_config, | 170 float* const* dest)); |
241 const StreamConfig& output_config, | 171 MOCK_METHOD1(set_stream_delay_ms, int(int delay)); |
242 float* const* dest)); | 172 MOCK_CONST_METHOD0(stream_delay_ms, int()); |
243 MOCK_METHOD1(set_stream_delay_ms, | 173 MOCK_CONST_METHOD0(was_stream_delay_set, bool()); |
244 int(int delay)); | 174 MOCK_METHOD1(set_stream_key_pressed, void(bool key_pressed)); |
245 MOCK_CONST_METHOD0(stream_delay_ms, | 175 MOCK_METHOD1(set_delay_offset_ms, void(int offset)); |
246 int()); | 176 MOCK_CONST_METHOD0(delay_offset_ms, int()); |
247 MOCK_CONST_METHOD0(was_stream_delay_set, | 177 MOCK_METHOD2(StartDebugRecording, int(const char filename[kMaxFilenameSize], |
248 bool()); | 178 int64_t max_log_size_bytes)); |
249 MOCK_METHOD1(set_stream_key_pressed, | 179 MOCK_METHOD2(StartDebugRecording, int(FILE* handle, |
250 void(bool key_pressed)); | 180 int64_t max_log_size_bytes)); |
251 MOCK_CONST_METHOD0(stream_key_pressed, | 181 MOCK_METHOD1(StartDebugRecording, int (FILE* handle)); |
252 bool()); | 182 MOCK_METHOD1(StartDebugRecordingForPlatformFile, |
253 MOCK_METHOD1(set_delay_offset_ms, | |
254 void(int offset)); | |
255 MOCK_CONST_METHOD0(delay_offset_ms, | |
256 int()); | |
257 MOCK_METHOD2(StartDebugRecording, | |
258 int(const char filename[kMaxFilenameSize], | |
259 int64_t max_log_size_bytes)); | |
260 MOCK_METHOD2(StartDebugRecording, | |
261 int(FILE* handle, int64_t max_log_size_bytes)); | |
262 MOCK_METHOD1(StartDebugRecording, | |
263 int (FILE* handle)); | |
264 MOCK_METHOD1(StartDebugRecording, | |
265 int(rtc::PlatformFile handle)); | 183 int(rtc::PlatformFile handle)); |
266 MOCK_METHOD0(StopDebugRecording, | 184 MOCK_METHOD0(StopDebugRecording, int()); |
267 int()); | |
268 MOCK_METHOD0(UpdateHistogramsOnCallEnd, void()); | 185 MOCK_METHOD0(UpdateHistogramsOnCallEnd, void()); |
269 virtual MockEchoCancellation* echo_cancellation() const { | 186 virtual MockEchoCancellation* echo_cancellation() const { |
270 return echo_cancellation_.get(); | 187 return echo_cancellation_.get(); |
271 } | 188 } |
272 virtual MockEchoControlMobile* echo_control_mobile() const { | 189 virtual MockEchoControlMobile* echo_control_mobile() const { |
273 return echo_control_mobile_.get(); | 190 return echo_control_mobile_.get(); |
274 } | 191 } |
275 virtual MockGainControl* gain_control() const { | 192 virtual MockGainControl* gain_control() const { |
276 return gain_control_.get(); | 193 return gain_control_.get(); |
277 } | 194 } |
(...skipping 13 matching lines...) Expand all Loading... |
291 private: | 208 private: |
292 std::unique_ptr<MockEchoCancellation> echo_cancellation_; | 209 std::unique_ptr<MockEchoCancellation> echo_cancellation_; |
293 std::unique_ptr<MockEchoControlMobile> echo_control_mobile_; | 210 std::unique_ptr<MockEchoControlMobile> echo_control_mobile_; |
294 std::unique_ptr<MockGainControl> gain_control_; | 211 std::unique_ptr<MockGainControl> gain_control_; |
295 std::unique_ptr<MockHighPassFilter> high_pass_filter_; | 212 std::unique_ptr<MockHighPassFilter> high_pass_filter_; |
296 std::unique_ptr<MockLevelEstimator> level_estimator_; | 213 std::unique_ptr<MockLevelEstimator> level_estimator_; |
297 std::unique_ptr<MockNoiseSuppression> noise_suppression_; | 214 std::unique_ptr<MockNoiseSuppression> noise_suppression_; |
298 std::unique_ptr<MockVoiceDetection> voice_detection_; | 215 std::unique_ptr<MockVoiceDetection> voice_detection_; |
299 }; | 216 }; |
300 | 217 |
| 218 } // namespace test |
301 } // namespace webrtc | 219 } // namespace webrtc |
302 | 220 |
303 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ | 221 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ |
OLD | NEW |