diff --git a/third_party/libwebrtc/README.moz-ff-commit b/third_party/libwebrtc/README.moz-ff-commit index c49fab909ca0e..addd13ae57f21 100644 --- a/third_party/libwebrtc/README.moz-ff-commit +++ b/third_party/libwebrtc/README.moz-ff-commit @@ -31776,3 +31776,6 @@ bef5d63112 # MOZ_LIBWEBRTC_SRC=/Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh # base of lastest vendoring e7686023a1 +# MOZ_LIBWEBRTC_SRC=/Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f237dc146d diff --git a/third_party/libwebrtc/README.mozilla b/third_party/libwebrtc/README.mozilla index a81310e87da26..ffdd17b4f4708 100644 --- a/third_party/libwebrtc/README.mozilla +++ b/third_party/libwebrtc/README.mozilla @@ -21208,3 +21208,5 @@ libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc co libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-08-28T17:21:13.694405. # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-08-28T17:23:39.728003. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-08-28T17:27:24.493750. diff --git a/third_party/libwebrtc/moz-patch-stack/0079.patch b/third_party/libwebrtc/moz-patch-stack/0079.patch index 90a40617eee28..aebc8c18d5b5c 100644 --- a/third_party/libwebrtc/moz-patch-stack/0079.patch +++ b/third_party/libwebrtc/moz-patch-stack/0079.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc -index af26db8719..7ef6ea5f77 100644 +index a9391e0cea..ef3d85f8b4 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -1368,7 +1368,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { diff --git a/third_party/libwebrtc/video/quality_convergence_controller.cc b/third_party/libwebrtc/video/quality_convergence_controller.cc index 7a46e1106290b..a19cb8c998b87 100644 --- a/third_party/libwebrtc/video/quality_convergence_controller.cc +++ b/third_party/libwebrtc/video/quality_convergence_controller.cc @@ -44,6 +44,7 @@ void QualityConvergenceController::Initialize( absl::optional static_qp_threshold, VideoCodecType codec, const FieldTrialsView& trials) { + RTC_DCHECK(sequence_checker_.IsCurrent()); RTC_CHECK(number_of_layers > 0); number_of_layers_ = number_of_layers; convergence_monitors_.clear(); @@ -61,11 +62,20 @@ bool QualityConvergenceController::AddSampleAndCheckTargetQuality( int layer_index, int qp, bool is_refresh_frame) { + RTC_DCHECK(sequence_checker_.IsCurrent()); RTC_CHECK(initialized_); if (layer_index < 0 || layer_index >= number_of_layers_) { return false; } + // TODO(kron): Remove temporary check that verifies that the initialization is + // working as expected. See https://crbug.com/359410061. + RTC_DCHECK(number_of_layers_ == + static_cast(convergence_monitors_.size())); + if (number_of_layers_ != static_cast(convergence_monitors_.size())) { + return false; + } + convergence_monitors_[layer_index]->AddSample(qp, is_refresh_frame); return convergence_monitors_[layer_index]->AtTargetQuality(); } diff --git a/third_party/libwebrtc/video/quality_convergence_controller.h b/third_party/libwebrtc/video/quality_convergence_controller.h index 46f8419c418d1..a09dc872a784f 100644 --- a/third_party/libwebrtc/video/quality_convergence_controller.h +++ b/third_party/libwebrtc/video/quality_convergence_controller.h @@ -16,6 +16,7 @@ #include "absl/types/optional.h" #include "api/field_trials_view.h" +#include "api/sequence_checker.h" #include "api/video/video_codec_type.h" #include "video/quality_convergence_monitor.h" @@ -41,6 +42,7 @@ class QualityConvergenceController { bool initialized_ = false; int number_of_layers_ = 0; std::vector> convergence_monitors_; + SequenceChecker sequence_checker_{SequenceChecker::kDetached}; }; } // namespace webrtc diff --git a/third_party/libwebrtc/video/video_stream_encoder.cc b/third_party/libwebrtc/video/video_stream_encoder.cc index 7ef6ea5f77cb5..ef3d85f8b41ed 100644 --- a/third_party/libwebrtc/video/video_stream_encoder.cc +++ b/third_party/libwebrtc/video/video_stream_encoder.cc @@ -2090,22 +2090,11 @@ EncodedImage VideoStreamEncoder::AugmentEncodedImage( .value_or(-1); } - // Check if the encoded image has reached target quality. - const size_t simulcast_index = encoded_image.SimulcastIndex().value_or(0); - bool at_target_quality = - quality_convergence_controller_.AddSampleAndCheckTargetQuality( - simulcast_index, image_copy.qp_, - image_copy.IsSteadyStateRefreshFrame()); - image_copy.SetAtTargetQuality(at_target_quality); TRACE_EVENT2("webrtc", "VideoStreamEncoder::AugmentEncodedImage", "stream_idx", stream_idx, "qp", image_copy.qp_); - TRACE_EVENT_INSTANT2("webrtc", "VideoStreamEncoder::AugmentEncodedImage", - TRACE_EVENT_SCOPE_GLOBAL, "simulcast_idx", - simulcast_index, "at_target_quality", at_target_quality); RTC_LOG(LS_VERBOSE) << __func__ << " ntp time " << encoded_image.NtpTimeMs() << " stream_idx " << stream_idx << " qp " - << image_copy.qp_ << " at target quality " - << at_target_quality; + << image_copy.qp_; return image_copy; } @@ -2128,11 +2117,16 @@ EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage( unsigned int image_width = image_copy._encodedWidth; unsigned int image_height = image_copy._encodedHeight; encoder_queue_->PostTask([this, codec_type, image_width, image_height, - simulcast_index, - at_target_quality = - image_copy.IsAtTargetQuality()] { + simulcast_index, qp = image_copy.qp_, + is_steady_state_refresh_frame = + image_copy.IsSteadyStateRefreshFrame()] { RTC_DCHECK_RUN_ON(encoder_queue_.get()); + // Check if the encoded image has reached target quality. + bool at_target_quality = + quality_convergence_controller_.AddSampleAndCheckTargetQuality( + simulcast_index, qp, is_steady_state_refresh_frame); + // Let the frame cadence adapter know about quality convergence. if (frame_cadence_adapter_) frame_cadence_adapter_->UpdateLayerQualityConvergence(simulcast_index, diff --git a/third_party/libwebrtc/video/video_stream_encoder.h b/third_party/libwebrtc/video/video_stream_encoder.h index 579cd3238c980..e593f91d444c7 100644 --- a/third_party/libwebrtc/video/video_stream_encoder.h +++ b/third_party/libwebrtc/video/video_stream_encoder.h @@ -422,7 +422,8 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, // The quality convergence controller is used to determine if a codec has // reached its target quality. This is used for screenshare to determine when // there's no need to continue encoding the same repeated frame. - QualityConvergenceController quality_convergence_controller_; + QualityConvergenceController quality_convergence_controller_ + RTC_GUARDED_BY(encoder_queue_); // Enables encoder switching on initialization failures. bool switch_encoder_on_init_failures_;