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

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

Issue 1414743004: Implement AudioSendStream::GetStats(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: workaround for android build issue 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.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
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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_AUDIO_FAKE_VOICE_ENGINE_H_ 11 #ifndef WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_
12 #define WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_ 12 #define WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_
13 13
14 #include <vector> 14 #include <vector>
15 15
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 #include "webrtc/voice_engine/voice_engine_impl.h" 18 #include "webrtc/voice_engine/voice_engine_impl.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 namespace test { 21 namespace test {
22 22
23 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be 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(). 24 // able to get the various interfaces as usual, via T::GetInterface().
25 class FakeVoiceEngine final : public VoiceEngineImpl { 25 class FakeVoiceEngine final : public VoiceEngineImpl {
26 public: 26 public:
27 const int kSendChannelId = 1; 27 static const int kSendChannelId;
28 const int kReceiveChannelId = 2; 28 static const int kRecvChannelId;
29 29 static const uint32_t kSendSsrc;
30 const int kRecvJitterBufferDelay = -7; 30 static const uint32_t kRecvSsrc;
31 const int kRecvPlayoutBufferDelay = 302; 31 static const int kSendEchoDelayMedian;
32 const unsigned int kRecvSpeechOutputLevel = 99; 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;
33 46
34 FakeVoiceEngine() : VoiceEngineImpl(new Config(), true) { 47 FakeVoiceEngine() : VoiceEngineImpl(new Config(), true) {
35 // Increase ref count so this object isn't automatically deleted whenever 48 // Increase ref count so this object isn't automatically deleted whenever
36 // interfaces are Release():d. 49 // interfaces are Release():d.
37 ++_ref_count; 50 ++_ref_count;
38 } 51 }
39 ~FakeVoiceEngine() override { 52 ~FakeVoiceEngine() override {
40 // Decrease ref count before base class d-tor is called; otherwise it will 53 // Decrease ref count before base class d-tor is called; otherwise it will
41 // trigger an assertion. 54 // trigger an assertion.
42 --_ref_count; 55 --_ref_count;
43 } 56 }
44 57
45 const CallStatistics& GetRecvCallStats() const { 58 // VoEAudioProcessing
46 static const CallStatistics kStats = { 59 int SetNsStatus(bool enable, NsModes mode = kNsUnchanged) override {
47 345, 678, 901, 234, -1, 0, 0, 567, 890, 123 60 return -1;
48 };
49 return kStats;
50 } 61 }
51 62 int GetNsStatus(bool& enabled, NsModes& mode) override { return -1; }
52 const CodecInst& GetRecvRecCodecInst() const { 63 int SetAgcStatus(bool enable, AgcModes mode = kAgcUnchanged) override {
53 static const CodecInst kStats = { 64 return -1;
54 123, "codec_name", 96000, -1, -1, -1
55 };
56 return kStats;
57 } 65 }
58 66 int GetAgcStatus(bool& enabled, AgcModes& mode) override { return -1; }
59 const NetworkStatistics& GetRecvNetworkStats() const { 67 int SetAgcConfig(AgcConfig config) override { return -1; }
60 static const NetworkStatistics kStats = { 68 int GetAgcConfig(AgcConfig& config) override { return -1; }
61 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0 69 int SetEcStatus(bool enable, EcModes mode = kEcUnchanged) override {
62 }; 70 return -1;
63 return kStats;
64 } 71 }
65 72 int GetEcStatus(bool& enabled, EcModes& mode) override { return -1; }
66 const AudioDecodingCallStats& GetRecvAudioDecodingCallStats() const { 73 int EnableDriftCompensation(bool enable) override { return -1; }
67 static AudioDecodingCallStats stats; 74 bool DriftCompensationEnabled() override { return false; }
68 if (stats.calls_to_silence_generator == 0) { 75 void SetDelayOffsetMs(int offset) override {}
69 stats.calls_to_silence_generator = 234; 76 int DelayOffsetMs() override { return -1; }
70 stats.calls_to_neteq = 567; 77 int SetAecmMode(AecmModes mode = kAecmSpeakerphone,
71 stats.decoded_normal = 890; 78 bool enableCNG = true) override { return -1; }
72 stats.decoded_plc = 123; 79 int GetAecmMode(AecmModes& mode, bool& enabledCNG) override { return -1; }
73 stats.decoded_cng = 456; 80 int EnableHighPassFilter(bool enable) override { return -1; }
74 stats.decoded_plc_cng = 789; 81 bool IsHighPassFilterEnabled() override { return false; }
75 } 82 int SetRxNsStatus(int channel,
76 return stats; 83 bool enable,
84 NsModes mode = kNsUnchanged) override { return -1; }
85 int GetRxNsStatus(int channel, bool& enabled, NsModes& mode) override {
86 return -1;
77 } 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; }
78 135
79 // VoEBase 136 // VoEBase
80 int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override { 137 int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override {
81 return -1; 138 return -1;
82 } 139 }
83 int DeRegisterVoiceEngineObserver() override { return -1; } 140 int DeRegisterVoiceEngineObserver() override { return -1; }
84 int Init(AudioDeviceModule* external_adm = NULL, 141 int Init(AudioDeviceModule* external_adm = NULL,
85 AudioProcessing* audioproc = NULL) override { return -1; } 142 AudioProcessing* audioproc = NULL) override { return -1; }
86 AudioProcessing* audio_processing() override { return nullptr; } 143 AudioProcessing* audio_processing() override { return nullptr; }
87 int Terminate() override { return -1; } 144 int Terminate() override { return -1; }
(...skipping 10 matching lines...) Expand all
98 int LastError() override { return -1; } 155 int LastError() override { return -1; }
99 AudioTransport* audio_transport() { return nullptr; } 156 AudioTransport* audio_transport() { return nullptr; }
100 int AssociateSendChannel(int channel, int accociate_send_channel) override { 157 int AssociateSendChannel(int channel, int accociate_send_channel) override {
101 return -1; 158 return -1;
102 } 159 }
103 160
104 // VoECodec 161 // VoECodec
105 int NumOfCodecs() override { return -1; } 162 int NumOfCodecs() override { return -1; }
106 int GetCodec(int index, CodecInst& codec) override { return -1; } 163 int GetCodec(int index, CodecInst& codec) override { return -1; }
107 int SetSendCodec(int channel, const CodecInst& codec) override { return -1; } 164 int SetSendCodec(int channel, const CodecInst& codec) override { return -1; }
108 int GetSendCodec(int channel, 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 }
109 int SetBitRate(int channel, int bitrate_bps) override { return -1; } 170 int SetBitRate(int channel, int bitrate_bps) override { return -1; }
110 int GetRecCodec(int channel, CodecInst& codec) override { 171 int GetRecCodec(int channel, CodecInst& codec) override {
111 EXPECT_EQ(channel, kReceiveChannelId); 172 EXPECT_EQ(channel, kRecvChannelId);
112 codec = GetRecvRecCodecInst(); 173 codec = kRecvCodecInst;
113 return 0; 174 return 0;
114 } 175 }
115 int SetRecPayloadType(int channel, const CodecInst& codec) override { 176 int SetRecPayloadType(int channel, const CodecInst& codec) override {
116 return -1; 177 return -1;
117 } 178 }
118 int GetRecPayloadType(int channel, CodecInst& codec) override { return -1; } 179 int GetRecPayloadType(int channel, CodecInst& codec) override { return -1; }
119 int SetSendCNPayloadType(int channel, int type, 180 int SetSendCNPayloadType(int channel, int type,
120 PayloadFrequencies frequency = kFreq16000Hz) override { return -1; } 181 PayloadFrequencies frequency = kFreq16000Hz) override { return -1; }
121 int SetVADStatus(int channel, 182 int SetVADStatus(int channel,
122 bool enable, 183 bool enable,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 int ReceivedRTPPacket(int channel, 349 int ReceivedRTPPacket(int channel,
289 const void* data, 350 const void* data,
290 size_t length, 351 size_t length,
291 const PacketTime& packet_time) override { return -1; } 352 const PacketTime& packet_time) override { return -1; }
292 int ReceivedRTCPPacket(int channel, 353 int ReceivedRTCPPacket(int channel,
293 const void* data, 354 const void* data,
294 size_t length) { return -1; } 355 size_t length) { return -1; }
295 356
296 // VoENetEqStats 357 // VoENetEqStats
297 int GetNetworkStatistics(int channel, NetworkStatistics& stats) override { 358 int GetNetworkStatistics(int channel, NetworkStatistics& stats) override {
298 EXPECT_EQ(channel, kReceiveChannelId); 359 EXPECT_EQ(channel, kRecvChannelId);
299 stats = GetRecvNetworkStats(); 360 stats = kRecvNetworkStats;
300 return 0; 361 return 0;
301 } 362 }
302 int GetDecodingCallStatistics(int channel, 363 int GetDecodingCallStatistics(int channel,
303 AudioDecodingCallStats* stats) const override { 364 AudioDecodingCallStats* stats) const override {
304 EXPECT_EQ(channel, kReceiveChannelId); 365 EXPECT_EQ(channel, kRecvChannelId);
305 EXPECT_NE(nullptr, stats); 366 EXPECT_NE(nullptr, stats);
306 *stats = GetRecvAudioDecodingCallStats(); 367 *stats = kRecvAudioDecodingCallStats;
307 return 0; 368 return 0;
308 } 369 }
309 370
310 // VoERTP_RTCP 371 // VoERTP_RTCP
311 int SetLocalSSRC(int channel, unsigned int ssrc) override { return -1; } 372 int SetLocalSSRC(int channel, unsigned int ssrc) override { return -1; }
312 int GetLocalSSRC(int channel, unsigned int& ssrc) override { return -1; } 373 int GetLocalSSRC(int channel, unsigned int& ssrc) override {
313 int GetRemoteSSRC(int channel, unsigned int& ssrc) override { 374 EXPECT_EQ(channel, kSendChannelId);
314 EXPECT_EQ(channel, kReceiveChannelId);
315 ssrc = 0; 375 ssrc = 0;
316 return 0; 376 return 0;
317 } 377 }
378 int GetRemoteSSRC(int channel, unsigned int& ssrc) override {
379 EXPECT_EQ(channel, kRecvChannelId);
380 ssrc = 0;
381 return 0;
382 }
318 int SetSendAudioLevelIndicationStatus(int channel, 383 int SetSendAudioLevelIndicationStatus(int channel,
319 bool enable, 384 bool enable,
320 unsigned char id = 1) override { 385 unsigned char id = 1) override {
321 return -1; 386 return -1;
322 } 387 }
323 int SetSendAbsoluteSenderTimeStatus(int channel, 388 int SetSendAbsoluteSenderTimeStatus(int channel,
324 bool enable, 389 bool enable,
325 unsigned char id) override { return -1; } 390 unsigned char id) override { return -1; }
326 int SetReceiveAbsoluteSenderTimeStatus(int channel, 391 int SetReceiveAbsoluteSenderTimeStatus(int channel,
327 bool enable, 392 bool enable,
(...skipping 12 matching lines...) Expand all
340 unsigned int& playoutTimestamp, 405 unsigned int& playoutTimestamp,
341 unsigned int* jitter = NULL, 406 unsigned int* jitter = NULL,
342 unsigned short* fractionLost = NULL) override { 407 unsigned short* fractionLost = NULL) override {
343 return -1; 408 return -1;
344 } 409 }
345 int GetRTPStatistics(int channel, 410 int GetRTPStatistics(int channel,
346 unsigned int& averageJitterMs, 411 unsigned int& averageJitterMs,
347 unsigned int& maxJitterMs, 412 unsigned int& maxJitterMs,
348 unsigned int& discardedPackets) override { return -1; } 413 unsigned int& discardedPackets) override { return -1; }
349 int GetRTCPStatistics(int channel, CallStatistics& stats) override { 414 int GetRTCPStatistics(int channel, CallStatistics& stats) override {
350 EXPECT_EQ(channel, kReceiveChannelId); 415 if (channel == kSendChannelId) {
351 stats = GetRecvCallStats(); 416 stats = kSendCallStats;
417 } else {
418 EXPECT_EQ(channel, kRecvChannelId);
419 stats = kRecvCallStats;
420 }
352 return 0; 421 return 0;
353 } 422 }
354 int GetRemoteRTCPReportBlocks( 423 int GetRemoteRTCPReportBlocks(
355 int channel, 424 int channel,
356 std::vector<ReportBlock>* receive_blocks) override { return -1; } 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 }
357 int SetNACKStatus(int channel, bool enable, int maxNoPackets) override { 437 int SetNACKStatus(int channel, bool enable, int maxNoPackets) override {
358 return -1; 438 return -1;
359 } 439 }
360 440
361 // VoEVideoSync 441 // VoEVideoSync
362 int GetPlayoutBufferSize(int& buffer_ms) override { return -1; } 442 int GetPlayoutBufferSize(int& buffer_ms) override { return -1; }
363 int SetMinimumPlayoutDelay(int channel, int delay_ms) override { return -1; } 443 int SetMinimumPlayoutDelay(int channel, int delay_ms) override { return -1; }
364 int SetInitialPlayoutDelay(int channel, int delay_ms) override { return -1; } 444 int SetInitialPlayoutDelay(int channel, int delay_ms) override { return -1; }
365 int GetDelayEstimate(int channel, 445 int GetDelayEstimate(int channel,
366 int* jitter_buffer_delay_ms, 446 int* jitter_buffer_delay_ms,
367 int* playout_buffer_delay_ms) override { 447 int* playout_buffer_delay_ms) override {
368 EXPECT_EQ(channel, kReceiveChannelId); 448 EXPECT_EQ(channel, kRecvChannelId);
369 *jitter_buffer_delay_ms = kRecvJitterBufferDelay; 449 *jitter_buffer_delay_ms = kRecvJitterBufferDelay;
370 *playout_buffer_delay_ms = kRecvPlayoutBufferDelay; 450 *playout_buffer_delay_ms = kRecvPlayoutBufferDelay;
371 return 0; 451 return 0;
372 } 452 }
373 int GetLeastRequiredDelayMs(int channel) const override { return -1; } 453 int GetLeastRequiredDelayMs(int channel) const override { return -1; }
374 int SetInitTimestamp(int channel, unsigned int timestamp) override { 454 int SetInitTimestamp(int channel, unsigned int timestamp) override {
375 return -1; 455 return -1;
376 } 456 }
377 int SetInitSequenceNumber(int channel, short sequenceNumber) override { 457 int SetInitSequenceNumber(int channel, short sequenceNumber) override {
378 return -1; 458 return -1;
379 } 459 }
380 int GetPlayoutTimestamp(int channel, unsigned int& timestamp) override { 460 int GetPlayoutTimestamp(int channel, unsigned int& timestamp) override {
381 return -1; 461 return -1;
382 } 462 }
383 int GetRtpRtcp(int channel, 463 int GetRtpRtcp(int channel,
384 RtpRtcp** rtpRtcpModule, 464 RtpRtcp** rtpRtcpModule,
385 RtpReceiver** rtp_receiver) override { return -1; } 465 RtpReceiver** rtp_receiver) override { return -1; }
386 466
387 // VoEVolumeControl 467 // VoEVolumeControl
388 int SetSpeakerVolume(unsigned int volume) override { return -1; } 468 int SetSpeakerVolume(unsigned int volume) override { return -1; }
389 int GetSpeakerVolume(unsigned int& volume) override { return -1; } 469 int GetSpeakerVolume(unsigned int& volume) override { return -1; }
390 int SetMicVolume(unsigned int volume) override { return -1; } 470 int SetMicVolume(unsigned int volume) override { return -1; }
391 int GetMicVolume(unsigned int& volume) override { return -1; } 471 int GetMicVolume(unsigned int& volume) override { return -1; }
392 int SetInputMute(int channel, bool enable) override { return -1; } 472 int SetInputMute(int channel, bool enable) override { return -1; }
393 int GetInputMute(int channel, bool& enabled) override { return -1; } 473 int GetInputMute(int channel, bool& enabled) override { return -1; }
394 int GetSpeechInputLevel(unsigned int& level) override { return -1; } 474 int GetSpeechInputLevel(unsigned int& level) override { return -1; }
395 int GetSpeechOutputLevel(int channel, unsigned int& level) override { 475 int GetSpeechOutputLevel(int channel, unsigned int& level) override {
396 return -1; 476 return -1;
397 } 477 }
398 int GetSpeechInputLevelFullRange(unsigned int& level) override { return -1; } 478 int GetSpeechInputLevelFullRange(unsigned int& level) override {
479 level = kSendSpeechInputLevel;
480 return 0;
481 }
399 int GetSpeechOutputLevelFullRange(int channel, 482 int GetSpeechOutputLevelFullRange(int channel,
400 unsigned int& level) override { 483 unsigned int& level) override {
401 EXPECT_EQ(channel, kReceiveChannelId); 484 EXPECT_EQ(channel, kRecvChannelId);
402 level = kRecvSpeechOutputLevel; 485 level = kRecvSpeechOutputLevel;
403 return 0; 486 return 0;
404 } 487 }
405 int SetChannelOutputVolumeScaling(int channel, float scaling) override { 488 int SetChannelOutputVolumeScaling(int channel, float scaling) override {
406 return -1; 489 return -1;
407 } 490 }
408 int GetChannelOutputVolumeScaling(int channel, float& scaling) override { 491 int GetChannelOutputVolumeScaling(int channel, float& scaling) override {
409 return -1; 492 return -1;
410 } 493 }
411 int SetOutputVolumePan(int channel, float left, float right) override { 494 int SetOutputVolumePan(int channel, float left, float right) override {
412 return -1; 495 return -1;
413 } 496 }
414 int GetOutputVolumePan(int channel, float& left, float& right) override { 497 int GetOutputVolumePan(int channel, float& left, float& right) override {
415 return -1; 498 return -1;
416 } 499 }
417 }; 500 };
418 } // namespace test 501 } // namespace test
419 } // namespace webrtc 502 } // namespace webrtc
420 503
421 #endif // WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_ 504 #endif // WEBRTC_AUDIO_FAKE_VOICE_ENGINE_H_
OLDNEW
« no previous file with comments | « webrtc/call/call.cc ('k') | webrtc/test/fake_voice_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698