Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: webrtc/test/fake_voice_engine.h

Issue 1402403008: Changed FakeVoiceEngine into a MockVoiceEngine. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: unneeded include Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/call/call_unittest.cc ('k') | webrtc/test/fake_voice_engine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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_FAKE_VOICE_ENGINE_H_
12 #define WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_
13
14 #include <vector>
15
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 #include "webrtc/voice_engine/voice_engine_impl.h"
19
20 namespace webrtc {
21 namespace test {
22
23 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be
24 // able to get the various interfaces as usual, via T::GetInterface().
25 class FakeVoiceEngine final : public VoiceEngineImpl {
26 public:
27 static const int kSendChannelId;
28 static const int kRecvChannelId;
29 static const uint32_t kSendSsrc;
30 static const uint32_t kRecvSsrc;
31 static const int kSendEchoDelayMedian;
32 static const int kSendEchoDelayStdDev;
33 static const int kSendEchoReturnLoss;
34 static const int kSendEchoReturnLossEnhancement;
35 static const int kRecvJitterBufferDelay;
36 static const int kRecvPlayoutBufferDelay;
37 static const unsigned int kSendSpeechInputLevel;
38 static const unsigned int kRecvSpeechOutputLevel;
39 static const CallStatistics kSendCallStats;
40 static const CodecInst kSendCodecInst;
41 static const ReportBlock kSendReportBlock;
42 static const CallStatistics kRecvCallStats;
43 static const CodecInst kRecvCodecInst;
44 static const NetworkStatistics kRecvNetworkStats;
45 static const AudioDecodingCallStats kRecvAudioDecodingCallStats;
46
47 FakeVoiceEngine() : VoiceEngineImpl(new Config(), true) {
48 // Increase ref count so this object isn't automatically deleted whenever
49 // interfaces are Release():d.
50 ++_ref_count;
51 }
52 ~FakeVoiceEngine() override {
53 // Decrease ref count before base class d-tor is called; otherwise it will
54 // trigger an assertion.
55 --_ref_count;
56 }
57
58 // VoEAudioProcessing
59 int SetNsStatus(bool enable, NsModes mode = kNsUnchanged) override {
60 return -1;
61 }
62 int GetNsStatus(bool& enabled, NsModes& mode) override { return -1; }
63 int SetAgcStatus(bool enable, AgcModes mode = kAgcUnchanged) override {
64 return -1;
65 }
66 int GetAgcStatus(bool& enabled, AgcModes& mode) override { return -1; }
67 int SetAgcConfig(AgcConfig config) override { return -1; }
68 int GetAgcConfig(AgcConfig& config) override { return -1; }
69 int SetEcStatus(bool enable, EcModes mode = kEcUnchanged) override {
70 return -1;
71 }
72 int GetEcStatus(bool& enabled, EcModes& mode) override { return -1; }
73 int EnableDriftCompensation(bool enable) override { return -1; }
74 bool DriftCompensationEnabled() override { return false; }
75 void SetDelayOffsetMs(int offset) override {}
76 int DelayOffsetMs() override { return -1; }
77 int SetAecmMode(AecmModes mode = kAecmSpeakerphone,
78 bool enableCNG = true) override { return -1; }
79 int GetAecmMode(AecmModes& mode, bool& enabledCNG) override { return -1; }
80 int EnableHighPassFilter(bool enable) override { return -1; }
81 bool IsHighPassFilterEnabled() override { return false; }
82 int SetRxNsStatus(int channel,
83 bool enable,
84 NsModes mode = kNsUnchanged) override { return -1; }
85 int GetRxNsStatus(int channel, bool& enabled, NsModes& mode) override {
86 return -1;
87 }
88 int SetRxAgcStatus(int channel,
89 bool enable,
90 AgcModes mode = kAgcUnchanged) override { return -1; }
91 int GetRxAgcStatus(int channel, bool& enabled, AgcModes& mode) override {
92 return -1;
93 }
94 int SetRxAgcConfig(int channel, AgcConfig config) override { return -1; }
95 int GetRxAgcConfig(int channel, AgcConfig& config) override { return -1; }
96 int RegisterRxVadObserver(int channel,
97 VoERxVadCallback& observer) override { return -1; }
98 int DeRegisterRxVadObserver(int channel) override { return -1; }
99 int VoiceActivityIndicator(int channel) override { return -1; }
100 int SetEcMetricsStatus(bool enable) override { return -1; }
101 int GetEcMetricsStatus(bool& enabled) override {
102 enabled = true;
103 return 0;
104 }
105 int GetEchoMetrics(int& ERL, int& ERLE, int& RERL, int& A_NLP) override {
106 ERL = kSendEchoReturnLoss;
107 ERLE = kSendEchoReturnLossEnhancement;
108 RERL = -123456789;
109 A_NLP = 123456789;
110 return 0;
111 }
112 int GetEcDelayMetrics(int& delay_median,
113 int& delay_std,
114 float& fraction_poor_delays) override {
115 delay_median = kSendEchoDelayMedian;
116 delay_std = kSendEchoDelayStdDev;
117 fraction_poor_delays = -12345.7890f;
118 return 0;
119 }
120 int StartDebugRecording(const char* fileNameUTF8) override { return -1; }
121 int StartDebugRecording(FILE* file_handle) override { return -1; }
122 int StopDebugRecording() override { return -1; }
123 int SetTypingDetectionStatus(bool enable) override { return -1; }
124 int GetTypingDetectionStatus(bool& enabled) override { return -1; }
125 int TimeSinceLastTyping(int& seconds) override { return -1; }
126 int SetTypingDetectionParameters(int timeWindow,
127 int costPerTyping,
128 int reportingThreshold,
129 int penaltyDecay,
130 int typeEventDelay = 0) override {
131 return -1;
132 }
133 void EnableStereoChannelSwapping(bool enable) override {}
134 bool IsStereoChannelSwappingEnabled() override { return false; }
135
136 // VoEBase
137 int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override {
138 return -1;
139 }
140 int DeRegisterVoiceEngineObserver() override { return -1; }
141 int Init(AudioDeviceModule* external_adm = NULL,
142 AudioProcessing* audioproc = NULL) override { return -1; }
143 AudioProcessing* audio_processing() override { return nullptr; }
144 int Terminate() override { return -1; }
145 int CreateChannel() override { return -1; }
146 int CreateChannel(const Config& config) override { return -1; }
147 int DeleteChannel(int channel) override { return -1; }
148 int StartReceive(int channel) override { return -1; }
149 int StopReceive(int channel) override { return -1; }
150 int StartPlayout(int channel) override { return -1; }
151 int StopPlayout(int channel) override { return -1; }
152 int StartSend(int channel) override { return -1; }
153 int StopSend(int channel) override { return -1; }
154 int GetVersion(char version[1024]) override { return -1; }
155 int LastError() override { return -1; }
156 AudioTransport* audio_transport() { return nullptr; }
157 int AssociateSendChannel(int channel, int accociate_send_channel) override {
158 return -1;
159 }
160
161 // VoECodec
162 int NumOfCodecs() override { return -1; }
163 int GetCodec(int index, CodecInst& codec) override { return -1; }
164 int SetSendCodec(int channel, const CodecInst& codec) override { return -1; }
165 int GetSendCodec(int channel, CodecInst& codec) override {
166 EXPECT_EQ(channel, kSendChannelId);
167 codec = kSendCodecInst;
168 return 0;
169 }
170 int SetBitRate(int channel, int bitrate_bps) override { return -1; }
171 int GetRecCodec(int channel, CodecInst& codec) override {
172 EXPECT_EQ(channel, kRecvChannelId);
173 codec = kRecvCodecInst;
174 return 0;
175 }
176 int SetRecPayloadType(int channel, const CodecInst& codec) override {
177 return -1;
178 }
179 int GetRecPayloadType(int channel, CodecInst& codec) override { return -1; }
180 int SetSendCNPayloadType(int channel, int type,
181 PayloadFrequencies frequency = kFreq16000Hz) override { return -1; }
182 int SetVADStatus(int channel,
183 bool enable,
184 VadModes mode = kVadConventional,
185 bool disableDTX = false) override { return -1; }
186 int GetVADStatus(int channel,
187 bool& enabled,
188 VadModes& mode,
189 bool& disabledDTX) override { return -1; }
190 int SetOpusMaxPlaybackRate(int channel, int frequency_hz) override {
191 return -1;
192 }
193 int SetOpusDtx(int channel, bool enable_dtx) override { return -1; }
194 RtcEventLog* GetEventLog() override { return nullptr; }
195
196 // VoEDtmf
197 int SendTelephoneEvent(int channel,
198 int eventCode,
199 bool outOfBand = true,
200 int lengthMs = 160,
201 int attenuationDb = 10) override { return -1; }
202 int SetSendTelephoneEventPayloadType(int channel,
203 unsigned char type) override {
204 return -1;
205 }
206 int GetSendTelephoneEventPayloadType(int channel,
207 unsigned char& type) override {
208 return -1;
209 }
210 int SetDtmfFeedbackStatus(bool enable,
211 bool directFeedback = false) override { return -1; }
212 int GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) override {
213 return -1;
214 }
215 int PlayDtmfTone(int eventCode,
216 int lengthMs = 200,
217 int attenuationDb = 10) override { return -1; }
218
219 // VoEExternalMedia
220 int RegisterExternalMediaProcessing(
221 int channel,
222 ProcessingTypes type,
223 VoEMediaProcess& processObject) override { return -1; }
224 int DeRegisterExternalMediaProcessing(int channel,
225 ProcessingTypes type) override {
226 return -1;
227 }
228 int GetAudioFrame(int channel,
229 int desired_sample_rate_hz,
230 AudioFrame* frame) override { return -1; }
231 int SetExternalMixing(int channel, bool enable) override { return -1; }
232
233 // VoEFile
234 int StartPlayingFileLocally(
235 int channel,
236 const char fileNameUTF8[1024],
237 bool loop = false,
238 FileFormats format = kFileFormatPcm16kHzFile,
239 float volumeScaling = 1.0,
240 int startPointMs = 0,
241 int stopPointMs = 0) override { return -1; }
242 int StartPlayingFileLocally(
243 int channel,
244 InStream* stream,
245 FileFormats format = kFileFormatPcm16kHzFile,
246 float volumeScaling = 1.0,
247 int startPointMs = 0,
248 int stopPointMs = 0) override { return -1; }
249 int StopPlayingFileLocally(int channel) override { return -1; }
250 int IsPlayingFileLocally(int channel) override { return -1; }
251 int StartPlayingFileAsMicrophone(
252 int channel,
253 const char fileNameUTF8[1024],
254 bool loop = false,
255 bool mixWithMicrophone = false,
256 FileFormats format = kFileFormatPcm16kHzFile,
257 float volumeScaling = 1.0) override { return -1; }
258 int StartPlayingFileAsMicrophone(
259 int channel,
260 InStream* stream,
261 bool mixWithMicrophone = false,
262 FileFormats format = kFileFormatPcm16kHzFile,
263 float volumeScaling = 1.0) override { return -1; }
264 int StopPlayingFileAsMicrophone(int channel) override { return -1; }
265 int IsPlayingFileAsMicrophone(int channel) override { return -1; }
266 int StartRecordingPlayout(int channel,
267 const char* fileNameUTF8,
268 CodecInst* compression = NULL,
269 int maxSizeBytes = -1) override { return -1; }
270 int StopRecordingPlayout(int channel) override { return -1; }
271 int StartRecordingPlayout(int channel,
272 OutStream* stream,
273 CodecInst* compression = NULL) override {
274 return -1;
275 }
276 int StartRecordingMicrophone(const char* fileNameUTF8,
277 CodecInst* compression = NULL,
278 int maxSizeBytes = -1) override { return -1; }
279 int StartRecordingMicrophone(OutStream* stream,
280 CodecInst* compression = NULL) override {
281 return -1;
282 }
283 int StopRecordingMicrophone() override { return -1; }
284
285 // VoEHardware
286 int GetNumOfRecordingDevices(int& devices) override { return -1; }
287
288 // Gets the number of audio devices available for playout.
289 int GetNumOfPlayoutDevices(int& devices) override { return -1; }
290
291 // Gets the name of a specific recording device given by an |index|.
292 // On Windows Vista/7, it also retrieves an additional unique ID
293 // (GUID) for the recording device.
294 int GetRecordingDeviceName(int index,
295 char strNameUTF8[128],
296 char strGuidUTF8[128]) override { return -1; }
297
298 // Gets the name of a specific playout device given by an |index|.
299 // On Windows Vista/7, it also retrieves an additional unique ID
300 // (GUID) for the playout device.
301 int GetPlayoutDeviceName(int index,
302 char strNameUTF8[128],
303 char strGuidUTF8[128]) override { return -1; }
304
305 // Sets the audio device used for recording.
306 int SetRecordingDevice(
307 int index,
308 StereoChannel recordingChannel = kStereoBoth) override { return -1; }
309
310 // Sets the audio device used for playout.
311 int SetPlayoutDevice(int index) override { return -1; }
312
313 // Sets the type of audio device layer to use.
314 int SetAudioDeviceLayer(AudioLayers audioLayer) override { return -1; }
315
316 // Gets the currently used (active) audio device layer.
317 int GetAudioDeviceLayer(AudioLayers& audioLayer) override { return -1; }
318
319 // Native sample rate controls (samples/sec)
320 int SetRecordingSampleRate(unsigned int samples_per_sec) override {
321 return -1;
322 }
323 int RecordingSampleRate(unsigned int* samples_per_sec) const override {
324 return -1;
325 }
326 int SetPlayoutSampleRate(unsigned int samples_per_sec) override {
327 return -1;
328 }
329 int PlayoutSampleRate(unsigned int* samples_per_sec) const override {
330 return -1;
331 }
332
333 // Queries and controls platform audio effects on Android devices.
334 bool BuiltInAECIsAvailable() const override { return false; }
335 int EnableBuiltInAEC(bool enable) override { return -1; }
336 bool BuiltInAGCIsAvailable() const override { return false; }
337 int EnableBuiltInAGC(bool enable) override { return -1; }
338 bool BuiltInNSIsAvailable() const override { return false; }
339 int EnableBuiltInNS(bool enable) override { return -1; }
340
341 // VoENetwork
342 int RegisterExternalTransport(int channel, Transport& transport) override {
343 return -1;
344 }
345 int DeRegisterExternalTransport(int channel) override { return -1; }
346 int ReceivedRTPPacket(int channel,
347 const void* data,
348 size_t length) override { return -1; }
349 int ReceivedRTPPacket(int channel,
350 const void* data,
351 size_t length,
352 const PacketTime& packet_time) override { return -1; }
353 int ReceivedRTCPPacket(int channel,
354 const void* data,
355 size_t length) { return -1; }
356
357 // VoENetEqStats
358 int GetNetworkStatistics(int channel, NetworkStatistics& stats) override {
359 EXPECT_EQ(channel, kRecvChannelId);
360 stats = kRecvNetworkStats;
361 return 0;
362 }
363 int GetDecodingCallStatistics(int channel,
364 AudioDecodingCallStats* stats) const override {
365 EXPECT_EQ(channel, kRecvChannelId);
366 EXPECT_NE(nullptr, stats);
367 *stats = kRecvAudioDecodingCallStats;
368 return 0;
369 }
370
371 // VoERTP_RTCP
372 int SetLocalSSRC(int channel, unsigned int ssrc) override { return -1; }
373 int GetLocalSSRC(int channel, unsigned int& ssrc) override {
374 EXPECT_EQ(channel, kSendChannelId);
375 ssrc = 0;
376 return 0;
377 }
378 int GetRemoteSSRC(int channel, unsigned int& ssrc) override {
379 EXPECT_EQ(channel, kRecvChannelId);
380 ssrc = 0;
381 return 0;
382 }
383 int SetSendAudioLevelIndicationStatus(int channel,
384 bool enable,
385 unsigned char id = 1) override {
386 return -1;
387 }
388 int SetSendAbsoluteSenderTimeStatus(int channel,
389 bool enable,
390 unsigned char id) override { return -1; }
391 int SetReceiveAbsoluteSenderTimeStatus(int channel,
392 bool enable,
393 unsigned char id) override {
394 return -1;
395 }
396 int SetRTCPStatus(int channel, bool enable) override { return -1; }
397 int GetRTCPStatus(int channel, bool& enabled) override { return -1; }
398 int SetRTCP_CNAME(int channel, const char cName[256]) override { return -1; }
399 int GetRTCP_CNAME(int channel, char cName[256]) { return -1; }
400 int GetRemoteRTCP_CNAME(int channel, char cName[256]) override { return -1; }
401 int GetRemoteRTCPData(int channel,
402 unsigned int& NTPHigh,
403 unsigned int& NTPLow,
404 unsigned int& timestamp,
405 unsigned int& playoutTimestamp,
406 unsigned int* jitter = NULL,
407 unsigned short* fractionLost = NULL) override {
408 return -1;
409 }
410 int GetRTPStatistics(int channel,
411 unsigned int& averageJitterMs,
412 unsigned int& maxJitterMs,
413 unsigned int& discardedPackets) override { return -1; }
414 int GetRTCPStatistics(int channel, CallStatistics& stats) override {
415 if (channel == kSendChannelId) {
416 stats = kSendCallStats;
417 } else {
418 EXPECT_EQ(channel, kRecvChannelId);
419 stats = kRecvCallStats;
420 }
421 return 0;
422 }
423 int GetRemoteRTCPReportBlocks(
424 int channel,
425 std::vector<ReportBlock>* receive_blocks) override {
426 EXPECT_EQ(channel, kSendChannelId);
427 EXPECT_NE(receive_blocks, nullptr);
428 EXPECT_EQ(receive_blocks->size(), 0u);
429 webrtc::ReportBlock block = kSendReportBlock;
430 receive_blocks->push_back(block); // Has wrong SSRC.
431 block.source_SSRC = kSendSsrc;
432 receive_blocks->push_back(block); // Correct block.
433 block.fraction_lost = 0;
434 receive_blocks->push_back(block); // Duplicate SSRC, bad fraction_lost.
435 return 0;
436 }
437 int SetNACKStatus(int channel, bool enable, int maxNoPackets) override {
438 return -1;
439 }
440
441 // VoEVideoSync
442 int GetPlayoutBufferSize(int& buffer_ms) override { return -1; }
443 int SetMinimumPlayoutDelay(int channel, int delay_ms) override { return -1; }
444 int GetDelayEstimate(int channel,
445 int* jitter_buffer_delay_ms,
446 int* playout_buffer_delay_ms) override {
447 EXPECT_EQ(channel, kRecvChannelId);
448 *jitter_buffer_delay_ms = kRecvJitterBufferDelay;
449 *playout_buffer_delay_ms = kRecvPlayoutBufferDelay;
450 return 0;
451 }
452 int GetLeastRequiredDelayMs(int channel) const override { return -1; }
453 int SetInitTimestamp(int channel, unsigned int timestamp) override {
454 return -1;
455 }
456 int SetInitSequenceNumber(int channel, short sequenceNumber) override {
457 return -1;
458 }
459 int GetPlayoutTimestamp(int channel, unsigned int& timestamp) override {
460 return -1;
461 }
462 int GetRtpRtcp(int channel,
463 RtpRtcp** rtpRtcpModule,
464 RtpReceiver** rtp_receiver) override { return -1; }
465
466 // VoEVolumeControl
467 int SetSpeakerVolume(unsigned int volume) override { return -1; }
468 int GetSpeakerVolume(unsigned int& volume) override { return -1; }
469 int SetMicVolume(unsigned int volume) override { return -1; }
470 int GetMicVolume(unsigned int& volume) override { return -1; }
471 int SetInputMute(int channel, bool enable) override { return -1; }
472 int GetInputMute(int channel, bool& enabled) override { return -1; }
473 int GetSpeechInputLevel(unsigned int& level) override { return -1; }
474 int GetSpeechOutputLevel(int channel, unsigned int& level) override {
475 return -1;
476 }
477 int GetSpeechInputLevelFullRange(unsigned int& level) override {
478 level = kSendSpeechInputLevel;
479 return 0;
480 }
481 int GetSpeechOutputLevelFullRange(int channel,
482 unsigned int& level) override {
483 EXPECT_EQ(channel, kRecvChannelId);
484 level = kRecvSpeechOutputLevel;
485 return 0;
486 }
487 int SetChannelOutputVolumeScaling(int channel, float scaling) override {
488 return -1;
489 }
490 int GetChannelOutputVolumeScaling(int channel, float& scaling) override {
491 return -1;
492 }
493 int SetOutputVolumePan(int channel, float left, float right) override {
494 return -1;
495 }
496 int GetOutputVolumePan(int channel, float& left, float& right) override {
497 return -1;
498 }
499 };
500 } // namespace test
501 } // namespace webrtc
502
503 #endif // WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_
OLDNEW
« no previous file with comments | « webrtc/call/call_unittest.cc ('k') | webrtc/test/fake_voice_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698