commit 64566823ff07d1fc82618ad8915f62d502554cea parent 2fb99a91766edb322d78ccd09f7df817cf1e1217 Author: Michael Froman <mfroman@mozilla.com> Date: Wed, 8 Oct 2025 23:26:16 -0500 Bug 1993083 - Vendor libwebrtc from d950a7fb2f Upstream commit: https://webrtc.googlesource.com/src/+/d950a7fb2fb16611ea943a41887592e4f4992fa2 Move frame instrumentation evaluation to using callback. Using a callback instead of a return value is in preparation for making the corruption score calculation truly asynchronous in some cases. Bug: webrtc:358039777 Change-Id: I8fc166a3236c5ccfb1e2cbacc0631091a2b3ad06 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398820 Reviewed-by: Fanny Linderborg <linderborg@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45117} Diffstat:
18 files changed, 145 insertions(+), 100 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-09T04:25:02.314623+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-09T04:26:06.417042+00:00. # base of lastest vendoring -78e1a84534 +d950a7fb2f diff --git a/third_party/libwebrtc/common_video/BUILD.gn b/third_party/libwebrtc/common_video/BUILD.gn @@ -29,6 +29,7 @@ rtc_library("corruption_score_calculator") { deps = [ ":frame_instrumentation_data", "../api/video:video_frame", + "../api/video:video_rtp_headers", ] } diff --git a/third_party/libwebrtc/common_video/include/corruption_score_calculator.h b/third_party/libwebrtc/common_video/include/corruption_score_calculator.h @@ -11,8 +11,7 @@ #ifndef COMMON_VIDEO_INCLUDE_CORRUPTION_SCORE_CALCULATOR_H_ #define COMMON_VIDEO_INCLUDE_CORRUPTION_SCORE_CALCULATOR_H_ -#include <optional> - +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" @@ -24,9 +23,10 @@ class CorruptionScoreCalculator { public: virtual ~CorruptionScoreCalculator() = default; - virtual std::optional<double> CalculateCorruptionScore( + virtual void CalculateCorruptionScore( const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data) = 0; + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type) = 0; }; } // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/generic_decoder.cc b/third_party/libwebrtc/modules/video_coding/generic_decoder.cc @@ -147,17 +147,6 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, return; } - std::optional<double> corruption_score; - if (corruption_score_calculator_ && - frame_info->frame_instrumentation_data.has_value()) { - if (const FrameInstrumentationData* data = - std::get_if<FrameInstrumentationData>( - &*frame_info->frame_instrumentation_data)) { - corruption_score = corruption_score_calculator_->CalculateCorruptionScore( - decodedImage, *data); - } - } - decodedImage.set_ntp_time_ms(frame_info->ntp_time_ms); decodedImage.set_packet_infos(frame_info->packet_infos); decodedImage.set_rotation(frame_info->rotation); @@ -255,8 +244,17 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, .qp = qp, .decode_time = decode_time, .content_type = frame_info->content_type, - .frame_type = frame_info->frame_type, - .corruption_score = corruption_score}); + .frame_type = frame_info->frame_type}); + + if (corruption_score_calculator_ && + frame_info->frame_instrumentation_data.has_value()) { + if (const FrameInstrumentationData* data = + std::get_if<FrameInstrumentationData>( + &*frame_info->frame_instrumentation_data)) { + corruption_score_calculator_->CalculateCorruptionScore( + decodedImage, *data, frame_info->content_type); + } + } } void VCMDecodedFrameCallback::OnDecoderInfoChanged( diff --git a/third_party/libwebrtc/modules/video_coding/generic_decoder_unittest.cc b/third_party/libwebrtc/modules/video_coding/generic_decoder_unittest.cc @@ -41,6 +41,9 @@ #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" +using ::testing::Eq; +using ::testing::Field; +using ::testing::Property; using ::testing::Return; namespace webrtc { @@ -48,10 +51,11 @@ namespace video_coding { class MockCorruptionScoreCalculator : public CorruptionScoreCalculator { public: - MOCK_METHOD(std::optional<double>, + MOCK_METHOD(void, CalculateCorruptionScore, (const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data), + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type), (override)); }; @@ -59,7 +63,6 @@ class ReceiveCallback : public VCMReceiveCallback { public: int32_t OnFrameToRender(const FrameToRender& arguments) override { frames_.push_back(arguments.video_frame); - last_corruption_score_ = arguments.corruption_score; return 0; } @@ -79,14 +82,9 @@ class ReceiveCallback : public VCMReceiveCallback { uint32_t frames_dropped() const { return frames_dropped_; } - std::optional<double> last_corruption_score() const { - return last_corruption_score_; - } - private: std::vector<VideoFrame> frames_; uint32_t frames_dropped_ = 0; - std::optional<double> last_corruption_score_; }; class GenericDecoderTest : public ::testing::Test { @@ -220,17 +218,13 @@ TEST_F(GenericDecoderTest, IsLowLatencyStreamActivatedByPlayoutDelay) { } TEST_F(GenericDecoderTest, CallCalculateCorruptionScoreInDecoded) { - constexpr double kCorruptionScore = 0.76; - - EXPECT_CALL(corruption_score_calculator_, CalculateCorruptionScore) - .WillOnce(Return(kCorruptionScore)); - constexpr uint32_t kRtpTimestamp = 1; FrameInfo frame_info; - frame_info.frame_instrumentation_data = FrameInstrumentationData{}; + frame_info.frame_instrumentation_data = + FrameInstrumentationData{.sequence_index = 1}; frame_info.rtp_timestamp = kRtpTimestamp; frame_info.decode_start = Timestamp::Zero(); - frame_info.content_type = VideoContentType::UNSPECIFIED; + frame_info.content_type = VideoContentType::SCREENSHARE; frame_info.frame_type = VideoFrameType::kVideoFrameDelta; VideoFrame video_frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(5, 5)) @@ -238,9 +232,12 @@ TEST_F(GenericDecoderTest, CallCalculateCorruptionScoreInDecoded) { .build(); vcm_callback_.Map(std::move(frame_info)); + EXPECT_CALL(corruption_score_calculator_, + CalculateCorruptionScore( + Property(&VideoFrame::rtp_timestamp, Eq(kRtpTimestamp)), + Field(&FrameInstrumentationData::sequence_index, Eq(1)), + VideoContentType::SCREENSHARE)); vcm_callback_.Decoded(video_frame); - - EXPECT_EQ(user_callback_.last_corruption_score(), kCorruptionScore); } } // namespace video_coding diff --git a/third_party/libwebrtc/modules/video_coding/include/video_coding_defines.h b/third_party/libwebrtc/modules/video_coding/include/video_coding_defines.h @@ -58,7 +58,6 @@ class VCMReceiveCallback { TimeDelta decode_time; VideoContentType content_type; VideoFrameType frame_type; - std::optional<double> corruption_score; }; virtual int32_t OnFrameToRender(const FrameToRender& arguments) = 0; diff --git a/third_party/libwebrtc/moz-patch-stack/s0037.patch b/third_party/libwebrtc/moz-patch-stack/s0037.patch @@ -53,10 +53,10 @@ index 18ee7ffa46..7e358c3c13 100644 // Implements RtpVideoFrameReceiver. void ManageFrame(std::unique_ptr<RtpFrameObject> frame) override; diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc -index 2e8bc0ba66..b9c6931cff 100644 +index 4660da8265..f8b2adcd88 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc -@@ -625,6 +625,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { +@@ -627,6 +627,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent; stats.sender_reports_reports_count = rtcp_sr_stats->reports_count; } diff --git a/third_party/libwebrtc/moz-patch-stack/s0042.patch b/third_party/libwebrtc/moz-patch-stack/s0042.patch @@ -190,10 +190,10 @@ index 7e358c3c13..05498bd640 100644 private: // Implements RtpVideoFrameReceiver. diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc -index b9c6931cff..8291132456 100644 +index f8b2adcd88..7030a702a1 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc -@@ -631,7 +631,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { +@@ -633,7 +633,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { // seem to be any support for these stats right now. So, we hack this in. rtp_video_stream_receiver_.RemoteRTCPSenderInfo( &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent, diff --git a/third_party/libwebrtc/moz-patch-stack/s0057.patch b/third_party/libwebrtc/moz-patch-stack/s0057.patch @@ -202,10 +202,10 @@ index b89ae42538..e35f8babb1 100644 RTC_DCHECK_RUN_ON(&main_thread_); last_codec_type_ = codec_type; diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h -index 023f4fa5f2..9c4df5c5ea 100644 +index 2fb819ae94..4702332dc5 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h -@@ -103,6 +103,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, +@@ -105,6 +105,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, void OnDecodableFrame(TimeDelta jitter_buffer_delay, TimeDelta target_delay, TimeDelta minimum_delay) override; @@ -272,10 +272,10 @@ index 05498bd640..e35711dc8b 100644 RTC_GUARDED_BY(packet_sequence_checker_); // h26x_packet_buffer_ is applicable to H.264 and H.265. For H.265 it is diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc -index 8291132456..e5ad9f76eb 100644 +index 7030a702a1..ea87ba1309 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc -@@ -256,6 +256,7 @@ VideoReceiveStream2::VideoReceiveStream2( +@@ -257,6 +257,7 @@ VideoReceiveStream2::VideoReceiveStream2( &stats_proxy_, &stats_proxy_, nack_periodic_processor, diff --git a/third_party/libwebrtc/moz-patch-stack/s0093.patch b/third_party/libwebrtc/moz-patch-stack/s0093.patch @@ -30,7 +30,7 @@ index 9a4f0f1b97..74f7c78e12 100644 if (rtc_use_perfetto) { rtc_library("webrtc_libperfetto") { diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc -index c605cf74e3..085e739ffc 100644 +index 14b5a92f82..e37fc9d6b6 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -122,9 +122,9 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, @@ -46,7 +46,7 @@ index c605cf74e3..085e739ffc 100644 // TODO(holmer): We should improve this so that we can handle multiple // callbacks from one call to Decode(). std::optional<FrameInfo> frame_info; -@@ -333,8 +333,8 @@ int32_t VCMGenericDecoder::Decode( +@@ -331,8 +331,8 @@ int32_t VCMGenericDecoder::Decode( const std::optional< std::variant<FrameInstrumentationSyncData, FrameInstrumentationData>>& frame_instrumentation_data) { diff --git a/third_party/libwebrtc/video/corruption_detection/BUILD.gn b/third_party/libwebrtc/video/corruption_detection/BUILD.gn @@ -32,6 +32,7 @@ rtc_library("frame_instrumentation_evaluation") { "../../api:array_view", "../../api:scoped_refptr", "../../api/video:video_frame", + "../../api/video:video_rtp_headers", "../../common_video:frame_instrumentation_data", "../../rtc_base:checks", "../../rtc_base:logging", @@ -162,6 +163,7 @@ if (rtc_include_tests) { ":frame_instrumentation_evaluation", "../../api:scoped_refptr", "../../api/video:video_frame", + "../../api/video:video_rtp_headers", "../../common_video:frame_instrumentation_data", "../../test:test_support", ] diff --git a/third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation.cc b/third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation.cc @@ -11,15 +11,14 @@ #include "video/corruption_detection/frame_instrumentation_evaluation.h" #include <cstddef> -#include <optional> #include <vector> #include "api/array_view.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "video/corruption_detection/corruption_classifier.h" #include "video/corruption_detection/halton_frame_sampler.h" namespace webrtc { @@ -41,42 +40,49 @@ std::vector<FilteredSample> ConvertSampleValuesToFilteredSamples( } // namespace -std::optional<double> GetCorruptionScore(const FrameInstrumentationData& data, - const VideoFrame& frame) { +FrameInstrumentationEvaluation::FrameInstrumentationEvaluation( + CorruptionScoreObserver* observer) + : observer_(observer), classifier_(/*scale_factor=*/3) { + RTC_CHECK(observer); +} + +void FrameInstrumentationEvaluation::OnInstrumentedFrame( + const FrameInstrumentationData& data, + const VideoFrame& frame, + VideoContentType content_type) { if (data.sample_values.empty()) { RTC_LOG(LS_WARNING) << "Samples are needed to calculate a corruption score."; - return std::nullopt; + return; } - HaltonFrameSampler frame_sampler; - frame_sampler.SetCurrentIndex(data.sequence_index); + frame_sampler_.SetCurrentIndex(data.sequence_index); std::vector<HaltonFrameSampler::Coordinates> sample_coordinates = - frame_sampler.GetSampleCoordinatesForFrame(data.sample_values.size()); + frame_sampler_.GetSampleCoordinatesForFrame(data.sample_values.size()); if (sample_coordinates.empty()) { RTC_LOG(LS_ERROR) << "Failed to get sample coordinates for frame."; - return std::nullopt; + return; } std::vector<FilteredSample> samples = GetSampleValuesForFrame( frame, sample_coordinates, frame.width(), frame.height(), data.std_dev); if (samples.empty()) { RTC_LOG(LS_ERROR) << "Failed to get sample values for frame"; - return std::nullopt; + return; } std::vector<FilteredSample> data_samples = ConvertSampleValuesToFilteredSamples(data.sample_values, samples); if (data_samples.empty()) { RTC_LOG(LS_ERROR) << "Failed to convert sample values to filtered samples"; - return std::nullopt; + return; } - CorruptionClassifier classifier(3); + double score = classifier_.CalculateCorruptionProbability( + data_samples, samples, data.luma_error_threshold, + data.chroma_error_threshold); - return classifier.CalculateCorruptionProbability(data_samples, samples, - data.luma_error_threshold, - data.chroma_error_threshold); + observer_->OnCorruptionScore(score, content_type); } } // namespace webrtc diff --git a/third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation.h b/third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation.h @@ -11,15 +11,39 @@ #ifndef VIDEO_CORRUPTION_DETECTION_FRAME_INSTRUMENTATION_EVALUATION_H_ #define VIDEO_CORRUPTION_DETECTION_FRAME_INSTRUMENTATION_EVALUATION_H_ -#include <optional> - +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" +#include "video/corruption_detection/corruption_classifier.h" +#include "video/corruption_detection/halton_frame_sampler.h" namespace webrtc { -std::optional<double> GetCorruptionScore(const FrameInstrumentationData& data, - const VideoFrame& frame); +class CorruptionScoreObserver { + public: + CorruptionScoreObserver() = default; + virtual ~CorruptionScoreObserver() = default; + + // Results of corruption detection for a single frame, with a likelihood score + // in the range [0.0, 1.0]. + virtual void OnCorruptionScore(double corruption_score, + VideoContentType content_type) = 0; +}; + +class FrameInstrumentationEvaluation { + public: + explicit FrameInstrumentationEvaluation(CorruptionScoreObserver* observer); + + void OnInstrumentedFrame(const FrameInstrumentationData& data, + const VideoFrame& frame, + VideoContentType frame_type); + + private: + CorruptionScoreObserver* const observer_; + + HaltonFrameSampler frame_sampler_; + CorruptionClassifier classifier_; +}; } // namespace webrtc diff --git a/third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation_unittest.cc b/third_party/libwebrtc/video/corruption_detection/frame_instrumentation_evaluation_unittest.cc @@ -11,18 +11,29 @@ #include "video/corruption_detection/frame_instrumentation_evaluation.h" #include <cstdint> -#include <optional> #include <vector> #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { namespace { +using ::testing::_; +using ::testing::AllOf; +using ::testing::Ge; +using ::testing::Le; + +class MockCorruptionScoreObserver : public CorruptionScoreObserver { + public: + MOCK_METHOD(void, OnCorruptionScore, (double, VideoContentType), (override)); +}; + scoped_refptr<I420Buffer> MakeI420FrameBufferWithDifferentPixelValues() { // Create an I420 frame of size 4x4. const int kDefaultLumaWidth = 4; @@ -52,9 +63,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional<double> corruption_score = GetCorruptionScore(data, frame); - - EXPECT_FALSE(corruption_score.has_value()); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore).Times(0); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } TEST(FrameInstrumentationEvaluationTest, @@ -71,10 +83,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional<double> corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_DOUBLE_EQ(*corruption_score, 1.0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(1.0, VideoContentType::SCREENSHARE)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::SCREENSHARE); } TEST(FrameInstrumentationEvaluationTest, @@ -91,11 +103,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional<double> corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_LE(*corruption_score, 1); - EXPECT_GE(*corruption_score, 0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(AllOf(Ge(0.0), Le(1.0)), _)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } TEST(FrameInstrumentationEvaluationTest, @@ -114,11 +125,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional<double> corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_LE(*corruption_score, 1); - EXPECT_GE(*corruption_score, 0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(AllOf(Ge(0.0), Le(1.0)), _)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } TEST(FrameInstrumentationEvaluationTest, ApplySequenceIndexWhenProvided) { @@ -136,11 +146,10 @@ TEST(FrameInstrumentationEvaluationTest, ApplySequenceIndexWhenProvided) { .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional<double> corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_LE(*corruption_score, 1); - EXPECT_GE(*corruption_score, 0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(AllOf(Ge(0.0), Le(1.0)), _)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } } // namespace diff --git a/third_party/libwebrtc/video/receive_statistics_proxy.h b/third_party/libwebrtc/video/receive_statistics_proxy.h @@ -40,6 +40,7 @@ #include "rtc_base/rate_tracker.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" +#include "video/corruption_detection/frame_instrumentation_evaluation.h" #include "video/stats_counter.h" #include "video/video_quality_observer2.h" #include "video/video_stream_buffer_controller.h" @@ -55,7 +56,8 @@ struct VideoFrameMetaData; class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, public RtcpCnameCallback, - public RtcpPacketTypeCounterObserver { + public RtcpPacketTypeCounterObserver, + public CorruptionScoreObserver { public: ReceiveStatisticsProxy(uint32_t remote_ssrc, Clock* clock, @@ -116,7 +118,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, void OnCname(uint32_t ssrc, absl::string_view cname) override; void OnCorruptionScore(double corruption_score, - VideoContentType content_type); + VideoContentType content_type) override; // Implements RtcpPacketTypeCounterObserver. void RtcpPacketTypesCounterUpdated( diff --git a/third_party/libwebrtc/video/video_receive_stream2.cc b/third_party/libwebrtc/video/video_receive_stream2.cc @@ -48,6 +48,7 @@ #include "api/video/recordable_encoded_frame.h" #include "api/video/render_resolution.h" #include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "api/video/video_frame_type.h" #include "api/video/video_rotation.h" @@ -267,6 +268,7 @@ VideoReceiveStream2::VideoReceiveStream2( max_wait_for_frame_(DetermineMaxWaitForFrame( TimeDelta::Millis(config_.rtp.nack.rtp_history_ms), false)), + frame_evaluator_(&stats_proxy_), decode_queue_(env_.task_queue_factory().CreateTaskQueue( "DecodingQueue", TaskQueueFactory::Priority::HIGH)) { @@ -661,10 +663,13 @@ void VideoReceiveStream2::UpdateHistograms() { stats_proxy_.UpdateHistograms(fraction_lost, rtp_stats, nullptr); } -std::optional<double> VideoReceiveStream2::CalculateCorruptionScore( +void VideoReceiveStream2::CalculateCorruptionScore( const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data) { - return GetCorruptionScore(frame_instrumentation_data, frame); + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type) { + RTC_DCHECK_RUN_ON(&decode_sequence_checker_); + frame_evaluator_.OnInstrumentedFrame(frame_instrumentation_data, frame, + content_type); } bool VideoReceiveStream2::SetBaseMinimumPlayoutDelayMs(int delay_ms) { diff --git a/third_party/libwebrtc/video/video_receive_stream2.h b/third_party/libwebrtc/video/video_receive_stream2.h @@ -34,6 +34,7 @@ #include "api/units/timestamp.h" #include "api/video/encoded_frame.h" #include "api/video/recordable_encoded_frame.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "call/call.h" @@ -50,6 +51,7 @@ #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" +#include "video/corruption_detection/frame_instrumentation_evaluation.h" #include "video/decode_synchronizer.h" #include "video/receive_statistics_proxy.h" #include "video/rtp_streams_synchronizer2.h" @@ -258,9 +260,10 @@ class VideoReceiveStream2 RTC_RUN_ON(decode_sequence_checker_); void UpdateHistograms(); - std::optional<double> CalculateCorruptionScore( + void CalculateCorruptionScore( const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data) override; + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type) override; const Environment env_; @@ -364,6 +367,9 @@ class VideoReceiveStream2 std::vector<std::unique_ptr<EncodedFrame>> buffered_encoded_frames_ RTC_GUARDED_BY(decode_sequence_checker_); + FrameInstrumentationEvaluation frame_evaluator_ + RTC_GUARDED_BY(decode_sequence_checker_); + // Used to signal destruction to potentially pending tasks. ScopedTaskSafety task_safety_; diff --git a/third_party/libwebrtc/video/video_stream_decoder2.cc b/third_party/libwebrtc/video/video_stream_decoder2.cc @@ -53,10 +53,6 @@ int32_t VideoStreamDecoder::OnFrameToRender(const FrameToRender& arguments) { receive_stats_callback_->OnDecodedFrame( arguments.video_frame, arguments.qp, arguments.decode_time, arguments.content_type, arguments.frame_type); - if (arguments.corruption_score.has_value()) { - receive_stats_callback_->OnCorruptionScore(*arguments.corruption_score, - arguments.content_type); - } incoming_video_stream_->OnFrame(arguments.video_frame); return 0; }