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}
diff --git a/call/video_send_stream.h b/call/video_send_stream.h
index 5daec19..8f550da 100644
--- a/call/video_send_stream.h
+++ b/call/video_send_stream.h
@@ -68,6 +68,8 @@
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;
diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc
index 3717c76..3201e19 100644
--- a/video/end_to_end_tests/stats_tests.cc
+++ b/video/end_to_end_tests/stats_tests.cc
@@ -161,7 +161,8 @@
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 ==
diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc
index 20e5449..0b16537 100644
--- a/video/send_statistics_proxy.cc
+++ b/video/send_statistics_proxy.cc
@@ -674,10 +674,12 @@
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;
}
diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc
index 1e36795..ded7fed 100644
--- a/video/send_statistics_proxy_unittest.cc
+++ b/video/send_statistics_proxy_unittest.cc
@@ -318,6 +318,15 @@
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;