RTCOutboundRTPStreamStats.roundTripTime: Only report non-negative values.

Underlying stats gatherers may otherwise default it to -1.

BUG=chromium:669877, chromium:627816

Review-Url: https://codereview.webrtc.org/2562703007
Cr-Commit-Position: refs/heads/master@{#15625}
This commit is contained in:
hbos 2016-12-15 01:54:29 -08:00 committed by Commit bot
parent 24db179bbf
commit e10e6d1f47
3 changed files with 102 additions and 3 deletions

View File

@ -497,7 +497,8 @@ class RTCStatsReportVerifier {
verifier.TestMemberIsDefined(outbound_stream.packets_sent);
verifier.TestMemberIsDefined(outbound_stream.bytes_sent);
verifier.TestMemberIsUndefined(outbound_stream.target_bitrate);
verifier.TestMemberIsDefined(outbound_stream.round_trip_time);
// TODO(hbos): Defined in video but not audio case. Why? crbug.com/669877
verifier.MarkMemberTested(outbound_stream.round_trip_time, true);
return verifier.ExpectAllMembersSuccessfullyTested();
}

View File

@ -197,8 +197,10 @@ void SetOutboundRTPStreamStatsFromMediaSenderInfo(
static_cast<uint32_t>(media_sender_info.packets_sent);
outbound_stats->bytes_sent =
static_cast<uint64_t>(media_sender_info.bytes_sent);
outbound_stats->round_trip_time =
static_cast<double>(media_sender_info.rtt_ms) / rtc::kNumMillisecsPerSec;
if (media_sender_info.rtt_ms >= 0) {
outbound_stats->round_trip_time = static_cast<double>(
media_sender_info.rtt_ms) / rtc::kNumMillisecsPerSec;
}
}
void SetOutboundRTPStreamStatsFromVoiceSenderInfo(

View File

@ -1628,6 +1628,102 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) {
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_->media_engine(),
voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled,
kDefaultSrtpRequired);
MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(
test_->worker_thread(), test_->network_thread(), video_media_channel,
nullptr, "VideoContentName", kDefaultRtcpEnabled, 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);
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);
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(), GetTransportStats(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true)));
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(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.round_trip_time| should be undefined.
ASSERT(report->Get(expected_video.id()));
const RTCOutboundRTPStreamStats& video = report->Get(
expected_video.id())->cast_to<RTCOutboundRTPStreamStats>();
EXPECT_EQ(video, expected_video);
}
TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
std::unique_ptr<cricket::Candidate> rtp_local_candidate = CreateFakeCandidate(
"42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42);