From 820f578f2bb3585cc48876fa9e594a6a6b0dd174 Mon Sep 17 00:00:00 2001 From: hbos Date: Tue, 22 Nov 2016 03:16:50 -0800 Subject: [PATCH] RTCInboundRTPStreamStats's [fir/pli/nack]_count are collected for video. Previously this was only collected for RTCOutboundRTPStreamStats video, with no comment saying it was missing for Inbound. (nack_count should be collected vor audio as well but this is currently not available - there is already an existing comment about this in rtcstats_objects.h.) BUG=chromium:657855, chromium:657854, chromium:627816 Review-Url: https://codereview.webrtc.org/2515293002 Cr-Commit-Position: refs/heads/master@{#15185} --- webrtc/api/rtcstatscollector.cc | 24 ++++++++++++------ webrtc/api/rtcstatscollector_unittest.cc | 32 ++++++++++++++---------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/webrtc/api/rtcstatscollector.cc b/webrtc/api/rtcstatscollector.cc index fbc6dbc5d3..b866b68b16 100644 --- a/webrtc/api/rtcstatscollector.cc +++ b/webrtc/api/rtcstatscollector.cc @@ -107,6 +107,7 @@ void SetMediaStreamTrackStatsFromMediaStreamTrackInterface( track_stats->ended = (track.state() == MediaStreamTrackInterface::kEnded); } +// Provides the media independent counters (both audio and video). void SetInboundRTPStreamStatsFromMediaReceiverInfo( const cricket::MediaReceiverInfo& media_receiver_info, RTCInboundRTPStreamStats* inbound_stats) { @@ -126,23 +127,32 @@ void SetInboundRTPStreamStatsFromMediaReceiverInfo( void SetInboundRTPStreamStatsFromVoiceReceiverInfo( const cricket::VoiceReceiverInfo& voice_receiver_info, - RTCInboundRTPStreamStats* inbound_stats) { + RTCInboundRTPStreamStats* inbound_audio) { SetInboundRTPStreamStatsFromMediaReceiverInfo( - voice_receiver_info, inbound_stats); - inbound_stats->media_type = "audio"; - inbound_stats->jitter = + voice_receiver_info, inbound_audio); + inbound_audio->media_type = "audio"; + inbound_audio->jitter = static_cast(voice_receiver_info.jitter_ms) / rtc::kNumMillisecsPerSec; + // |fir_count|, |pli_count| and |sli_count| are only valid for video and are + // purposefully left undefined for audio. } void SetInboundRTPStreamStatsFromVideoReceiverInfo( const cricket::VideoReceiverInfo& video_receiver_info, - RTCInboundRTPStreamStats* inbound_stats) { + RTCInboundRTPStreamStats* inbound_video) { SetInboundRTPStreamStatsFromMediaReceiverInfo( - video_receiver_info, inbound_stats); - inbound_stats->media_type = "video"; + video_receiver_info, inbound_video); + inbound_video->media_type = "video"; + inbound_video->fir_count = + static_cast(video_receiver_info.firs_sent); + inbound_video->pli_count = + static_cast(video_receiver_info.plis_sent); + inbound_video->nack_count = + static_cast(video_receiver_info.nacks_sent); } +// Provides the media independent counters (both audio and video). void SetOutboundRTPStreamStatsFromMediaSenderInfo( const cricket::MediaSenderInfo& media_sender_info, RTCOutboundRTPStreamStats* outbound_stats) { diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc index e032384238..64e7e0a97b 100644 --- a/webrtc/api/rtcstatscollector_unittest.cc +++ b/webrtc/api/rtcstatscollector_unittest.cc @@ -1383,6 +1383,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { video_media_info.receivers[0].packets_rcvd = 2; video_media_info.receivers[0].bytes_rcvd = 3; video_media_info.receivers[0].fraction_lost = 4.5f; + video_media_info.receivers[0].firs_sent = 5; + video_media_info.receivers[0].plis_sent = 6; + video_media_info.receivers[0].nacks_sent = 7; EXPECT_CALL(*video_media_channel, GetStats(_)) .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); @@ -1404,23 +1407,26 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { rtc::scoped_refptr report = GetStatsReport(); - RTCInboundRTPStreamStats expected_audio( + RTCInboundRTPStreamStats expected_video( "RTCInboundRTPVideoStream_1", report->timestamp_us()); - expected_audio.ssrc = "1"; - expected_audio.is_remote = false; - expected_audio.media_type = "video"; - expected_audio.transport_id = "RTCTransport_TransportName_" + + 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_audio.packets_received = 2; - expected_audio.bytes_received = 3; - expected_audio.fraction_lost = 4.5; + expected_video.fir_count = 5; + expected_video.pli_count = 6; + expected_video.nack_count = 7; + expected_video.packets_received = 2; + expected_video.bytes_received = 3; + expected_video.fraction_lost = 4.5; - ASSERT(report->Get(expected_audio.id())); - const RTCInboundRTPStreamStats& audio = report->Get( - expected_audio.id())->cast_to(); - EXPECT_EQ(audio, expected_audio); + ASSERT(report->Get(expected_video.id())); + const RTCInboundRTPStreamStats& video = report->Get( + expected_video.id())->cast_to(); + EXPECT_EQ(video, expected_video); - EXPECT_TRUE(report->Get(*expected_audio.transport_id)); + EXPECT_TRUE(report->Get(*expected_video.transport_id)); } TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) {