andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 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 WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ |
| 13 | |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 16 | #include "webrtc/modules/audio_processing/include/aec_dump.h" |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 17 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 18 | #include "webrtc/test/gmock.h" |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 22 | namespace test { |
| 23 | |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 24 | class MockEchoCancellation : public EchoCancellation { |
| 25 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 26 | virtual ~MockEchoCancellation() {} |
| 27 | MOCK_METHOD1(Enable, int(bool enable)); |
| 28 | MOCK_CONST_METHOD0(is_enabled, bool()); |
| 29 | MOCK_METHOD1(enable_drift_compensation, int(bool enable)); |
| 30 | MOCK_CONST_METHOD0(is_drift_compensation_enabled, bool()); |
| 31 | MOCK_METHOD1(set_stream_drift_samples, void(int drift)); |
| 32 | MOCK_CONST_METHOD0(stream_drift_samples, int()); |
| 33 | MOCK_METHOD1(set_suppression_level, int(SuppressionLevel level)); |
| 34 | MOCK_CONST_METHOD0(suppression_level, SuppressionLevel()); |
| 35 | MOCK_CONST_METHOD0(stream_has_echo, bool()); |
| 36 | MOCK_METHOD1(enable_metrics, int(bool enable)); |
| 37 | MOCK_CONST_METHOD0(are_metrics_enabled, bool()); |
| 38 | MOCK_METHOD1(GetMetrics, int(Metrics* metrics)); |
| 39 | MOCK_METHOD1(enable_delay_logging, int(bool enable)); |
| 40 | MOCK_CONST_METHOD0(is_delay_logging_enabled, bool()); |
| 41 | MOCK_METHOD2(GetDelayMetrics, int(int* median, int* std)); |
| 42 | MOCK_METHOD3(GetDelayMetrics, int(int* median, int* std, |
| 43 | float* fraction_poor_delays)); |
| 44 | MOCK_CONST_METHOD0(aec_core, struct AecCore*()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | class MockEchoControlMobile : public EchoControlMobile { |
| 48 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 49 | virtual ~MockEchoControlMobile() {} |
| 50 | MOCK_METHOD1(Enable, int(bool enable)); |
| 51 | MOCK_CONST_METHOD0(is_enabled, bool()); |
| 52 | MOCK_METHOD1(set_routing_mode, int(RoutingMode mode)); |
| 53 | MOCK_CONST_METHOD0(routing_mode, RoutingMode()); |
| 54 | MOCK_METHOD1(enable_comfort_noise, int(bool enable)); |
| 55 | MOCK_CONST_METHOD0(is_comfort_noise_enabled, bool()); |
| 56 | MOCK_METHOD2(SetEchoPath, int(const void* echo_path, size_t size_bytes)); |
| 57 | MOCK_CONST_METHOD2(GetEchoPath, int(void* echo_path, size_t size_bytes)); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | class MockGainControl : public GainControl { |
| 61 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 62 | virtual ~MockGainControl() {} |
| 63 | MOCK_METHOD1(Enable, int(bool enable)); |
| 64 | MOCK_CONST_METHOD0(is_enabled, bool()); |
| 65 | MOCK_METHOD1(set_stream_analog_level, int(int level)); |
| 66 | MOCK_METHOD0(stream_analog_level, int()); |
| 67 | MOCK_METHOD1(set_mode, int(Mode mode)); |
| 68 | MOCK_CONST_METHOD0(mode, Mode()); |
| 69 | MOCK_METHOD1(set_target_level_dbfs, int(int level)); |
| 70 | MOCK_CONST_METHOD0(target_level_dbfs, int()); |
| 71 | MOCK_METHOD1(set_compression_gain_db, int(int gain)); |
| 72 | MOCK_CONST_METHOD0(compression_gain_db, int()); |
| 73 | MOCK_METHOD1(enable_limiter, int(bool enable)); |
| 74 | MOCK_CONST_METHOD0(is_limiter_enabled, bool()); |
| 75 | MOCK_METHOD2(set_analog_level_limits, int(int minimum, int maximum)); |
| 76 | MOCK_CONST_METHOD0(analog_level_minimum, int()); |
| 77 | MOCK_CONST_METHOD0(analog_level_maximum, int()); |
| 78 | MOCK_CONST_METHOD0(stream_is_saturated, bool()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | class MockHighPassFilter : public HighPassFilter { |
| 82 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 83 | virtual ~MockHighPassFilter() {} |
| 84 | MOCK_METHOD1(Enable, int(bool enable)); |
| 85 | MOCK_CONST_METHOD0(is_enabled, bool()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | class MockLevelEstimator : public LevelEstimator { |
| 89 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 90 | virtual ~MockLevelEstimator() {} |
| 91 | MOCK_METHOD1(Enable, int(bool enable)); |
| 92 | MOCK_CONST_METHOD0(is_enabled, bool()); |
| 93 | MOCK_METHOD0(RMS, int()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | class MockNoiseSuppression : public NoiseSuppression { |
| 97 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 98 | virtual ~MockNoiseSuppression() {} |
| 99 | MOCK_METHOD1(Enable, int(bool enable)); |
| 100 | MOCK_CONST_METHOD0(is_enabled, bool()); |
| 101 | MOCK_METHOD1(set_level, int(Level level)); |
| 102 | MOCK_CONST_METHOD0(level, Level()); |
| 103 | MOCK_CONST_METHOD0(speech_probability, float()); |
Alejandro Luebs | fa639f0 | 2016-02-09 11:24:32 -0800 | [diff] [blame] | 104 | MOCK_METHOD0(NoiseEstimate, std::vector<float>()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | class MockVoiceDetection : public VoiceDetection { |
| 108 | public: |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 109 | virtual ~MockVoiceDetection() {} |
| 110 | MOCK_METHOD1(Enable, int(bool enable)); |
| 111 | MOCK_CONST_METHOD0(is_enabled, bool()); |
| 112 | MOCK_CONST_METHOD0(stream_has_voice, bool()); |
| 113 | MOCK_METHOD1(set_stream_has_voice, int(bool has_voice)); |
| 114 | MOCK_METHOD1(set_likelihood, int(Likelihood likelihood)); |
| 115 | MOCK_CONST_METHOD0(likelihood, Likelihood()); |
| 116 | MOCK_METHOD1(set_frame_size_ms, int(int size)); |
| 117 | MOCK_CONST_METHOD0(frame_size_ms, int()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | class MockAudioProcessing : public AudioProcessing { |
| 121 | public: |
| 122 | MockAudioProcessing() |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 123 | : echo_cancellation_(new testing::NiceMock<MockEchoCancellation>()), |
| 124 | echo_control_mobile_(new testing::NiceMock<MockEchoControlMobile>()), |
| 125 | gain_control_(new testing::NiceMock<MockGainControl>()), |
| 126 | high_pass_filter_(new testing::NiceMock<MockHighPassFilter>()), |
| 127 | level_estimator_(new testing::NiceMock<MockLevelEstimator>()), |
| 128 | noise_suppression_(new testing::NiceMock<MockNoiseSuppression>()), |
| 129 | voice_detection_(new testing::NiceMock<MockVoiceDetection>()) { |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 130 | } |
| 131 | |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 132 | virtual ~MockAudioProcessing() {} |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 133 | |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 134 | MOCK_METHOD0(Initialize, int()); |
| 135 | MOCK_METHOD6(Initialize, int(int capture_input_sample_rate_hz, |
| 136 | int capture_output_sample_rate_hz, |
| 137 | int render_sample_rate_hz, |
| 138 | ChannelLayout capture_input_layout, |
| 139 | ChannelLayout capture_output_layout, |
| 140 | ChannelLayout render_input_layout)); |
| 141 | MOCK_METHOD1(Initialize, int(const ProcessingConfig& processing_config)); |
peah | 88ac853 | 2016-09-12 16:47:25 -0700 | [diff] [blame] | 142 | MOCK_METHOD1(ApplyConfig, void(const Config& config)); |
| 143 | MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config)); |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 144 | MOCK_CONST_METHOD0(proc_sample_rate_hz, int()); |
| 145 | MOCK_CONST_METHOD0(proc_split_sample_rate_hz, int()); |
| 146 | MOCK_CONST_METHOD0(num_input_channels, size_t()); |
| 147 | MOCK_CONST_METHOD0(num_proc_channels, size_t()); |
| 148 | MOCK_CONST_METHOD0(num_output_channels, size_t()); |
| 149 | MOCK_CONST_METHOD0(num_reverse_channels, size_t()); |
| 150 | MOCK_METHOD1(set_output_will_be_muted, void(bool muted)); |
| 151 | MOCK_METHOD1(ProcessStream, int(AudioFrame* frame)); |
| 152 | MOCK_METHOD7(ProcessStream, int(const float* const* src, |
| 153 | size_t samples_per_channel, |
| 154 | int input_sample_rate_hz, |
| 155 | ChannelLayout input_layout, |
| 156 | int output_sample_rate_hz, |
| 157 | ChannelLayout output_layout, |
| 158 | float* const* dest)); |
| 159 | MOCK_METHOD4(ProcessStream, int(const float* const* src, |
| 160 | const StreamConfig& input_config, |
| 161 | const StreamConfig& output_config, |
| 162 | float* const* dest)); |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 163 | MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame)); |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 164 | MOCK_METHOD4(AnalyzeReverseStream, int(const float* const* data, |
| 165 | size_t samples_per_channel, |
| 166 | int sample_rate_hz, |
| 167 | ChannelLayout layout)); |
| 168 | MOCK_METHOD4(ProcessReverseStream, int(const float* const* src, |
| 169 | const StreamConfig& input_config, |
| 170 | const StreamConfig& output_config, |
| 171 | float* const* dest)); |
| 172 | MOCK_METHOD1(set_stream_delay_ms, int(int delay)); |
| 173 | MOCK_CONST_METHOD0(stream_delay_ms, int()); |
| 174 | MOCK_CONST_METHOD0(was_stream_delay_set, bool()); |
| 175 | MOCK_METHOD1(set_stream_key_pressed, void(bool key_pressed)); |
| 176 | MOCK_METHOD1(set_delay_offset_ms, void(int offset)); |
| 177 | MOCK_CONST_METHOD0(delay_offset_ms, int()); |
aleloi | 868f32f | 2017-05-23 07:20:05 -0700 | [diff] [blame] | 178 | |
| 179 | virtual void AttachAecDump(std::unique_ptr<AecDump> aec_dump) {} |
| 180 | MOCK_METHOD0(DetachAecDump, void()); |
| 181 | |
Bjorn Volcker | 4e7aa43 | 2015-07-07 11:50:05 +0200 | [diff] [blame] | 182 | MOCK_METHOD0(UpdateHistogramsOnCallEnd, void()); |
ivoc | 3e9a537 | 2016-10-28 07:55:33 -0700 | [diff] [blame] | 183 | MOCK_CONST_METHOD0(GetStatistics, AudioProcessingStatistics()); |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 184 | virtual MockEchoCancellation* echo_cancellation() const { |
| 185 | return echo_cancellation_.get(); |
| 186 | } |
| 187 | virtual MockEchoControlMobile* echo_control_mobile() const { |
| 188 | return echo_control_mobile_.get(); |
| 189 | } |
| 190 | virtual MockGainControl* gain_control() const { |
| 191 | return gain_control_.get(); |
| 192 | } |
| 193 | virtual MockHighPassFilter* high_pass_filter() const { |
| 194 | return high_pass_filter_.get(); |
andrew@webrtc.org | 17e4064 | 2014-03-04 20:58:13 +0000 | [diff] [blame] | 195 | } |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 196 | virtual MockLevelEstimator* level_estimator() const { |
| 197 | return level_estimator_.get(); |
andrew@webrtc.org | 17e4064 | 2014-03-04 20:58:13 +0000 | [diff] [blame] | 198 | } |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 199 | virtual MockNoiseSuppression* noise_suppression() const { |
| 200 | return noise_suppression_.get(); |
andrew@webrtc.org | 17e4064 | 2014-03-04 20:58:13 +0000 | [diff] [blame] | 201 | } |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 202 | virtual MockVoiceDetection* voice_detection() const { |
| 203 | return voice_detection_.get(); |
andrew@webrtc.org | 17e4064 | 2014-03-04 20:58:13 +0000 | [diff] [blame] | 204 | } |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 205 | |
henrik.lundin | adf0635 | 2017-04-05 05:48:24 -0700 | [diff] [blame] | 206 | MOCK_CONST_METHOD0(GetConfig, AudioProcessing::Config()); |
| 207 | |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 208 | private: |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 209 | std::unique_ptr<MockEchoCancellation> echo_cancellation_; |
| 210 | std::unique_ptr<MockEchoControlMobile> echo_control_mobile_; |
| 211 | std::unique_ptr<MockGainControl> gain_control_; |
| 212 | std::unique_ptr<MockHighPassFilter> high_pass_filter_; |
| 213 | std::unique_ptr<MockLevelEstimator> level_estimator_; |
| 214 | std::unique_ptr<MockNoiseSuppression> noise_suppression_; |
| 215 | std::unique_ptr<MockVoiceDetection> voice_detection_; |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 216 | }; |
| 217 | |
solenberg | 059fb44 | 2016-10-26 05:12:24 -0700 | [diff] [blame] | 218 | } // namespace test |
andrew@webrtc.org | c83a00a | 2013-03-25 21:20:38 +0000 | [diff] [blame] | 219 | } // namespace webrtc |
| 220 | |
| 221 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_ |