Update the source of EncodeTimeInMs UMA histogram.
This CL changes the source of WebRTC.Video.EncodeTimeInMs and
WebRTC.Video.Screenshare.EncodeTimeInMs to use the timing frame
extensions data instead of the callback on the CPU adaptation logic,
since the latter may drop samples in some cases causing flakiness
of the HistogramTest.* tests.
Bug: webrtc:450045075
Change-Id: I4d56750eba72f3b1c1b00380b803c4c01aa5930f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/415283
Auto-Submit: Erik Språng <sprang@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45867}
diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc
index 65b328a..9a637b5 100644
--- a/video/send_statistics_proxy.cc
+++ b/video/send_statistics_proxy.cc
@@ -734,7 +734,6 @@
int encode_usage_percent) {
RTC_DCHECK_GE(encode_time_ms, 0);
MutexLock lock(&mutex_);
- uma_container_->encode_time_counter_.Add(encode_time_ms);
encode_time_.Apply(1.0f, encode_time_ms);
stats_.avg_encode_time_ms = std::round(encode_time_.filtered());
stats_.total_encode_time_ms += encode_time_ms;
@@ -1015,8 +1014,10 @@
Trackers& track = trackers_[ssrc];
stats->frames_encoded++;
- stats->total_encode_time_ms += encoded_image.timing_.encode_finish_ms -
- encoded_image.timing_.encode_start_ms;
+ int64_t encode_time_ms = encoded_image.timing_.encode_finish_ms -
+ encoded_image.timing_.encode_start_ms;
+ stats->total_encode_time_ms += encode_time_ms;
+ uma_container_->encode_time_counter_.Add(encode_time_ms);
stats->scalability_mode =
codec_info ? codec_info->scalability_mode : std::nullopt;
// Report resolution of the top spatial layer.