diff options
Diffstat (limited to 'third_party/libwebrtc/moz-patch-stack/0106.patch')
-rw-r--r-- | third_party/libwebrtc/moz-patch-stack/0106.patch | 208 |
1 files changed, 114 insertions, 94 deletions
diff --git a/third_party/libwebrtc/moz-patch-stack/0106.patch b/third_party/libwebrtc/moz-patch-stack/0106.patch index d232dcb897..1db996311f 100644 --- a/third_party/libwebrtc/moz-patch-stack/0106.patch +++ b/third_party/libwebrtc/moz-patch-stack/0106.patch @@ -1,107 +1,127 @@ -From: Michael Froman <mfroman@mozilla.com> -Date: Mon, 18 Dec 2023 15:00:00 +0000 -Subject: Bug 1867099 - revert libwebrtc 8602f604e0. r=bwc +From: Jan Grulich <jgrulich@redhat.com> +Date: Tue, 13 Feb 2024 13:12:00 +0000 +Subject: Bug 1879752 - WebRTC backport: Video capture PipeWire - simplify + thread and lock annotations r=pehrsons,webrtc-reviewers -Upstream 8602f604e0 removed code sending BYEs which breaks some of -our wpt. They've opened a bug for a real fix here: -https://bugs.chromium.org/p/webrtc/issues/detail?id=15664 +This is a simple backport of an WebRTC upstream change. -I've opened Bug 1870643 to track the real fix and upstream bug. +Upstream commit: 541f202354e2b4906935c8db6e54386aa8bc8d1f -Differential Revision: https://phabricator.services.mozilla.com/D196729 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d92a578327f524ec3e1c144c82492a4c76b8266f +Differential Revision: https://phabricator.services.mozilla.com/D201328 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/dc12e6eecaa8dc91ee0a517cfd27570691c441b9 --- - call/rtp_video_sender.cc | 1 + - modules/rtp_rtcp/source/rtcp_sender.cc | 19 +++++++++++++++++-- - .../rtp_rtcp/source/rtcp_sender_unittest.cc | 5 +++-- - modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 1 + - modules/rtp_rtcp/source/rtp_rtcp_interface.h | 2 +- - 5 files changed, 23 insertions(+), 5 deletions(-) + .../linux/video_capture_pipewire.cc | 25 ++++++++++++------- + .../linux/video_capture_pipewire.h | 14 +++++------ + 2 files changed, 22 insertions(+), 17 deletions(-) -diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc -index 1ace08fa32..4d99c61bb4 100644 ---- a/call/rtp_video_sender.cc -+++ b/call/rtp_video_sender.cc -@@ -510,6 +510,7 @@ void RtpVideoSender::SetActiveModulesLocked( - const bool was_active = rtp_module.Sending(); - const bool should_be_active = active_modules[i]; - -+ // Sends a kRtcpByeCode when going from true to false. - rtp_module.SetSendingStatus(active_modules[i]); - - if (was_active && !should_be_active) { -diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc -index 099b0be1a3..971f49b949 100644 ---- a/modules/rtp_rtcp/source/rtcp_sender.cc -+++ b/modules/rtp_rtcp/source/rtcp_sender.cc -@@ -212,8 +212,23 @@ bool RTCPSender::Sending() const { - - void RTCPSender::SetSendingStatus(const FeedbackState& feedback_state, - bool sending) { -- MutexLock lock(&mutex_rtcp_sender_); -- sending_ = sending; -+ bool sendRTCPBye = false; -+ { -+ MutexLock lock(&mutex_rtcp_sender_); +diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc +index fb813e331f..8af483636a 100644 +--- a/modules/video_capture/linux/video_capture_pipewire.cc ++++ b/modules/video_capture/linux/video_capture_pipewire.cc +@@ -121,7 +121,6 @@ static spa_pod* BuildFormat(spa_pod_builder* builder, + + int32_t VideoCaptureModulePipeWire::StartCapture( + const VideoCaptureCapability& capability) { +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + RTC_DCHECK_RUN_ON(&api_checker_); + + if (initialized_) { +@@ -134,10 +133,17 @@ int32_t VideoCaptureModulePipeWire::StartCapture( + + uint8_t buffer[1024] = {}; + ++ // We don't want members above to be guarded by capture_checker_ as ++ // it's meant to be for members that are accessed on the API thread ++ // only when we are not capturing. The code above can be called many ++ // times while sharing instance of VideoCapturePipeWire between ++ // websites and therefore it would not follow the requirements of this ++ // checker. ++ RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); ++ PipeWireThreadLoopLock thread_loop_lock(session_->pw_main_loop_); + -+ if (method_ != RtcpMode::kOff) { -+ if (sending == false && sending_ == true) { -+ // Trigger RTCP bye -+ sendRTCPBye = true; -+ } -+ } -+ sending_ = sending; -+ } -+ if (sendRTCPBye) { -+ if (SendRTCP(feedback_state, kRtcpBye) != 0) { -+ RTC_LOG(LS_WARNING) << "Failed to send RTCP BYE"; -+ } -+ } + RTC_LOG(LS_VERBOSE) << "Creating new PipeWire stream for node " << node_id_; + +- PipeWireThreadLoopLock thread_loop_lock(session_->pw_main_loop_); +- RTC_CHECK_RUNS_SERIALIZED(&pipewire_checker_); + pw_properties* reuse_props = + pw_properties_new_string("pipewire.client.reuse=1"); + stream_ = pw_stream_new(session_->pw_core_, "camera-stream", reuse_props); +@@ -188,11 +194,13 @@ int32_t VideoCaptureModulePipeWire::StartCapture( } - void RTCPSender::SetNonSenderRttMeasurement(bool enabled) { -diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc -index 002a5f86f1..1dcb628722 100644 ---- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc -+++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc -@@ -328,12 +328,13 @@ TEST_F(RtcpSenderTest, SendBye) { - EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc()); + int32_t VideoCaptureModulePipeWire::StopCapture() { +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + RTC_DCHECK_RUN_ON(&api_checker_); + + PipeWireThreadLoopLock thread_loop_lock(session_->pw_main_loop_); +- RTC_CHECK_RUNS_SERIALIZED(&pipewire_checker_); ++ // PipeWireSession is guarded by API checker so just make sure we do ++ // race detection when the PipeWire loop is locked/stopped to not run ++ // any callback at this point. ++ RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + if (stream_) { + pw_stream_destroy(stream_); + stream_ = nullptr; +@@ -225,14 +233,14 @@ void VideoCaptureModulePipeWire::OnStreamParamChanged( + VideoCaptureModulePipeWire* that = + static_cast<VideoCaptureModulePipeWire*>(data); + RTC_DCHECK(that); +- RTC_CHECK_RUNS_SERIALIZED(&that->pipewire_checker_); ++ RTC_CHECK_RUNS_SERIALIZED(&that->capture_checker_); + + if (format && id == SPA_PARAM_Format) + that->OnFormatChanged(format); } --TEST_F(RtcpSenderTest, StopSendingDoesNotTriggersBye) { -+TEST_F(RtcpSenderTest, StopSendingTriggersBye) { - auto rtcp_sender = CreateRtcpSender(GetDefaultConfig()); - rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize); - rtcp_sender->SetSendingStatus(feedback_state(), true); - rtcp_sender->SetSendingStatus(feedback_state(), false); -- EXPECT_EQ(0, parser()->bye()->num_packets()); -+ EXPECT_EQ(1, parser()->bye()->num_packets()); -+ EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc()); + void VideoCaptureModulePipeWire::OnFormatChanged(const struct spa_pod* format) { +- RTC_CHECK_RUNS_SERIALIZED(&pipewire_checker_); ++ RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + + uint32_t media_type, media_subtype; + +@@ -331,7 +339,6 @@ void VideoCaptureModulePipeWire::OnStreamStateChanged( + VideoCaptureModulePipeWire* that = + static_cast<VideoCaptureModulePipeWire*>(data); + RTC_DCHECK(that); +- RTC_CHECK_RUNS_SERIALIZED(&that->capture_checker_); + + MutexLock lock(&that->api_lock_); + switch (state) { +@@ -374,7 +381,7 @@ static VideoRotation VideorotationFromPipeWireTransform(uint32_t transform) { } - TEST_F(RtcpSenderTest, SendFir) { -diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc -index cca9a40250..a63067141d 100644 ---- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc -+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc -@@ -296,6 +296,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() { - - int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { - if (rtcp_sender_.Sending() != sending) { -+ // Sends RTCP BYE when going from true to false - rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending); - } - return 0; -diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h -index f196d11b58..bc8da63ab6 100644 ---- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h -+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h -@@ -277,7 +277,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { - // Returns the FlexFEC SSRC, if there is one. - virtual absl::optional<uint32_t> FlexfecSsrc() const = 0; - -- // Sets sending status. -+ // Sets sending status. Sends kRtcpByeCode when going from true to false. - // Returns -1 on failure else 0. - virtual int32_t SetSendingStatus(bool sending) = 0; + void VideoCaptureModulePipeWire::ProcessBuffers() { +- RTC_CHECK_RUNS_SERIALIZED(&pipewire_checker_); ++ RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + + while (pw_buffer* buffer = pw_stream_dequeue_buffer(stream_)) { + struct spa_meta_header* h; +diff --git a/modules/video_capture/linux/video_capture_pipewire.h b/modules/video_capture/linux/video_capture_pipewire.h +index 5d6794ed65..eeb3b9497c 100644 +--- a/modules/video_capture/linux/video_capture_pipewire.h ++++ b/modules/video_capture/linux/video_capture_pipewire.h +@@ -43,18 +43,16 @@ class VideoCaptureModulePipeWire : public VideoCaptureImpl { + void OnFormatChanged(const struct spa_pod* format); + void ProcessBuffers(); + +- rtc::RaceChecker pipewire_checker_; +- + const rtc::scoped_refptr<PipeWireSession> session_ +- RTC_GUARDED_BY(capture_checker_); ++ RTC_GUARDED_BY(api_checker_); ++ bool initialized_ RTC_GUARDED_BY(api_checker_); ++ bool started_ RTC_GUARDED_BY(api_lock_); + int node_id_ RTC_GUARDED_BY(capture_checker_); + VideoCaptureCapability configured_capability_ +- RTC_GUARDED_BY(pipewire_checker_); +- bool initialized_ RTC_GUARDED_BY(capture_checker_); +- bool started_ RTC_GUARDED_BY(api_lock_); ++ RTC_GUARDED_BY(capture_checker_); +- struct pw_stream* stream_ RTC_GUARDED_BY(pipewire_checker_) = nullptr; +- struct spa_hook stream_listener_ RTC_GUARDED_BY(pipewire_checker_); ++ struct pw_stream* stream_ RTC_GUARDED_BY(capture_checker_) = nullptr; ++ struct spa_hook stream_listener_ RTC_GUARDED_BY(capture_checker_); + }; + } // namespace videocapturemodule + } // namespace webrtc |