From 92665682fe103e36e5099bb9e6945dc96ce1c518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Mon, 24 Jul 2023 16:01:09 +0200 Subject: [PATCH] Clear scalability mode from stats when implementation changes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was discovered that if libvpx reported a scalability mode in getStats (e.g. L3T3_KEY) and we then changed encoder implementation to an RTCVideoEncoder (such as MediaFoundationVideoEncodeAccelerator), getStats continued to report the old scalability mode value. This CL makes sure to clear the scalability mode on encoder implementation change or if the `codec_info` is missing. We should update MediaFoundation to report L1T1 as well, but in the meantime we should clear any old scalability modes values when the implementation changes (if the scalability mode is not known it is better to report nothing than to report an old misleading value). Bug: chromium:1426440 Change-Id: I1b5f324c4d29a00a6c73404cbee0faa2ae9cd843 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/312900 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#40467} --- video/send_statistics_proxy.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 8605771cd3..b857c0535b 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -977,8 +977,8 @@ void SendStatisticsProxy::OnSendEncodedImage( stats->frames_encoded++; stats->total_encode_time_ms += encoded_image.timing_.encode_finish_ms - encoded_image.timing_.encode_start_ms; - if (codec_info) - stats->scalability_mode = codec_info->scalability_mode; + stats->scalability_mode = + codec_info ? codec_info->scalability_mode : absl::nullopt; // Report resolution of the top spatial layer. bool is_top_spatial_layer = codec_info == nullptr || codec_info->end_of_picture; @@ -1059,6 +1059,11 @@ void SendStatisticsProxy::OnEncoderImplementationChanged( implementation.name}; stats_.encoder_implementation_name = implementation.name; stats_.power_efficient_encoder = implementation.is_hardware_accelerated; + // Clear cached scalability mode values, they may no longer be accurate. + for (auto& pair : stats_.substreams) { + VideoSendStream::StreamStats& stream_stats = pair.second; + stream_stats.scalability_mode = absl::nullopt; + } } int SendStatisticsProxy::GetInputFrameRate() const {