Chromium Code Reviews| Index: webrtc/test/fake_voice_engine.h |
| diff --git a/webrtc/test/fake_voice_engine.h b/webrtc/test/fake_voice_engine.h |
| index 72f6b27dd2e3c6d995427e4aa4ae9c53ee238926..2ef3d058f7d9ba83572c8e81e65983983c0b1f98 100644 |
| --- a/webrtc/test/fake_voice_engine.h |
| +++ b/webrtc/test/fake_voice_engine.h |
| @@ -25,10 +25,16 @@ namespace test { |
| class FakeVoiceEngine final : public VoiceEngineImpl { |
| public: |
| const int kSendChannelId = 1; |
| - const int kReceiveChannelId = 2; |
| - |
| + const int kRecvChannelId = 2; |
|
tommi
2015/10/23 12:50:37
I think these should all be static and be referenc
the sun
2015/10/23 15:14:17
Ok, you get the .cc :)
|
| + const uint32_t kSendSsrc = 665; |
| + const uint32_t kRecvSsrc = 667; |
| + const int kSendEchoDelayMedian = 254; |
| + const int kSendEchoDelayStdDev = -3; |
| + const int kSendEchoReturnLoss = -65; |
| + const int kSendEchoReturnLossEnhancement = 101; |
| const int kRecvJitterBufferDelay = -7; |
| const int kRecvPlayoutBufferDelay = 302; |
| + const unsigned int kSendSpeechInputLevel = 96; |
| const unsigned int kRecvSpeechOutputLevel = 99; |
| FakeVoiceEngine() : VoiceEngineImpl(new Config(), true) { |
| @@ -42,16 +48,37 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| --_ref_count; |
| } |
| + const CallStatistics& GetSendCallStats() const { |
| + static const CallStatistics kStats = { |
|
tommi
2015/10/23 12:50:37
I'm a bit on the fence whether using statics like
the sun
2015/10/23 15:14:17
I've made this static const structs and moved them
kwiberg-webrtc
2015/10/25 02:07:43
CallStatistics looks like a POD to me (if I'm look
the sun
2015/10/26 09:11:02
So now that the structs are static const members o
|
| + 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123 |
| + }; |
| + return kStats; |
| + } |
| + |
| + const CodecInst& GetSendCodecInst() const { |
| + static const CodecInst kStats = { |
| + -121, "codec_name_send", 48000, -231, -451, -671 |
| + }; |
| + return kStats; |
| + } |
| + |
| + const ReportBlock& GetSendReportBlock() const { |
| + static const ReportBlock kBlock = { |
| + 456, 780, 123, 567, 890, 132, 143, 13354 |
| + }; |
| + return kBlock; |
| + } |
| + |
| const CallStatistics& GetRecvCallStats() const { |
| static const CallStatistics kStats = { |
| - 345, 678, 901, 234, -1, 0, 0, 567, 890, 123 |
| + 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123 |
| }; |
| return kStats; |
| } |
| - const CodecInst& GetRecvRecCodecInst() const { |
| + const CodecInst& GetRecvCodecInst() const { |
| static const CodecInst kStats = { |
| - 123, "codec_name", 96000, -1, -1, -1 |
| + 123, "codec_name_recv", 96000, -187, -198, -103 |
| }; |
| return kStats; |
| } |
| @@ -76,6 +103,84 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| return stats; |
| } |
| + // VoEAudioProcessing |
| + int SetNsStatus(bool enable, NsModes mode = kNsUnchanged) override { |
| + return -1; |
| + } |
| + int GetNsStatus(bool& enabled, NsModes& mode) override { return -1; } |
| + int SetAgcStatus(bool enable, AgcModes mode = kAgcUnchanged) override { |
| + return -1; |
| + } |
| + int GetAgcStatus(bool& enabled, AgcModes& mode) override { return -1; } |
| + int SetAgcConfig(AgcConfig config) override { return -1; } |
| + int GetAgcConfig(AgcConfig& config) override { return -1; } |
| + int SetEcStatus(bool enable, EcModes mode = kEcUnchanged) override { |
| + return -1; |
| + } |
| + int GetEcStatus(bool& enabled, EcModes& mode) override { return -1; } |
| + int EnableDriftCompensation(bool enable) override { return -1; } |
| + bool DriftCompensationEnabled() override { return false; } |
| + void SetDelayOffsetMs(int offset) override {} |
| + int DelayOffsetMs() override { return -1; } |
| + int SetAecmMode(AecmModes mode = kAecmSpeakerphone, |
| + bool enableCNG = true) override { return -1; } |
| + int GetAecmMode(AecmModes& mode, bool& enabledCNG) override { return -1; } |
| + int EnableHighPassFilter(bool enable) override { return -1; } |
| + bool IsHighPassFilterEnabled() override { return false; } |
| + int SetRxNsStatus(int channel, |
| + bool enable, |
| + NsModes mode = kNsUnchanged) override { return -1; } |
| + int GetRxNsStatus(int channel, bool& enabled, NsModes& mode) override { |
| + return -1; |
| + } |
| + int SetRxAgcStatus(int channel, |
| + bool enable, |
| + AgcModes mode = kAgcUnchanged) override { return -1; } |
| + int GetRxAgcStatus(int channel, bool& enabled, AgcModes& mode) override { |
| + return -1; |
| + } |
| + int SetRxAgcConfig(int channel, AgcConfig config) override { return -1; } |
| + int GetRxAgcConfig(int channel, AgcConfig& config) override { return -1; } |
| + int RegisterRxVadObserver(int channel, |
| + VoERxVadCallback& observer) override { return -1; } |
| + int DeRegisterRxVadObserver(int channel) override { return -1; } |
| + int VoiceActivityIndicator(int channel) override { return -1; } |
| + int SetEcMetricsStatus(bool enable) override { return -1; } |
| + int GetEcMetricsStatus(bool& enabled) override { |
| + enabled = true; |
| + return 0; |
| + } |
| + int GetEchoMetrics(int& ERL, int& ERLE, int& RERL, int& A_NLP) override { |
| + ERL = kSendEchoReturnLoss; |
| + ERLE = kSendEchoReturnLossEnhancement; |
| + RERL = -123456789; |
| + A_NLP = 123456789; |
| + return 0; |
| + } |
| + int GetEcDelayMetrics(int& delay_median, |
| + int& delay_std, |
| + float& fraction_poor_delays) override { |
| + delay_median = kSendEchoDelayMedian; |
| + delay_std = kSendEchoDelayStdDev; |
| + fraction_poor_delays = -12345.7890; |
| + return 0; |
| + } |
| + int StartDebugRecording(const char* fileNameUTF8) override { return -1; } |
| + int StartDebugRecording(FILE* file_handle) override { return -1; } |
| + int StopDebugRecording() override { return -1; } |
| + int SetTypingDetectionStatus(bool enable) override { return -1; } |
| + int GetTypingDetectionStatus(bool& enabled) override { return -1; } |
| + int TimeSinceLastTyping(int& seconds) override { return -1; } |
| + int SetTypingDetectionParameters(int timeWindow, |
| + int costPerTyping, |
| + int reportingThreshold, |
| + int penaltyDecay, |
| + int typeEventDelay = 0) override { |
| + return -1; |
| + } |
| + void EnableStereoChannelSwapping(bool enable) override {} |
| + bool IsStereoChannelSwappingEnabled() override { return false; } |
| + |
| // VoEBase |
| int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override { |
| return -1; |
| @@ -105,11 +210,15 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| int NumOfCodecs() override { return -1; } |
| int GetCodec(int index, CodecInst& codec) override { return -1; } |
| int SetSendCodec(int channel, const CodecInst& codec) override { return -1; } |
| - int GetSendCodec(int channel, CodecInst& codec) override { return -1; } |
| + int GetSendCodec(int channel, CodecInst& codec) override { |
| + EXPECT_EQ(channel, kSendChannelId); |
| + codec = GetSendCodecInst(); |
| + return 0; |
| + } |
| int SetBitRate(int channel, int bitrate_bps) override { return -1; } |
| int GetRecCodec(int channel, CodecInst& codec) override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| - codec = GetRecvRecCodecInst(); |
| + EXPECT_EQ(channel, kRecvChannelId); |
| + codec = GetRecvCodecInst(); |
| return 0; |
| } |
| int SetRecPayloadType(int channel, const CodecInst& codec) override { |
| @@ -295,13 +404,13 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| // VoENetEqStats |
| int GetNetworkStatistics(int channel, NetworkStatistics& stats) override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| + EXPECT_EQ(channel, kRecvChannelId); |
| stats = GetRecvNetworkStats(); |
| return 0; |
| } |
| int GetDecodingCallStatistics(int channel, |
| AudioDecodingCallStats* stats) const override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| + EXPECT_EQ(channel, kRecvChannelId); |
| EXPECT_NE(nullptr, stats); |
| *stats = GetRecvAudioDecodingCallStats(); |
| return 0; |
| @@ -309,9 +418,13 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| // VoERTP_RTCP |
| int SetLocalSSRC(int channel, unsigned int ssrc) override { return -1; } |
| - int GetLocalSSRC(int channel, unsigned int& ssrc) override { return -1; } |
| + int GetLocalSSRC(int channel, unsigned int& ssrc) override { |
| + EXPECT_EQ(channel, kSendChannelId); |
| + ssrc = 0; |
| + return 0; |
| + } |
| int GetRemoteSSRC(int channel, unsigned int& ssrc) override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| + EXPECT_EQ(channel, kRecvChannelId); |
| ssrc = 0; |
| return 0; |
| } |
| @@ -347,13 +460,28 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| unsigned int& maxJitterMs, |
| unsigned int& discardedPackets) override { return -1; } |
| int GetRTCPStatistics(int channel, CallStatistics& stats) override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| - stats = GetRecvCallStats(); |
| + if (channel == kSendChannelId) { |
| + stats = GetSendCallStats(); |
| + } else { |
| + EXPECT_EQ(channel, kRecvChannelId); |
| + stats = GetRecvCallStats(); |
| + } |
| return 0; |
| } |
| int GetRemoteRTCPReportBlocks( |
| int channel, |
| - std::vector<ReportBlock>* receive_blocks) override { return -1; } |
| + std::vector<ReportBlock>* receive_blocks) override { |
| + EXPECT_EQ(channel, kSendChannelId); |
| + EXPECT_NE(receive_blocks, nullptr); |
| + EXPECT_EQ(receive_blocks->size(), 0u); |
| + webrtc::ReportBlock block = GetSendReportBlock(); |
| + receive_blocks->push_back(block); // Has wrong SSRC. |
| + block.source_SSRC = kSendSsrc; |
| + receive_blocks->push_back(block); // Correct block. |
| + block.fraction_lost = 0; |
| + receive_blocks->push_back(block); // Duplicate SSRC, bad fraction_lost. |
| + return 0; |
| + } |
| int SetNACKStatus(int channel, bool enable, int maxNoPackets) override { |
| return -1; |
| } |
| @@ -365,7 +493,7 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| int GetDelayEstimate(int channel, |
| int* jitter_buffer_delay_ms, |
| int* playout_buffer_delay_ms) override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| + EXPECT_EQ(channel, kRecvChannelId); |
| *jitter_buffer_delay_ms = kRecvJitterBufferDelay; |
| *playout_buffer_delay_ms = kRecvPlayoutBufferDelay; |
| return 0; |
| @@ -395,10 +523,13 @@ class FakeVoiceEngine final : public VoiceEngineImpl { |
| int GetSpeechOutputLevel(int channel, unsigned int& level) override { |
| return -1; |
| } |
| - int GetSpeechInputLevelFullRange(unsigned int& level) override { return -1; } |
| + int GetSpeechInputLevelFullRange(unsigned int& level) override { |
| + level = kSendSpeechInputLevel; |
| + return 0; |
| + } |
| int GetSpeechOutputLevelFullRange(int channel, |
| unsigned int& level) override { |
| - EXPECT_EQ(channel, kReceiveChannelId); |
| + EXPECT_EQ(channel, kRecvChannelId); |
| level = kRecvSpeechOutputLevel; |
| return 0; |
| } |