Wire up RTCOutboundRtpStreamStats.totalEncodeTime.

This is a follow-up to
https://webrtc-review.googlesource.com/c/src/+/130517 that calculated
this metric.

This CL is purely plumbing, exposing
VideoSendStream::total_encode_time_ms in standard getStats() as
RTCOutboundRtpStreamStats.totalEncodeTime (in seconds):
https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime

Bug: webrtc:10448
Change-Id: I715f1ef937e441169dee55b5e8d4fbf98811c5f3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131940
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27501}
This commit is contained in:
Henrik Boström
2019-04-08 16:14:23 +02:00
committed by Commit Bot
parent ea7b4c5c40
commit f71362f0cf
7 changed files with 18 additions and 3 deletions

View File

@ -437,6 +437,7 @@ class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
// TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
RTCStatsMember<double> target_bitrate; RTCStatsMember<double> target_bitrate;
RTCStatsMember<uint32_t> frames_encoded; RTCStatsMember<uint32_t> frames_encoded;
RTCStatsMember<double> total_encode_time;
}; };
// https://w3c.github.io/webrtc-stats/#transportstats-dict* // https://w3c.github.io/webrtc-stats/#transportstats-dict*

View File

@ -527,6 +527,8 @@ struct VideoSenderInfo : public MediaSenderInfo {
int avg_encode_ms = 0; int avg_encode_ms = 0;
int encode_usage_percent = 0; int encode_usage_percent = 0;
uint32_t frames_encoded = 0; uint32_t frames_encoded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime
uint64_t total_encode_time_ms = 0;
bool has_entered_low_resolution = false; bool has_entered_low_resolution = false;
absl::optional<uint64_t> qp_sum; absl::optional<uint64_t> qp_sum;
webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED;

View File

@ -2243,6 +2243,7 @@ VideoSenderInfo WebRtcVideoChannel::WebRtcVideoSendStream::GetVideoSenderInfo(
info.avg_encode_ms = stats.avg_encode_time_ms; info.avg_encode_ms = stats.avg_encode_time_ms;
info.encode_usage_percent = stats.encode_usage_percent; info.encode_usage_percent = stats.encode_usage_percent;
info.frames_encoded = stats.frames_encoded; info.frames_encoded = stats.frames_encoded;
info.total_encode_time_ms = stats.total_encode_time_ms;
info.qp_sum = stats.qp_sum; info.qp_sum = stats.qp_sum;
info.nominal_bitrate = stats.media_bitrate_bps; info.nominal_bitrate = stats.media_bitrate_bps;

View File

@ -319,6 +319,9 @@ void SetOutboundRTPStreamStatsFromVideoSenderInfo(
if (video_sender_info.qp_sum) if (video_sender_info.qp_sum)
outbound_video->qp_sum = *video_sender_info.qp_sum; outbound_video->qp_sum = *video_sender_info.qp_sum;
outbound_video->frames_encoded = video_sender_info.frames_encoded; outbound_video->frames_encoded = video_sender_info.frames_encoded;
outbound_video->total_encode_time =
static_cast<double>(video_sender_info.total_encode_time_ms) /
rtc::kNumMillisecsPerSec;
} }
void ProduceCertificateStatsFromSSLCertificateStats( void ProduceCertificateStatsFromSSLCertificateStats(

View File

@ -1804,6 +1804,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) {
video_media_info.senders[0].bytes_sent = 6; video_media_info.senders[0].bytes_sent = 6;
video_media_info.senders[0].codec_payload_type = 42; video_media_info.senders[0].codec_payload_type = 42;
video_media_info.senders[0].frames_encoded = 8; video_media_info.senders[0].frames_encoded = 8;
video_media_info.senders[0].total_encode_time_ms = 9000;
video_media_info.senders[0].qp_sum = absl::nullopt; video_media_info.senders[0].qp_sum = absl::nullopt;
RtpCodecParameters codec_parameters; RtpCodecParameters codec_parameters;
@ -1841,6 +1842,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) {
expected_video.packets_sent = 5; expected_video.packets_sent = 5;
expected_video.bytes_sent = 6; expected_video.bytes_sent = 6;
expected_video.frames_encoded = 8; expected_video.frames_encoded = 8;
expected_video.total_encode_time = 9.0;
// |expected_video.qp_sum| should be undefined. // |expected_video.qp_sum| should be undefined.
ASSERT_TRUE(report->Get(expected_video.id())); ASSERT_TRUE(report->Get(expected_video.id()));

View File

@ -762,8 +762,11 @@ class RTCStatsReportVerifier {
if (outbound_stream.media_type.is_defined() && if (outbound_stream.media_type.is_defined() &&
*outbound_stream.media_type == "video") { *outbound_stream.media_type == "video") {
verifier.TestMemberIsDefined(outbound_stream.frames_encoded); verifier.TestMemberIsDefined(outbound_stream.frames_encoded);
verifier.TestMemberIsNonNegative<double>(
outbound_stream.total_encode_time);
} else { } else {
verifier.TestMemberIsUndefined(outbound_stream.frames_encoded); verifier.TestMemberIsUndefined(outbound_stream.frames_encoded);
verifier.TestMemberIsUndefined(outbound_stream.total_encode_time);
} }
return verifier.ExpectAllMembersSuccessfullyTested(); return verifier.ExpectAllMembersSuccessfullyTested();
} }

View File

@ -644,7 +644,8 @@ WEBRTC_RTCSTATS_IMPL(
&packets_sent, &packets_sent,
&bytes_sent, &bytes_sent,
&target_bitrate, &target_bitrate,
&frames_encoded) &frames_encoded,
&total_encode_time)
// clang-format on // clang-format on
RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id, RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id,
@ -657,7 +658,8 @@ RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id,
packets_sent("packetsSent"), packets_sent("packetsSent"),
bytes_sent("bytesSent"), bytes_sent("bytesSent"),
target_bitrate("targetBitrate"), target_bitrate("targetBitrate"),
frames_encoded("framesEncoded") {} frames_encoded("framesEncoded"),
total_encode_time("totalEncodeTime") {}
RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats( RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
const RTCOutboundRTPStreamStats& other) const RTCOutboundRTPStreamStats& other)
@ -665,7 +667,8 @@ RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
packets_sent(other.packets_sent), packets_sent(other.packets_sent),
bytes_sent(other.bytes_sent), bytes_sent(other.bytes_sent),
target_bitrate(other.target_bitrate), target_bitrate(other.target_bitrate),
frames_encoded(other.frames_encoded) {} frames_encoded(other.frames_encoded),
total_encode_time(other.total_encode_time) {}
RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {} RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {}