Fredrik Solenberg | 0ccae13 | 2015-11-03 10:15:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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_AUDIO_MOCK_VOICE_ENGINE_H_ |
| 12 | #define WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
| 13 | |
| 14 | #include "testing/gmock/include/gmock/gmock.h" |
| 15 | #include "webrtc/voice_engine/voice_engine_impl.h" |
| 16 | |
| 17 | namespace webrtc { |
| 18 | namespace test { |
| 19 | |
| 20 | // NOTE: This class inherits from VoiceEngineImpl so that its clients will be |
| 21 | // able to get the various interfaces as usual, via T::GetInterface(). |
solenberg | 3a94154 | 2015-11-16 07:34:50 -0800 | [diff] [blame^] | 22 | class MockVoiceEngine : public VoiceEngineImpl { |
Fredrik Solenberg | 0ccae13 | 2015-11-03 10:15:49 +0100 | [diff] [blame] | 23 | public: |
| 24 | MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { |
| 25 | // Increase ref count so this object isn't automatically deleted whenever |
| 26 | // interfaces are Release():d. |
| 27 | ++_ref_count; |
| 28 | } |
| 29 | ~MockVoiceEngine() override { |
| 30 | // Decrease ref count before base class d-tor is called; otherwise it will |
| 31 | // trigger an assertion. |
| 32 | --_ref_count; |
| 33 | } |
| 34 | |
| 35 | // VoEAudioProcessing |
| 36 | MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); |
| 37 | MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); |
| 38 | MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); |
| 39 | MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); |
| 40 | MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); |
| 41 | MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); |
| 42 | MOCK_METHOD2(SetEcStatus, int(bool enable, EcModes mode)); |
| 43 | MOCK_METHOD2(GetEcStatus, int(bool& enabled, EcModes& mode)); |
| 44 | MOCK_METHOD1(EnableDriftCompensation, int(bool enable)); |
| 45 | MOCK_METHOD0(DriftCompensationEnabled, bool()); |
| 46 | MOCK_METHOD1(SetDelayOffsetMs, void(int offset)); |
| 47 | MOCK_METHOD0(DelayOffsetMs, int()); |
| 48 | MOCK_METHOD2(SetAecmMode, int(AecmModes mode, bool enableCNG)); |
| 49 | MOCK_METHOD2(GetAecmMode, int(AecmModes& mode, bool& enabledCNG)); |
| 50 | MOCK_METHOD1(EnableHighPassFilter, int(bool enable)); |
| 51 | MOCK_METHOD0(IsHighPassFilterEnabled, bool()); |
| 52 | MOCK_METHOD3(SetRxNsStatus, int(int channel, bool enable, NsModes mode)); |
| 53 | MOCK_METHOD3(GetRxNsStatus, int(int channel, bool& enabled, NsModes& mode)); |
| 54 | MOCK_METHOD3(SetRxAgcStatus, int(int channel, bool enable, AgcModes mode)); |
| 55 | MOCK_METHOD3(GetRxAgcStatus, int(int channel, bool& enabled, AgcModes& mode)); |
| 56 | MOCK_METHOD2(SetRxAgcConfig, int(int channel, AgcConfig config)); |
| 57 | MOCK_METHOD2(GetRxAgcConfig, int(int channel, AgcConfig& config)); |
| 58 | MOCK_METHOD2(RegisterRxVadObserver, |
| 59 | int(int channel, VoERxVadCallback& observer)); |
| 60 | MOCK_METHOD1(DeRegisterRxVadObserver, int(int channel)); |
| 61 | MOCK_METHOD1(VoiceActivityIndicator, int(int channel)); |
| 62 | MOCK_METHOD1(SetEcMetricsStatus, int(bool enable)); |
| 63 | MOCK_METHOD1(GetEcMetricsStatus, int(bool& enabled)); |
| 64 | MOCK_METHOD4(GetEchoMetrics, int(int& ERL, int& ERLE, int& RERL, int& A_NLP)); |
| 65 | MOCK_METHOD3(GetEcDelayMetrics, |
| 66 | int(int& delay_median, |
| 67 | int& delay_std, |
| 68 | float& fraction_poor_delays)); |
| 69 | MOCK_METHOD1(StartDebugRecording, int(const char* fileNameUTF8)); |
| 70 | MOCK_METHOD1(StartDebugRecording, int(FILE* file_handle)); |
| 71 | MOCK_METHOD0(StopDebugRecording, int()); |
| 72 | MOCK_METHOD1(SetTypingDetectionStatus, int(bool enable)); |
| 73 | MOCK_METHOD1(GetTypingDetectionStatus, int(bool& enabled)); |
| 74 | MOCK_METHOD1(TimeSinceLastTyping, int(int& seconds)); |
| 75 | MOCK_METHOD5(SetTypingDetectionParameters, |
| 76 | int(int timeWindow, |
| 77 | int costPerTyping, |
| 78 | int reportingThreshold, |
| 79 | int penaltyDecay, |
| 80 | int typeEventDelay)); |
| 81 | MOCK_METHOD1(EnableStereoChannelSwapping, void(bool enable)); |
| 82 | MOCK_METHOD0(IsStereoChannelSwappingEnabled, bool()); |
| 83 | |
| 84 | // VoEBase |
| 85 | MOCK_METHOD1(RegisterVoiceEngineObserver, int(VoiceEngineObserver& observer)); |
| 86 | MOCK_METHOD0(DeRegisterVoiceEngineObserver, int()); |
| 87 | MOCK_METHOD2(Init, |
| 88 | int(AudioDeviceModule* external_adm, |
| 89 | AudioProcessing* audioproc)); |
| 90 | MOCK_METHOD0(audio_processing, AudioProcessing*()); |
| 91 | MOCK_METHOD0(Terminate, int()); |
| 92 | MOCK_METHOD0(CreateChannel, int()); |
| 93 | MOCK_METHOD1(CreateChannel, int(const Config& config)); |
| 94 | MOCK_METHOD1(DeleteChannel, int(int channel)); |
| 95 | MOCK_METHOD1(StartReceive, int(int channel)); |
| 96 | MOCK_METHOD1(StopReceive, int(int channel)); |
| 97 | MOCK_METHOD1(StartPlayout, int(int channel)); |
| 98 | MOCK_METHOD1(StopPlayout, int(int channel)); |
| 99 | MOCK_METHOD1(StartSend, int(int channel)); |
| 100 | MOCK_METHOD1(StopSend, int(int channel)); |
| 101 | MOCK_METHOD1(GetVersion, int(char version[1024])); |
| 102 | MOCK_METHOD0(LastError, int()); |
| 103 | MOCK_METHOD0(audio_transport, AudioTransport*()); |
| 104 | MOCK_METHOD2(AssociateSendChannel, |
| 105 | int(int channel, int accociate_send_channel)); |
| 106 | |
| 107 | // VoECodec |
| 108 | MOCK_METHOD0(NumOfCodecs, int()); |
| 109 | MOCK_METHOD2(GetCodec, int(int index, CodecInst& codec)); |
| 110 | MOCK_METHOD2(SetSendCodec, int(int channel, const CodecInst& codec)); |
| 111 | MOCK_METHOD2(GetSendCodec, int(int channel, CodecInst& codec)); |
| 112 | MOCK_METHOD2(SetBitRate, int(int channel, int bitrate_bps)); |
| 113 | MOCK_METHOD2(GetRecCodec, int(int channel, CodecInst& codec)); |
| 114 | MOCK_METHOD2(SetRecPayloadType, int(int channel, const CodecInst& codec)); |
| 115 | MOCK_METHOD2(GetRecPayloadType, int(int channel, CodecInst& codec)); |
| 116 | MOCK_METHOD3(SetSendCNPayloadType, |
| 117 | int(int channel, int type, PayloadFrequencies frequency)); |
| 118 | MOCK_METHOD2(SetFECStatus, int(int channel, bool enable)); |
| 119 | MOCK_METHOD2(GetFECStatus, int(int channel, bool& enabled)); |
| 120 | MOCK_METHOD4(SetVADStatus, |
| 121 | int(int channel, bool enable, VadModes mode, bool disableDTX)); |
| 122 | MOCK_METHOD4( |
| 123 | GetVADStatus, |
| 124 | int(int channel, bool& enabled, VadModes& mode, bool& disabledDTX)); |
| 125 | MOCK_METHOD2(SetOpusMaxPlaybackRate, int(int channel, int frequency_hz)); |
| 126 | MOCK_METHOD2(SetOpusDtx, int(int channel, bool enable_dtx)); |
| 127 | MOCK_METHOD0(GetEventLog, RtcEventLog*()); |
| 128 | |
| 129 | // VoEDtmf |
| 130 | MOCK_METHOD5(SendTelephoneEvent, |
| 131 | int(int channel, |
| 132 | int eventCode, |
| 133 | bool outOfBand, |
| 134 | int lengthMs, |
| 135 | int attenuationDb)); |
| 136 | MOCK_METHOD2(SetSendTelephoneEventPayloadType, |
| 137 | int(int channel, unsigned char type)); |
| 138 | MOCK_METHOD2(GetSendTelephoneEventPayloadType, |
| 139 | int(int channel, unsigned char& type)); |
| 140 | MOCK_METHOD2(SetDtmfFeedbackStatus, int(bool enable, bool directFeedback)); |
| 141 | MOCK_METHOD2(GetDtmfFeedbackStatus, int(bool& enabled, bool& directFeedback)); |
| 142 | MOCK_METHOD3(PlayDtmfTone, |
| 143 | int(int eventCode, int lengthMs, int attenuationDb)); |
| 144 | |
| 145 | // VoEExternalMedia |
| 146 | MOCK_METHOD3(RegisterExternalMediaProcessing, |
| 147 | int(int channel, |
| 148 | ProcessingTypes type, |
| 149 | VoEMediaProcess& processObject)); |
| 150 | MOCK_METHOD2(DeRegisterExternalMediaProcessing, |
| 151 | int(int channel, ProcessingTypes type)); |
| 152 | MOCK_METHOD3(GetAudioFrame, |
| 153 | int(int channel, int desired_sample_rate_hz, AudioFrame* frame)); |
| 154 | MOCK_METHOD2(SetExternalMixing, int(int channel, bool enable)); |
| 155 | |
| 156 | // VoEFile |
| 157 | MOCK_METHOD7(StartPlayingFileLocally, |
| 158 | int(int channel, |
| 159 | const char fileNameUTF8[1024], |
| 160 | bool loop, |
| 161 | FileFormats format, |
| 162 | float volumeScaling, |
| 163 | int startPointMs, |
| 164 | int stopPointMs)); |
| 165 | MOCK_METHOD6(StartPlayingFileLocally, |
| 166 | int(int channel, |
| 167 | InStream* stream, |
| 168 | FileFormats format, |
| 169 | float volumeScaling, |
| 170 | int startPointMs, |
| 171 | int stopPointMs)); |
| 172 | MOCK_METHOD1(StopPlayingFileLocally, int(int channel)); |
| 173 | MOCK_METHOD1(IsPlayingFileLocally, int(int channel)); |
| 174 | MOCK_METHOD6(StartPlayingFileAsMicrophone, |
| 175 | int(int channel, |
| 176 | const char fileNameUTF8[1024], |
| 177 | bool loop, |
| 178 | bool mixWithMicrophone, |
| 179 | FileFormats format, |
| 180 | float volumeScaling)); |
| 181 | MOCK_METHOD5(StartPlayingFileAsMicrophone, |
| 182 | int(int channel, |
| 183 | InStream* stream, |
| 184 | bool mixWithMicrophone, |
| 185 | FileFormats format, |
| 186 | float volumeScaling)); |
| 187 | MOCK_METHOD1(StopPlayingFileAsMicrophone, int(int channel)); |
| 188 | MOCK_METHOD1(IsPlayingFileAsMicrophone, int(int channel)); |
| 189 | MOCK_METHOD4(StartRecordingPlayout, |
| 190 | int(int channel, |
| 191 | const char* fileNameUTF8, |
| 192 | CodecInst* compression, |
| 193 | int maxSizeBytes)); |
| 194 | MOCK_METHOD1(StopRecordingPlayout, int(int channel)); |
| 195 | MOCK_METHOD3(StartRecordingPlayout, |
| 196 | int(int channel, OutStream* stream, CodecInst* compression)); |
| 197 | MOCK_METHOD3(StartRecordingMicrophone, |
| 198 | int(const char* fileNameUTF8, |
| 199 | CodecInst* compression, |
| 200 | int maxSizeBytes)); |
| 201 | MOCK_METHOD2(StartRecordingMicrophone, |
| 202 | int(OutStream* stream, CodecInst* compression)); |
| 203 | MOCK_METHOD0(StopRecordingMicrophone, int()); |
| 204 | |
| 205 | // VoEHardware |
| 206 | MOCK_METHOD1(GetNumOfRecordingDevices, int(int& devices)); |
| 207 | MOCK_METHOD1(GetNumOfPlayoutDevices, int(int& devices)); |
| 208 | MOCK_METHOD3(GetRecordingDeviceName, |
| 209 | int(int index, char strNameUTF8[128], char strGuidUTF8[128])); |
| 210 | MOCK_METHOD3(GetPlayoutDeviceName, |
| 211 | int(int index, char strNameUTF8[128], char strGuidUTF8[128])); |
| 212 | MOCK_METHOD2(SetRecordingDevice, |
| 213 | int(int index, StereoChannel recordingChannel)); |
| 214 | MOCK_METHOD1(SetPlayoutDevice, int(int index)); |
| 215 | MOCK_METHOD1(SetAudioDeviceLayer, int(AudioLayers audioLayer)); |
| 216 | MOCK_METHOD1(GetAudioDeviceLayer, int(AudioLayers& audioLayer)); |
| 217 | MOCK_METHOD1(SetRecordingSampleRate, int(unsigned int samples_per_sec)); |
| 218 | MOCK_CONST_METHOD1(RecordingSampleRate, int(unsigned int* samples_per_sec)); |
| 219 | MOCK_METHOD1(SetPlayoutSampleRate, int(unsigned int samples_per_sec)); |
| 220 | MOCK_CONST_METHOD1(PlayoutSampleRate, int(unsigned int* samples_per_sec)); |
| 221 | MOCK_CONST_METHOD0(BuiltInAECIsAvailable, bool()); |
| 222 | MOCK_METHOD1(EnableBuiltInAEC, int(bool enable)); |
| 223 | MOCK_CONST_METHOD0(BuiltInAGCIsAvailable, bool()); |
| 224 | MOCK_METHOD1(EnableBuiltInAGC, int(bool enable)); |
| 225 | MOCK_CONST_METHOD0(BuiltInNSIsAvailable, bool()); |
| 226 | MOCK_METHOD1(EnableBuiltInNS, int(bool enable)); |
| 227 | |
| 228 | // VoENetEqStats |
| 229 | MOCK_METHOD2(GetNetworkStatistics, |
| 230 | int(int channel, NetworkStatistics& stats)); |
| 231 | MOCK_CONST_METHOD2(GetDecodingCallStatistics, |
| 232 | int(int channel, AudioDecodingCallStats* stats)); |
| 233 | |
| 234 | // VoENetwork |
| 235 | MOCK_METHOD2(RegisterExternalTransport, |
| 236 | int(int channel, Transport& transport)); |
| 237 | MOCK_METHOD1(DeRegisterExternalTransport, int(int channel)); |
| 238 | MOCK_METHOD3(ReceivedRTPPacket, |
| 239 | int(int channel, const void* data, size_t length)); |
| 240 | MOCK_METHOD4(ReceivedRTPPacket, |
| 241 | int(int channel, |
| 242 | const void* data, |
| 243 | size_t length, |
| 244 | const PacketTime& packet_time)); |
| 245 | MOCK_METHOD3(ReceivedRTCPPacket, |
| 246 | int(int channel, const void* data, size_t length)); |
| 247 | |
| 248 | // VoERTP_RTCP |
| 249 | MOCK_METHOD2(SetLocalSSRC, int(int channel, unsigned int ssrc)); |
| 250 | MOCK_METHOD2(GetLocalSSRC, int(int channel, unsigned int& ssrc)); |
| 251 | MOCK_METHOD2(GetRemoteSSRC, int(int channel, unsigned int& ssrc)); |
| 252 | MOCK_METHOD3(SetSendAudioLevelIndicationStatus, |
| 253 | int(int channel, bool enable, unsigned char id)); |
| 254 | MOCK_METHOD3(SetReceiveAudioLevelIndicationStatus, |
| 255 | int(int channel, bool enable, unsigned char id)); |
| 256 | MOCK_METHOD3(SetSendAbsoluteSenderTimeStatus, |
| 257 | int(int channel, bool enable, unsigned char id)); |
| 258 | MOCK_METHOD3(SetReceiveAbsoluteSenderTimeStatus, |
| 259 | int(int channel, bool enable, unsigned char id)); |
| 260 | MOCK_METHOD2(SetRTCPStatus, int(int channel, bool enable)); |
| 261 | MOCK_METHOD2(GetRTCPStatus, int(int channel, bool& enabled)); |
| 262 | MOCK_METHOD2(SetRTCP_CNAME, int(int channel, const char cName[256])); |
| 263 | MOCK_METHOD2(GetRTCP_CNAME, int(int channel, char cName[256])); |
| 264 | MOCK_METHOD2(GetRemoteRTCP_CNAME, int(int channel, char cName[256])); |
| 265 | MOCK_METHOD7(GetRemoteRTCPData, |
| 266 | int(int channel, |
| 267 | unsigned int& NTPHigh, |
| 268 | unsigned int& NTPLow, |
| 269 | unsigned int& timestamp, |
| 270 | unsigned int& playoutTimestamp, |
| 271 | unsigned int* jitter, |
| 272 | unsigned short* fractionLost)); |
| 273 | MOCK_METHOD4(GetRTPStatistics, |
| 274 | int(int channel, |
| 275 | unsigned int& averageJitterMs, |
| 276 | unsigned int& maxJitterMs, |
| 277 | unsigned int& discardedPackets)); |
| 278 | MOCK_METHOD2(GetRTCPStatistics, int(int channel, CallStatistics& stats)); |
| 279 | MOCK_METHOD2(GetRemoteRTCPReportBlocks, |
| 280 | int(int channel, std::vector<ReportBlock>* receive_blocks)); |
| 281 | MOCK_METHOD3(SetREDStatus, int(int channel, bool enable, int redPayloadtype)); |
| 282 | MOCK_METHOD3(GetREDStatus, |
| 283 | int(int channel, bool& enable, int& redPayloadtype)); |
| 284 | MOCK_METHOD3(SetNACKStatus, int(int channel, bool enable, int maxNoPackets)); |
| 285 | |
| 286 | // VoEVideoSync |
| 287 | MOCK_METHOD1(GetPlayoutBufferSize, int(int& buffer_ms)); |
| 288 | MOCK_METHOD2(SetMinimumPlayoutDelay, int(int channel, int delay_ms)); |
| 289 | MOCK_METHOD3(GetDelayEstimate, |
| 290 | int(int channel, |
| 291 | int* jitter_buffer_delay_ms, |
| 292 | int* playout_buffer_delay_ms)); |
| 293 | MOCK_CONST_METHOD1(GetLeastRequiredDelayMs, int(int channel)); |
| 294 | MOCK_METHOD2(SetInitTimestamp, int(int channel, unsigned int timestamp)); |
| 295 | MOCK_METHOD2(SetInitSequenceNumber, int(int channel, short sequenceNumber)); |
| 296 | MOCK_METHOD2(GetPlayoutTimestamp, int(int channel, unsigned int& timestamp)); |
| 297 | MOCK_METHOD3(GetRtpRtcp, |
| 298 | int(int channel, |
| 299 | RtpRtcp** rtpRtcpModule, |
| 300 | RtpReceiver** rtp_receiver)); |
| 301 | |
| 302 | // VoEVolumeControl |
| 303 | MOCK_METHOD1(SetSpeakerVolume, int(unsigned int volume)); |
| 304 | MOCK_METHOD1(GetSpeakerVolume, int(unsigned int& volume)); |
| 305 | MOCK_METHOD1(SetMicVolume, int(unsigned int volume)); |
| 306 | MOCK_METHOD1(GetMicVolume, int(unsigned int& volume)); |
| 307 | MOCK_METHOD2(SetInputMute, int(int channel, bool enable)); |
| 308 | MOCK_METHOD2(GetInputMute, int(int channel, bool& enabled)); |
| 309 | MOCK_METHOD1(GetSpeechInputLevel, int(unsigned int& level)); |
| 310 | MOCK_METHOD2(GetSpeechOutputLevel, int(int channel, unsigned int& level)); |
| 311 | MOCK_METHOD1(GetSpeechInputLevelFullRange, int(unsigned int& level)); |
| 312 | MOCK_METHOD2(GetSpeechOutputLevelFullRange, |
| 313 | int(int channel, unsigned& level)); |
| 314 | MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); |
| 315 | MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); |
| 316 | MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); |
| 317 | MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); |
| 318 | }; |
| 319 | } // namespace test |
| 320 | } // namespace webrtc |
| 321 | |
| 322 | #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |