| 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_voice_engine.h" | 17 #include "webrtc/test/mock_voice_engine.h" |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 namespace test { | 20 namespace test { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 using testing::_; |
| 24 using testing::Return; |
| 25 |
| 23 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { | 26 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { |
| 24 AudioDecodingCallStats audio_decode_stats; | 27 AudioDecodingCallStats audio_decode_stats; |
| 25 audio_decode_stats.calls_to_silence_generator = 234; | 28 audio_decode_stats.calls_to_silence_generator = 234; |
| 26 audio_decode_stats.calls_to_neteq = 567; | 29 audio_decode_stats.calls_to_neteq = 567; |
| 27 audio_decode_stats.decoded_normal = 890; | 30 audio_decode_stats.decoded_normal = 890; |
| 28 audio_decode_stats.decoded_plc = 123; | 31 audio_decode_stats.decoded_plc = 123; |
| 29 audio_decode_stats.decoded_cng = 456; | 32 audio_decode_stats.decoded_cng = 456; |
| 30 audio_decode_stats.decoded_plc_cng = 789; | 33 audio_decode_stats.decoded_plc_cng = 789; |
| 31 return audio_decode_stats; | 34 return audio_decode_stats; |
| 32 } | 35 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 43 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; | 46 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; |
| 44 const CodecInst kCodecInst = { | 47 const CodecInst kCodecInst = { |
| 45 123, "codec_name_recv", 96000, -187, -198, -103}; | 48 123, "codec_name_recv", 96000, -187, -198, -103}; |
| 46 const NetworkStatistics kNetworkStats = { | 49 const NetworkStatistics kNetworkStats = { |
| 47 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; | 50 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; |
| 48 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); | 51 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); |
| 49 | 52 |
| 50 struct ConfigHelper { | 53 struct ConfigHelper { |
| 51 ConfigHelper() { | 54 ConfigHelper() { |
| 52 EXPECT_CALL(voice_engine_, | 55 EXPECT_CALL(voice_engine_, |
| 53 RegisterVoiceEngineObserver(testing::_)).WillOnce(testing::Return(0)); | 56 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
| 54 EXPECT_CALL(voice_engine_, | 57 EXPECT_CALL(voice_engine_, |
| 55 DeRegisterVoiceEngineObserver()).WillOnce(testing::Return(0)); | 58 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
| 56 AudioState::Config config; | 59 AudioState::Config config; |
| 57 config.voice_engine = &voice_engine_; | 60 config.voice_engine = &voice_engine_; |
| 58 audio_state_ = AudioState::Create(config); | 61 audio_state_ = AudioState::Create(config); |
| 59 stream_config_.voe_channel_id = kChannelId; | 62 stream_config_.voe_channel_id = kChannelId; |
| 60 stream_config_.rtp.local_ssrc = kLocalSsrc; | 63 stream_config_.rtp.local_ssrc = kLocalSsrc; |
| 61 stream_config_.rtp.remote_ssrc = kRemoteSsrc; | 64 stream_config_.rtp.remote_ssrc = kRemoteSsrc; |
| 62 } | 65 } |
| 63 | 66 |
| 64 MockRemoteBitrateEstimator* remote_bitrate_estimator() { | 67 MockRemoteBitrateEstimator* remote_bitrate_estimator() { |
| 65 return &remote_bitrate_estimator_; | 68 return &remote_bitrate_estimator_; |
| 66 } | 69 } |
| 67 AudioReceiveStream::Config& config() { return stream_config_; } | 70 AudioReceiveStream::Config& config() { return stream_config_; } |
| 68 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } | 71 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } |
| 69 MockVoiceEngine& voice_engine() { return voice_engine_; } | 72 MockVoiceEngine& voice_engine() { return voice_engine_; } |
| 70 | 73 |
| 71 void SetupMockForGetStats() { | 74 void SetupMockForGetStats() { |
| 72 using testing::_; | |
| 73 using testing::DoAll; | 75 using testing::DoAll; |
| 74 using testing::Return; | |
| 75 using testing::SetArgPointee; | 76 using testing::SetArgPointee; |
| 76 using testing::SetArgReferee; | 77 using testing::SetArgReferee; |
| 77 EXPECT_CALL(voice_engine_, GetRemoteSSRC(kChannelId, _)) | 78 EXPECT_CALL(voice_engine_, GetRemoteSSRC(kChannelId, _)) |
| 78 .WillOnce(DoAll(SetArgReferee<1>(0), Return(0))); | 79 .WillOnce(DoAll(SetArgReferee<1>(0), Return(0))); |
| 79 EXPECT_CALL(voice_engine_, GetRTCPStatistics(kChannelId, _)) | 80 EXPECT_CALL(voice_engine_, GetRTCPStatistics(kChannelId, _)) |
| 80 .WillOnce(DoAll(SetArgReferee<1>(kCallStats), Return(0))); | 81 .WillOnce(DoAll(SetArgReferee<1>(kCallStats), Return(0))); |
| 81 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) | 82 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) |
| 82 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); | 83 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); |
| 83 EXPECT_CALL(voice_engine_, GetDelayEstimate(kChannelId, _, _)) | 84 EXPECT_CALL(voice_engine_, GetDelayEstimate(kChannelId, _, _)) |
| 84 .WillOnce(DoAll(SetArgPointee<1>(kJitterBufferDelay), | 85 .WillOnce(DoAll(SetArgPointee<1>(kJitterBufferDelay), |
| 85 SetArgPointee<2>(kPlayoutBufferDelay), Return(0))); | 86 SetArgPointee<2>(kPlayoutBufferDelay), Return(0))); |
| 86 EXPECT_CALL(voice_engine_, | 87 EXPECT_CALL(voice_engine_, |
| 87 GetSpeechOutputLevelFullRange(kChannelId, _)).WillOnce( | 88 GetSpeechOutputLevelFullRange(kChannelId, _)).WillOnce( |
| 88 DoAll(SetArgReferee<1>(kSpeechOutputLevel), Return(0))); | 89 DoAll(SetArgReferee<1>(kSpeechOutputLevel), Return(0))); |
| 89 EXPECT_CALL(voice_engine_, GetNetworkStatistics(kChannelId, _)) | 90 EXPECT_CALL(voice_engine_, GetNetworkStatistics(kChannelId, _)) |
| 90 .WillOnce(DoAll(SetArgReferee<1>(kNetworkStats), Return(0))); | 91 .WillOnce(DoAll(SetArgReferee<1>(kNetworkStats), Return(0))); |
| 91 EXPECT_CALL(voice_engine_, GetDecodingCallStatistics(kChannelId, _)) | 92 EXPECT_CALL(voice_engine_, GetDecodingCallStatistics(kChannelId, _)) |
| 92 .WillOnce(DoAll(SetArgPointee<1>(kAudioDecodeStats), Return(0))); | 93 .WillOnce(DoAll(SetArgPointee<1>(kAudioDecodeStats), Return(0))); |
| 93 } | 94 } |
| 94 | 95 |
| 95 private: | 96 private: |
| 96 MockRemoteBitrateEstimator remote_bitrate_estimator_; | 97 MockRemoteBitrateEstimator remote_bitrate_estimator_; |
| 97 MockVoiceEngine voice_engine_; | 98 testing::StrictMock<MockVoiceEngine> voice_engine_; |
| 98 rtc::scoped_refptr<AudioState> audio_state_; | 99 rtc::scoped_refptr<AudioState> audio_state_; |
| 99 AudioReceiveStream::Config stream_config_; | 100 AudioReceiveStream::Config stream_config_; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 void BuildAbsoluteSendTimeExtension(uint8_t* buffer, | 103 void BuildAbsoluteSendTimeExtension(uint8_t* buffer, |
| 103 int id, | 104 int id, |
| 104 uint32_t abs_send_time) { | 105 uint32_t abs_send_time) { |
| 105 const size_t kRtpOneByteHeaderLength = 4; | 106 const size_t kRtpOneByteHeaderLength = 4; |
| 106 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; | 107 const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE; |
| 107 ByteWriter<uint16_t>::WriteBigEndian(buffer, kRtpOneByteHeaderExtensionId); | 108 ByteWriter<uint16_t>::WriteBigEndian(buffer, kRtpOneByteHeaderExtensionId); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); | 215 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); |
| 215 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); | 216 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); |
| 216 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); | 217 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); |
| 217 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); | 218 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); |
| 218 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); | 219 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); |
| 219 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, | 220 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, |
| 220 stats.capture_start_ntp_time_ms); | 221 stats.capture_start_ntp_time_ms); |
| 221 } | 222 } |
| 222 } // namespace test | 223 } // namespace test |
| 223 } // namespace webrtc | 224 } // namespace webrtc |
| OLD | NEW |