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

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

Issue 1390753002: Implement AudioReceiveStream::GetStats(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: merge master Created 5 years, 2 months 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/test/call_test.cc ('k') | webrtc/test/webrtc_test_common.gyp » ('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 const int kSendChannelId = 1;
28 const int kReceiveChannelId = 2;
29
30 const int kRecvJitterBufferDelay = -7;
31 const int kRecvPlayoutBufferDelay = 302;
32 const unsigned int kRecvSpeechOutputLevel = 99;
33
34 FakeVoiceEngine() : VoiceEngineImpl(new Config(), true) {
35 // Increase ref count so this object isn't automatically deleted whenever
36 // interfaces are Release():d.
37 ++_ref_count;
38 }
39 ~FakeVoiceEngine() override {
40 // Decrease ref count before base class d-tor is called; otherwise it will
41 // trigger an assertion.
42 --_ref_count;
43 }
44
45 const CallStatistics& GetRecvCallStats() const {
46 static const CallStatistics kStats = {
47 345, 678, 901, 234, -1, 0, 0, 567, 890, 123
48 };
49 return kStats;
50 }
51
52 const CodecInst& GetRecvRecCodecInst() const {
53 static const CodecInst kStats = {
54 123, "codec_name", 96000, -1, -1, -1
55 };
56 return kStats;
57 }
58
59 const NetworkStatistics& GetRecvNetworkStats() const {
60 static const NetworkStatistics kStats = {
61 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0
62 };
63 return kStats;
64 }
65
66 const AudioDecodingCallStats& GetRecvAudioDecodingCallStats() const {
67 static AudioDecodingCallStats stats;
68 if (stats.calls_to_silence_generator == 0) {
69 stats.calls_to_silence_generator = 234;
70 stats.calls_to_neteq = 567;
71 stats.decoded_normal = 890;
72 stats.decoded_plc = 123;
73 stats.decoded_cng = 456;
74 stats.decoded_plc_cng = 789;
75 }
76 return stats;
77 }
78
79 // VoEBase
80 int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override {
81 return -1;
82 }
83 int DeRegisterVoiceEngineObserver() override { return -1; }
84 int Init(AudioDeviceModule* external_adm = NULL,
85 AudioProcessing* audioproc = NULL) override { return -1; }
86 AudioProcessing* audio_processing() override { return nullptr; }
87 int Terminate() override { return -1; }
88 int CreateChannel() override { return -1; }
89 int CreateChannel(const Config& config) override { return -1; }
90 int DeleteChannel(int channel) override { return -1; }
91 int StartReceive(int channel) override { return -1; }
92 int StopReceive(int channel) override { return -1; }
93 int StartPlayout(int channel) override { return -1; }
94 int StopPlayout(int channel) override { return -1; }
95 int StartSend(int channel) override { return -1; }
96 int StopSend(int channel) override { return -1; }
97 int GetVersion(char version[1024]) override { return -1; }
98 int LastError() override { return -1; }
99 AudioTransport* audio_transport() { return nullptr; }
100 int AssociateSendChannel(int channel, int accociate_send_channel) override {
101 return -1;
102 }
103
104 // VoECodec
105 int NumOfCodecs() override { return -1; }
106 int GetCodec(int index, CodecInst& codec) override { return -1; }
107 int SetSendCodec(int channel, const CodecInst& codec) override { return -1; }
108 int GetSendCodec(int channel, CodecInst& codec) override { return -1; }
109 int SetBitRate(int channel, int bitrate_bps) override { return -1; }
110 int GetRecCodec(int channel, CodecInst& codec) override {
111 EXPECT_EQ(channel, kReceiveChannelId);
112 codec = GetRecvRecCodecInst();
113 return 0;
114 }
115 int SetRecPayloadType(int channel, const CodecInst& codec) override {
116 return -1;
117 }
118 int GetRecPayloadType(int channel, CodecInst& codec) override { return -1; }
119 int SetSendCNPayloadType(int channel, int type,
120 PayloadFrequencies frequency = kFreq16000Hz) override { return -1; }
121 int SetVADStatus(int channel,
122 bool enable,
123 VadModes mode = kVadConventional,
124 bool disableDTX = false) override { return -1; }
125 int GetVADStatus(int channel,
126 bool& enabled,
127 VadModes& mode,
128 bool& disabledDTX) override { return -1; }
129 int SetOpusMaxPlaybackRate(int channel, int frequency_hz) override {
130 return -1;
131 }
132 int SetOpusDtx(int channel, bool enable_dtx) override { return -1; }
133 RtcEventLog* GetEventLog() override { return nullptr; }
134
135 // VoEDtmf
136 int SendTelephoneEvent(int channel,
137 int eventCode,
138 bool outOfBand = true,
139 int lengthMs = 160,
140 int attenuationDb = 10) override { return -1; }
141 int SetSendTelephoneEventPayloadType(int channel,
142 unsigned char type) override {
143 return -1;
144 }
145 int GetSendTelephoneEventPayloadType(int channel,
146 unsigned char& type) override {
147 return -1;
148 }
149 int SetDtmfFeedbackStatus(bool enable,
150 bool directFeedback = false) override { return -1; }
151 int GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) override {
152 return -1;
153 }
154 int PlayDtmfTone(int eventCode,
155 int lengthMs = 200,
156 int attenuationDb = 10) override { return -1; }
157
158 // VoEExternalMedia
159 int RegisterExternalMediaProcessing(
160 int channel,
161 ProcessingTypes type,
162 VoEMediaProcess& processObject) override { return -1; }
163 int DeRegisterExternalMediaProcessing(int channel,
164 ProcessingTypes type) override {
165 return -1;
166 }
167 int GetAudioFrame(int channel,
168 int desired_sample_rate_hz,
169 AudioFrame* frame) override { return -1; }
170 int SetExternalMixing(int channel, bool enable) override { return -1; }
171
172 // VoEFile
173 int StartPlayingFileLocally(
174 int channel,
175 const char fileNameUTF8[1024],
176 bool loop = false,
177 FileFormats format = kFileFormatPcm16kHzFile,
178 float volumeScaling = 1.0,
179 int startPointMs = 0,
180 int stopPointMs = 0) override { return -1; }
181 int StartPlayingFileLocally(
182 int channel,
183 InStream* stream,
184 FileFormats format = kFileFormatPcm16kHzFile,
185 float volumeScaling = 1.0,
186 int startPointMs = 0,
187 int stopPointMs = 0) override { return -1; }
188 int StopPlayingFileLocally(int channel) override { return -1; }
189 int IsPlayingFileLocally(int channel) override { return -1; }
190 int StartPlayingFileAsMicrophone(
191 int channel,
192 const char fileNameUTF8[1024],
193 bool loop = false,
194 bool mixWithMicrophone = false,
195 FileFormats format = kFileFormatPcm16kHzFile,
196 float volumeScaling = 1.0) override { return -1; }
197 int StartPlayingFileAsMicrophone(
198 int channel,
199 InStream* stream,
200 bool mixWithMicrophone = false,
201 FileFormats format = kFileFormatPcm16kHzFile,
202 float volumeScaling = 1.0) override { return -1; }
203 int StopPlayingFileAsMicrophone(int channel) override { return -1; }
204 int IsPlayingFileAsMicrophone(int channel) override { return -1; }
205 int StartRecordingPlayout(int channel,
206 const char* fileNameUTF8,
207 CodecInst* compression = NULL,
208 int maxSizeBytes = -1) override { return -1; }
209 int StopRecordingPlayout(int channel) override { return -1; }
210 int StartRecordingPlayout(int channel,
211 OutStream* stream,
212 CodecInst* compression = NULL) override {
213 return -1;
214 }
215 int StartRecordingMicrophone(const char* fileNameUTF8,
216 CodecInst* compression = NULL,
217 int maxSizeBytes = -1) override { return -1; }
218 int StartRecordingMicrophone(OutStream* stream,
219 CodecInst* compression = NULL) override {
220 return -1;
221 }
222 int StopRecordingMicrophone() override { return -1; }
223
224 // VoEHardware
225 int GetNumOfRecordingDevices(int& devices) override { return -1; }
226
227 // Gets the number of audio devices available for playout.
228 int GetNumOfPlayoutDevices(int& devices) override { return -1; }
229
230 // Gets the name of a specific recording device given by an |index|.
231 // On Windows Vista/7, it also retrieves an additional unique ID
232 // (GUID) for the recording device.
233 int GetRecordingDeviceName(int index,
234 char strNameUTF8[128],
235 char strGuidUTF8[128]) override { return -1; }
236
237 // Gets the name of a specific playout device given by an |index|.
238 // On Windows Vista/7, it also retrieves an additional unique ID
239 // (GUID) for the playout device.
240 int GetPlayoutDeviceName(int index,
241 char strNameUTF8[128],
242 char strGuidUTF8[128]) override { return -1; }
243
244 // Sets the audio device used for recording.
245 int SetRecordingDevice(
246 int index,
247 StereoChannel recordingChannel = kStereoBoth) override { return -1; }
248
249 // Sets the audio device used for playout.
250 int SetPlayoutDevice(int index) override { return -1; }
251
252 // Sets the type of audio device layer to use.
253 int SetAudioDeviceLayer(AudioLayers audioLayer) override { return -1; }
254
255 // Gets the currently used (active) audio device layer.
256 int GetAudioDeviceLayer(AudioLayers& audioLayer) override { return -1; }
257
258 // Native sample rate controls (samples/sec)
259 int SetRecordingSampleRate(unsigned int samples_per_sec) override {
260 return -1;
261 }
262 int RecordingSampleRate(unsigned int* samples_per_sec) const override {
263 return -1;
264 }
265 int SetPlayoutSampleRate(unsigned int samples_per_sec) override {
266 return -1;
267 }
268 int PlayoutSampleRate(unsigned int* samples_per_sec) const override {
269 return -1;
270 }
271
272 // Queries and controls platform audio effects on Android devices.
273 bool BuiltInAECIsAvailable() const override { return false; }
274 int EnableBuiltInAEC(bool enable) override { return -1; }
275 bool BuiltInAGCIsAvailable() const override { return false; }
276 int EnableBuiltInAGC(bool enable) override { return -1; }
277 bool BuiltInNSIsAvailable() const override { return false; }
278 int EnableBuiltInNS(bool enable) override { return -1; }
279
280 // VoENetwork
281 int RegisterExternalTransport(int channel, Transport& transport) override {
282 return -1;
283 }
284 int DeRegisterExternalTransport(int channel) override { return -1; }
285 int ReceivedRTPPacket(int channel,
286 const void* data,
287 size_t length) override { return -1; }
288 int ReceivedRTPPacket(int channel,
289 const void* data,
290 size_t length,
291 const PacketTime& packet_time) override { return -1; }
292 int ReceivedRTCPPacket(int channel,
293 const void* data,
294 size_t length) { return -1; }
295
296 // VoENetEqStats
297 int GetNetworkStatistics(int channel, NetworkStatistics& stats) override {
298 EXPECT_EQ(channel, kReceiveChannelId);
299 stats = GetRecvNetworkStats();
300 return 0;
301 }
302 int GetDecodingCallStatistics(int channel,
303 AudioDecodingCallStats* stats) const override {
304 EXPECT_EQ(channel, kReceiveChannelId);
305 EXPECT_NE(nullptr, stats);
306 *stats = GetRecvAudioDecodingCallStats();
307 return 0;
308 }
309
310 // VoERTP_RTCP
311 int SetLocalSSRC(int channel, unsigned int ssrc) override { return -1; }
312 int GetLocalSSRC(int channel, unsigned int& ssrc) override { return -1; }
313 int GetRemoteSSRC(int channel, unsigned int& ssrc) override {
314 EXPECT_EQ(channel, kReceiveChannelId);
315 ssrc = 0;
316 return 0;
317 }
318 int SetSendAudioLevelIndicationStatus(int channel,
319 bool enable,
320 unsigned char id = 1) override {
321 return -1;
322 }
323 int SetSendAbsoluteSenderTimeStatus(int channel,
324 bool enable,
325 unsigned char id) override { return -1; }
326 int SetReceiveAbsoluteSenderTimeStatus(int channel,
327 bool enable,
328 unsigned char id) override {
329 return -1;
330 }
331 int SetRTCPStatus(int channel, bool enable) override { return -1; }
332 int GetRTCPStatus(int channel, bool& enabled) override { return -1; }
333 int SetRTCP_CNAME(int channel, const char cName[256]) override { return -1; }
334 int GetRTCP_CNAME(int channel, char cName[256]) { return -1; }
335 int GetRemoteRTCP_CNAME(int channel, char cName[256]) override { return -1; }
336 int GetRemoteRTCPData(int channel,
337 unsigned int& NTPHigh,
338 unsigned int& NTPLow,
339 unsigned int& timestamp,
340 unsigned int& playoutTimestamp,
341 unsigned int* jitter = NULL,
342 unsigned short* fractionLost = NULL) override {
343 return -1;
344 }
345 int GetRTPStatistics(int channel,
346 unsigned int& averageJitterMs,
347 unsigned int& maxJitterMs,
348 unsigned int& discardedPackets) override { return -1; }
349 int GetRTCPStatistics(int channel, CallStatistics& stats) override {
350 EXPECT_EQ(channel, kReceiveChannelId);
351 stats = GetRecvCallStats();
352 return 0;
353 }
354 int GetRemoteRTCPReportBlocks(
355 int channel,
356 std::vector<ReportBlock>* receive_blocks) override { return -1; }
357 int SetNACKStatus(int channel, bool enable, int maxNoPackets) override {
358 return -1;
359 }
360
361 // VoEVideoSync
362 int GetPlayoutBufferSize(int& buffer_ms) override { return -1; }
363 int SetMinimumPlayoutDelay(int channel, int delay_ms) override { return -1; }
364 int SetInitialPlayoutDelay(int channel, int delay_ms) override { return -1; }
365 int GetDelayEstimate(int channel,
366 int* jitter_buffer_delay_ms,
367 int* playout_buffer_delay_ms) override {
368 EXPECT_EQ(channel, kReceiveChannelId);
369 *jitter_buffer_delay_ms = kRecvJitterBufferDelay;
370 *playout_buffer_delay_ms = kRecvPlayoutBufferDelay;
371 return 0;
372 }
373 int GetLeastRequiredDelayMs(int channel) const override { return -1; }
374 int SetInitTimestamp(int channel, unsigned int timestamp) override {
375 return -1;
376 }
377 int SetInitSequenceNumber(int channel, short sequenceNumber) override {
378 return -1;
379 }
380 int GetPlayoutTimestamp(int channel, unsigned int& timestamp) override {
381 return -1;
382 }
383 int GetRtpRtcp(int channel,
384 RtpRtcp** rtpRtcpModule,
385 RtpReceiver** rtp_receiver) override { return -1; }
386
387 // VoEVolumeControl
388 int SetSpeakerVolume(unsigned int volume) override { return -1; }
389 int GetSpeakerVolume(unsigned int& volume) override { return -1; }
390 int SetMicVolume(unsigned int volume) override { return -1; }
391 int GetMicVolume(unsigned int& volume) override { return -1; }
392 int SetInputMute(int channel, bool enable) override { return -1; }
393 int GetInputMute(int channel, bool& enabled) override { return -1; }
394 int GetSpeechInputLevel(unsigned int& level) override { return -1; }
395 int GetSpeechOutputLevel(int channel, unsigned int& level) override {
396 return -1;
397 }
398 int GetSpeechInputLevelFullRange(unsigned int& level) override { return -1; }
399 int GetSpeechOutputLevelFullRange(int channel,
400 unsigned int& level) override {
401 EXPECT_EQ(channel, kReceiveChannelId);
402 level = kRecvSpeechOutputLevel;
403 return 0;
404 }
405 int SetChannelOutputVolumeScaling(int channel, float scaling) override {
406 return -1;
407 }
408 int GetChannelOutputVolumeScaling(int channel, float& scaling) override {
409 return -1;
410 }
411 int SetOutputVolumePan(int channel, float left, float right) override {
412 return -1;
413 }
414 int GetOutputVolumePan(int channel, float& left, float& right) override {
415 return -1;
416 }
417 };
418 } // namespace test
419 } // namespace webrtc
420
421 #endif // WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_
OLDNEW
« no previous file with comments | « webrtc/test/call_test.cc ('k') | webrtc/test/webrtc_test_common.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698