VideoSendStream::Stats::total_encode_time_ms added.

This is a standard stat:
https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime

This is collected by SendStatisticsProxy. A follow-up CL will plumb
this to the RTCStatsCollector.

Bug: webrtc:10448
Change-Id: I236afa5576edc26afd54bd166f7faaf7e38e7c7f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130517
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27459}
This commit is contained in:
Henrik Boström
2019-04-02 15:05:21 +02:00
committed by Commit Bot
parent a556448138
commit 5684af5d63
4 changed files with 15 additions and 1 deletions

View File

@ -68,6 +68,8 @@ class VideoSendStream {
int avg_encode_time_ms = 0;
int encode_usage_percent = 0;
uint32_t frames_encoded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodetime
uint64_t total_encode_time_ms = 0;
uint32_t frames_dropped_by_capturer = 0;
uint32_t frames_dropped_by_encoder_queue = 0;
uint32_t frames_dropped_by_rate_limiter = 0;

View File

@ -161,7 +161,8 @@ TEST_F(StatsEndToEndTest, GetStats) {
stats.substreams.size() == expected_num_streams;
send_stats_filled_["CpuOveruseMetrics"] |=
stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0;
stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0 &&
stats.total_encode_time_ms != 0;
send_stats_filled_["EncoderImplementationName"] |=
stats.encoder_implementation_name ==

View File

@ -674,10 +674,12 @@ void SendStatisticsProxy::OnEncoderReconfigured(
void SendStatisticsProxy::OnEncodedFrameTimeMeasured(int encode_time_ms,
int encode_usage_percent) {
RTC_DCHECK_GE(encode_time_ms, 0);
rtc::CritScope lock(&crit_);
uma_container_->encode_time_counter_.Add(encode_time_ms);
encode_time_.Apply(1.0f, encode_time_ms);
stats_.avg_encode_time_ms = round(encode_time_.filtered());
stats_.total_encode_time_ms += encode_time_ms;
stats_.encode_usage_percent = encode_usage_percent;
}

View File

@ -318,6 +318,15 @@ TEST_F(SendStatisticsProxyTest, OnEncodedFrameTimeMeasured) {
EXPECT_EQ(encode_usage_percent, stats.encode_usage_percent);
}
TEST_F(SendStatisticsProxyTest, TotalEncodeTimeIncreasesPerFrameMeasured) {
const int kEncodeUsagePercent = 0; // Don't care for this test.
EXPECT_EQ(0u, statistics_proxy_->GetStats().total_encode_time_ms);
statistics_proxy_->OnEncodedFrameTimeMeasured(10, kEncodeUsagePercent);
EXPECT_EQ(10u, statistics_proxy_->GetStats().total_encode_time_ms);
statistics_proxy_->OnEncodedFrameTimeMeasured(20, kEncodeUsagePercent);
EXPECT_EQ(30u, statistics_proxy_->GetStats().total_encode_time_ms);
}
TEST_F(SendStatisticsProxyTest, OnSendEncodedImageIncreasesFramesEncoded) {
EncodedImage encoded_image;
CodecSpecificInfo codec_info;