| OLD | NEW |
| 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 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 #include "webrtc/audio/audio_receive_stream.h" | 13 #include "webrtc/audio/audio_receive_stream.h" |
| 14 #include "webrtc/audio/conversion.h" | 14 #include "webrtc/audio/conversion.h" |
| 15 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" | 15 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 17 #include "webrtc/test/mock_voe_channel_proxy.h" |
| 17 #include "webrtc/test/mock_voice_engine.h" | 18 #include "webrtc/test/mock_voice_engine.h" |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 namespace test { | 21 namespace test { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 using testing::_; | 24 using testing::_; |
| 24 using testing::Return; | 25 using testing::Return; |
| 25 | 26 |
| 26 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { | 27 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 const CallStatistics kCallStats = { | 47 const CallStatistics kCallStats = { |
| 47 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; | 48 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; |
| 48 const CodecInst kCodecInst = { | 49 const CodecInst kCodecInst = { |
| 49 123, "codec_name_recv", 96000, -187, -198, -103}; | 50 123, "codec_name_recv", 96000, -187, -198, -103}; |
| 50 const NetworkStatistics kNetworkStats = { | 51 const NetworkStatistics kNetworkStats = { |
| 51 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; | 52 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; |
| 52 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); | 53 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); |
| 53 | 54 |
| 54 struct ConfigHelper { | 55 struct ConfigHelper { |
| 55 ConfigHelper() { | 56 ConfigHelper() { |
| 57 using testing::Invoke; |
| 58 |
| 56 EXPECT_CALL(voice_engine_, | 59 EXPECT_CALL(voice_engine_, |
| 57 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 60 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
| 58 EXPECT_CALL(voice_engine_, | 61 EXPECT_CALL(voice_engine_, |
| 59 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 62 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
| 60 AudioState::Config config; | 63 AudioState::Config config; |
| 61 config.voice_engine = &voice_engine_; | 64 config.voice_engine = &voice_engine_; |
| 62 audio_state_ = AudioState::Create(config); | 65 audio_state_ = AudioState::Create(config); |
| 63 | 66 |
| 64 EXPECT_CALL(voice_engine_, SetLocalSSRC(kChannelId, kLocalSsrc)) | 67 EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId)) |
| 65 .WillOnce(Return(0)); | 68 .WillOnce(Invoke([this](int channel_id) { |
| 69 EXPECT_FALSE(channel_proxy_); |
| 70 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); |
| 71 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kLocalSsrc)).Times(1); |
| 72 return channel_proxy_; |
| 73 })); |
| 66 EXPECT_CALL(voice_engine_, | 74 EXPECT_CALL(voice_engine_, |
| 67 SetReceiveAbsoluteSenderTimeStatus(kChannelId, true, kAbsSendTimeId)) | 75 SetReceiveAbsoluteSenderTimeStatus(kChannelId, true, kAbsSendTimeId)) |
| 68 .WillOnce(Return(0)); | 76 .WillOnce(Return(0)); |
| 69 EXPECT_CALL(voice_engine_, | 77 EXPECT_CALL(voice_engine_, |
| 70 SetReceiveAudioLevelIndicationStatus(kChannelId, true, kAudioLevelId)) | 78 SetReceiveAudioLevelIndicationStatus(kChannelId, true, kAudioLevelId)) |
| 71 .WillOnce(Return(0)); | 79 .WillOnce(Return(0)); |
| 72 stream_config_.voe_channel_id = kChannelId; | 80 stream_config_.voe_channel_id = kChannelId; |
| 73 stream_config_.rtp.local_ssrc = kLocalSsrc; | 81 stream_config_.rtp.local_ssrc = kLocalSsrc; |
| 74 stream_config_.rtp.remote_ssrc = kRemoteSsrc; | 82 stream_config_.rtp.remote_ssrc = kRemoteSsrc; |
| 75 stream_config_.rtp.extensions.push_back( | 83 stream_config_.rtp.extensions.push_back( |
| 76 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); | 84 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); |
| 77 stream_config_.rtp.extensions.push_back( | 85 stream_config_.rtp.extensions.push_back( |
| 78 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId)); | 86 RtpExtension(RtpExtension::kAudioLevel, kAudioLevelId)); |
| 79 } | 87 } |
| 80 | 88 |
| 81 MockRemoteBitrateEstimator* remote_bitrate_estimator() { | 89 MockRemoteBitrateEstimator* remote_bitrate_estimator() { |
| 82 return &remote_bitrate_estimator_; | 90 return &remote_bitrate_estimator_; |
| 83 } | 91 } |
| 84 AudioReceiveStream::Config& config() { return stream_config_; } | 92 AudioReceiveStream::Config& config() { return stream_config_; } |
| 85 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } | 93 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } |
| 86 MockVoiceEngine& voice_engine() { return voice_engine_; } | 94 MockVoiceEngine& voice_engine() { return voice_engine_; } |
| 87 | 95 |
| 88 void SetupMockForGetStats() { | 96 void SetupMockForGetStats() { |
| 89 using testing::DoAll; | 97 using testing::DoAll; |
| 90 using testing::SetArgPointee; | 98 using testing::SetArgPointee; |
| 91 using testing::SetArgReferee; | 99 using testing::SetArgReferee; |
| 100 |
| 92 EXPECT_CALL(voice_engine_, GetRTCPStatistics(kChannelId, _)) | 101 EXPECT_CALL(voice_engine_, GetRTCPStatistics(kChannelId, _)) |
| 93 .WillOnce(DoAll(SetArgReferee<1>(kCallStats), Return(0))); | 102 .WillOnce(DoAll(SetArgReferee<1>(kCallStats), Return(0))); |
| 94 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) | 103 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) |
| 95 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); | 104 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); |
| 96 EXPECT_CALL(voice_engine_, GetDelayEstimate(kChannelId, _, _)) | 105 EXPECT_CALL(voice_engine_, GetDelayEstimate(kChannelId, _, _)) |
| 97 .WillOnce(DoAll(SetArgPointee<1>(kJitterBufferDelay), | 106 .WillOnce(DoAll(SetArgPointee<1>(kJitterBufferDelay), |
| 98 SetArgPointee<2>(kPlayoutBufferDelay), Return(0))); | 107 SetArgPointee<2>(kPlayoutBufferDelay), Return(0))); |
| 99 EXPECT_CALL(voice_engine_, | 108 EXPECT_CALL(voice_engine_, |
| 100 GetSpeechOutputLevelFullRange(kChannelId, _)).WillOnce( | 109 GetSpeechOutputLevelFullRange(kChannelId, _)).WillOnce( |
| 101 DoAll(SetArgReferee<1>(kSpeechOutputLevel), Return(0))); | 110 DoAll(SetArgReferee<1>(kSpeechOutputLevel), Return(0))); |
| 102 EXPECT_CALL(voice_engine_, GetNetworkStatistics(kChannelId, _)) | 111 EXPECT_CALL(voice_engine_, GetNetworkStatistics(kChannelId, _)) |
| 103 .WillOnce(DoAll(SetArgReferee<1>(kNetworkStats), Return(0))); | 112 .WillOnce(DoAll(SetArgReferee<1>(kNetworkStats), Return(0))); |
| 104 EXPECT_CALL(voice_engine_, GetDecodingCallStatistics(kChannelId, _)) | 113 EXPECT_CALL(voice_engine_, GetDecodingCallStatistics(kChannelId, _)) |
| 105 .WillOnce(DoAll(SetArgPointee<1>(kAudioDecodeStats), Return(0))); | 114 .WillOnce(DoAll(SetArgPointee<1>(kAudioDecodeStats), Return(0))); |
| 106 } | 115 } |
| 107 | 116 |
| 108 private: | 117 private: |
| 109 MockRemoteBitrateEstimator remote_bitrate_estimator_; | 118 MockRemoteBitrateEstimator remote_bitrate_estimator_; |
| 110 testing::StrictMock<MockVoiceEngine> voice_engine_; | 119 testing::StrictMock<MockVoiceEngine> voice_engine_; |
| 111 rtc::scoped_refptr<AudioState> audio_state_; | 120 rtc::scoped_refptr<AudioState> audio_state_; |
| 112 AudioReceiveStream::Config stream_config_; | 121 AudioReceiveStream::Config stream_config_; |
| 122 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; |
| 113 }; | 123 }; |
| 114 | 124 |
| 115 void BuildAbsoluteSendTimeExtension(uint8_t* buffer, | 125 void BuildAbsoluteSendTimeExtension(uint8_t* buffer, |
| 116 int id, | 126 int id, |
| 117 uint32_t abs_send_time) { | 127 uint32_t abs_send_time) { |
| 118 const size_t kRtpOneByteHeaderLength = 4; | 128 const size_t kRtpOneByteHeaderLength = 4; |
| 119 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; | 129 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; |
| 120 ByteWriter<uint16_t>::WriteBigEndian(buffer, kRtpOneByteHeaderExtensionId); | 130 ByteWriter<uint16_t>::WriteBigEndian(buffer, kRtpOneByteHeaderExtensionId); |
| 121 | 131 |
| 122 const uint32_t kPosLength = 2; | 132 const uint32_t kPosLength = 2; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); | 235 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); |
| 226 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); | 236 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); |
| 227 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); | 237 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); |
| 228 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); | 238 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); |
| 229 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); | 239 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); |
| 230 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, | 240 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, |
| 231 stats.capture_start_ntp_time_ms); | 241 stats.capture_start_ntp_time_ms); |
| 232 } | 242 } |
| 233 } // namespace test | 243 } // namespace test |
| 234 } // namespace webrtc | 244 } // namespace webrtc |
| OLD | NEW |