Index: webrtc/pc/rtcstatscollector_unittest.cc |
diff --git a/webrtc/pc/rtcstatscollector_unittest.cc b/webrtc/pc/rtcstatscollector_unittest.cc |
index 715da567abbdb98fb7f5f8ccb7238559e9fcd779..624d23e08f2211f30c7110c97bb729526b9e2f2f 100644 |
--- a/webrtc/pc/rtcstatscollector_unittest.cc |
+++ b/webrtc/pc/rtcstatscollector_unittest.cc |
@@ -1792,10 +1792,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { |
expected_audio.fraction_lost = 5.5; |
ASSERT_TRUE(report->Get(expected_audio.id())); |
- const RTCInboundRTPStreamStats& audio = report->Get( |
- expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); |
- EXPECT_EQ(audio, expected_audio); |
- |
+ EXPECT_EQ( |
+ report->Get(expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(), |
+ expected_audio); |
EXPECT_TRUE(report->Get(*expected_audio.track_id)); |
EXPECT_TRUE(report->Get(*expected_audio.transport_id)); |
EXPECT_TRUE(report->Get(*expected_audio.codec_id)); |
@@ -1826,6 +1825,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { |
video_media_info.receivers[0].plis_sent = 6; |
video_media_info.receivers[0].nacks_sent = 7; |
video_media_info.receivers[0].frames_decoded = 8; |
+ video_media_info.receivers[0].qp_sum = rtc::Optional<uint64_t>(); |
RtpCodecParameters codec_parameters; |
codec_parameters.payload_type = 42; |
@@ -1876,15 +1876,29 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { |
expected_video.packets_lost = 42; |
expected_video.fraction_lost = 4.5; |
expected_video.frames_decoded = 8; |
+ // |expected_video.qp_sum| should be undefined. |
ASSERT_TRUE(report->Get(expected_video.id())); |
- const RTCInboundRTPStreamStats& video = report->Get( |
- expected_video.id())->cast_to<RTCInboundRTPStreamStats>(); |
- EXPECT_EQ(video, expected_video); |
+ EXPECT_EQ( |
+ report->Get(expected_video.id())->cast_to<RTCInboundRTPStreamStats>(), |
+ expected_video); |
+ |
+ // Set previously undefined values and "GetStats" again. |
+ video_media_info.receivers[0].qp_sum = rtc::Optional<uint64_t>(9); |
+ expected_video.qp_sum = 9; |
+ EXPECT_CALL(*video_media_channel, GetStats(_)) |
+ .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
+ collector_->ClearCachedStatsReport(); |
+ report = GetStatsReport(); |
+ |
+ ASSERT_TRUE(report->Get(expected_video.id())); |
+ EXPECT_EQ( |
+ report->Get(expected_video.id())->cast_to<RTCInboundRTPStreamStats>(), |
+ expected_video); |
EXPECT_TRUE(report->Get(*expected_video.track_id)); |
EXPECT_TRUE(report->Get(*expected_video.transport_id)); |
- EXPECT_TRUE(report->Get(*video.codec_id)); |
+ EXPECT_TRUE(report->Get(*expected_video.codec_id)); |
} |
TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
@@ -1904,7 +1918,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
voice_media_info.senders[0].local_stats[0].ssrc = 1; |
voice_media_info.senders[0].packets_sent = 2; |
voice_media_info.senders[0].bytes_sent = 3; |
- voice_media_info.senders[0].rtt_ms = 4500; |
+ voice_media_info.senders[0].rtt_ms = -1; |
voice_media_info.senders[0].codec_payload_type = rtc::Optional<int>(42); |
RtpCodecParameters codec_parameters; |
@@ -1950,13 +1964,26 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
expected_audio.codec_id = "RTCCodec_OutboundAudio_42"; |
expected_audio.packets_sent = 2; |
expected_audio.bytes_sent = 3; |
- expected_audio.round_trip_time = 4.5; |
+ // |expected_audio.round_trip_time| should be undefined. |
ASSERT_TRUE(report->Get(expected_audio.id())); |
- const RTCOutboundRTPStreamStats& audio = report->Get( |
- expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(); |
- EXPECT_EQ(audio, expected_audio); |
+ EXPECT_EQ( |
+ report->Get(expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(), |
+ expected_audio); |
+ |
+ // Set previously undefined values and "GetStats" again. |
+ voice_media_info.senders[0].rtt_ms = 4500; |
+ expected_audio.round_trip_time = 4.5; |
+ |
+ EXPECT_CALL(*voice_media_channel, GetStats(_)) |
+ .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
+ collector_->ClearCachedStatsReport(); |
+ report = GetStatsReport(); |
+ ASSERT_TRUE(report->Get(expected_audio.id())); |
+ EXPECT_EQ( |
+ report->Get(expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(), |
+ expected_audio); |
EXPECT_TRUE(report->Get(*expected_audio.track_id)); |
EXPECT_TRUE(report->Get(*expected_audio.transport_id)); |
EXPECT_TRUE(report->Get(*expected_audio.codec_id)); |
@@ -1982,10 +2009,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { |
video_media_info.senders[0].nacks_rcvd = 4; |
video_media_info.senders[0].packets_sent = 5; |
video_media_info.senders[0].bytes_sent = 6; |
- video_media_info.senders[0].rtt_ms = 7500; |
+ video_media_info.senders[0].rtt_ms = -1; |
video_media_info.senders[0].codec_payload_type = rtc::Optional<int>(42); |
video_media_info.senders[0].frames_encoded = 8; |
- video_media_info.senders[0].qp_sum = rtc::Optional<uint64_t>(16); |
+ video_media_info.senders[0].qp_sum = rtc::Optional<uint64_t>(); |
RtpCodecParameters codec_parameters; |
codec_parameters.payload_type = 42; |
@@ -2033,120 +2060,33 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { |
expected_video.nack_count = 4; |
expected_video.packets_sent = 5; |
expected_video.bytes_sent = 6; |
- expected_video.round_trip_time = 7.5; |
expected_video.frames_encoded = 8; |
- expected_video.qp_sum = 16; |
+ // |expected_video.round_trip_time| and |expected_video.qp_sum| should be |
+ // undefined. |
ASSERT_TRUE(report->Get(expected_video.id())); |
- const RTCOutboundRTPStreamStats& video = report->Get( |
- expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(); |
- EXPECT_EQ(video, expected_video); |
- |
- EXPECT_TRUE(report->Get(*expected_video.track_id)); |
- EXPECT_TRUE(report->Get(*expected_video.transport_id)); |
- EXPECT_TRUE(report->Get(*expected_video.codec_id)); |
-} |
- |
-TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Default) { |
- MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
- cricket::VoiceChannel voice_channel( |
- test_->worker_thread(), test_->network_thread(), |
- test_->signaling_thread(), test_->media_engine(), voice_media_channel, |
- "VoiceContentName", kDefaultRtcpMuxRequired, kDefaultSrtpRequired); |
- MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
- cricket::VideoChannel video_channel( |
- test_->worker_thread(), test_->network_thread(), |
- test_->signaling_thread(), video_media_channel, "VideoContentName", |
- kDefaultRtcpMuxRequired, kDefaultSrtpRequired); |
- |
- cricket::VoiceMediaInfo voice_media_info; |
- voice_media_info.senders.push_back(cricket::VoiceSenderInfo()); |
- voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
- voice_media_info.senders[0].local_stats[0].ssrc = 1; |
- voice_media_info.senders[0].packets_sent = 2; |
- voice_media_info.senders[0].bytes_sent = 3; |
- voice_media_info.senders[0].rtt_ms = -1; |
- voice_media_info.senders[0].codec_payload_type = rtc::Optional<int>(42); |
+ EXPECT_EQ( |
+ report->Get(expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(), |
+ expected_video); |
- cricket::VideoMediaInfo video_media_info; |
- video_media_info.senders.push_back(cricket::VideoSenderInfo()); |
- video_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); |
- video_media_info.senders[0].local_stats[0].ssrc = 1; |
- video_media_info.senders[0].firs_rcvd = 2; |
- video_media_info.senders[0].plis_rcvd = 3; |
- video_media_info.senders[0].nacks_rcvd = 4; |
- video_media_info.senders[0].packets_sent = 5; |
- video_media_info.senders[0].bytes_sent = 6; |
- video_media_info.senders[0].rtt_ms = -1; |
- video_media_info.senders[0].codec_payload_type = rtc::Optional<int>(42); |
- video_media_info.senders[0].frames_encoded = 7; |
+ // Set previously undefined values and "GetStats" again. |
+ video_media_info.senders[0].rtt_ms = 7500; |
+ video_media_info.senders[0].qp_sum = rtc::Optional<uint64_t>(9); |
+ expected_video.round_trip_time = 7.5; |
+ expected_video.qp_sum = 9; |
- EXPECT_CALL(*voice_media_channel, GetStats(_)) |
- .WillOnce(DoAll(SetArgPointee<0>(voice_media_info), Return(true))); |
EXPECT_CALL(*video_media_channel, GetStats(_)) |
.WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
- |
- SessionStats session_stats; |
- session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; |
- session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; |
- session_stats.transport_stats["TransportName"].transport_name = |
- "TransportName"; |
- |
- // Make sure the associated |RTCTransportStats| is created. |
- cricket::TransportChannelStats channel_stats; |
- channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
- session_stats.transport_stats["TransportName"].channel_stats.push_back( |
- channel_stats); |
- |
- EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( |
- [&session_stats](const ChannelNamePairs&) { |
- return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); |
- })); |
- EXPECT_CALL(test_->session(), voice_channel()) |
- .WillRepeatedly(Return(&voice_channel)); |
- EXPECT_CALL(test_->session(), video_channel()) |
- .WillRepeatedly(Return(&video_channel)); |
- |
- rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
- |
- RTCOutboundRTPStreamStats expected_audio( |
- "RTCOutboundRTPAudioStream_1", report->timestamp_us()); |
- expected_audio.ssrc = 1; |
- expected_audio.is_remote = false; |
- expected_audio.media_type = "audio"; |
- expected_audio.transport_id = "RTCTransport_TransportName_" + |
- rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
- expected_audio.codec_id = "RTCCodec_OutboundAudio_42"; |
- expected_audio.packets_sent = 2; |
- expected_audio.bytes_sent = 3; |
- // |expected_audio.round_trip_time| should be undefined. |
- |
- ASSERT_TRUE(report->Get(expected_audio.id())); |
- const RTCOutboundRTPStreamStats& audio = report->Get( |
- expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(); |
- EXPECT_EQ(audio, expected_audio); |
- |
- RTCOutboundRTPStreamStats expected_video( |
- "RTCOutboundRTPVideoStream_1", report->timestamp_us()); |
- expected_video.ssrc = 1; |
- expected_video.is_remote = false; |
- expected_video.media_type = "video"; |
- expected_video.transport_id = "RTCTransport_TransportName_" + |
- rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP); |
- expected_video.codec_id = "RTCCodec_OutboundVideo_42"; |
- expected_video.fir_count = 2; |
- expected_video.pli_count = 3; |
- expected_video.nack_count = 4; |
- expected_video.packets_sent = 5; |
- expected_video.bytes_sent = 6; |
- expected_video.frames_encoded = 7; |
- // |expected_video.round_trip_time| should be undefined. |
- // |expected_video.qp_sum| should be undefined. |
+ collector_->ClearCachedStatsReport(); |
+ report = GetStatsReport(); |
ASSERT_TRUE(report->Get(expected_video.id())); |
- const RTCOutboundRTPStreamStats& video = report->Get( |
- expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(); |
- EXPECT_EQ(video, expected_video); |
+ EXPECT_EQ( |
+ report->Get(expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(), |
+ expected_video); |
+ EXPECT_TRUE(report->Get(*expected_video.track_id)); |
+ EXPECT_TRUE(report->Get(*expected_video.transport_id)); |
+ EXPECT_TRUE(report->Get(*expected_video.codec_id)); |
} |
TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) { |