Backport upstream fixes to PipeWire camera support
This commit is contained in:
parent
7658746ef7
commit
879253503b
18
firefox.spec
18
firefox.spec
@ -179,7 +179,7 @@ ExcludeArch: i686
|
||||
Summary: Mozilla Firefox Web browser
|
||||
Name: firefox
|
||||
Version: 122.0
|
||||
Release: 6%{?pre_tag}%{?dist}
|
||||
Release: 7%{?pre_tag}%{?dist}
|
||||
URL: https://www.mozilla.org/firefox/
|
||||
License: MPLv1.1 or GPLv2+ or LGPLv2+
|
||||
Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz
|
||||
@ -260,6 +260,15 @@ Patch402: mozilla-1196777.patch
|
||||
Patch407: mozilla-1667096.patch
|
||||
Patch408: D167159.diff
|
||||
|
||||
# Firefox 123 patches for PipeWire camera support
|
||||
# https://phabricator.services.mozilla.com/D200147
|
||||
Patch420: libwebrtc-fix-serialization-of-cameraaccessstatus-enum.patch
|
||||
# Firefox 124 patches for PipeWire camera support
|
||||
# https://phabricator.services.mozilla.com/D200142
|
||||
Patch421: libwebrtc-allow-videocapturemodulepipewire-be-shared-with-more-consumers.patch
|
||||
# https://phabricator.services.mozilla.com/D201328
|
||||
Patch422: libwebrtc-simplify-thread-and-lock-annotations.patch
|
||||
|
||||
# PGO/LTO patches
|
||||
Patch600: pgo.patch
|
||||
Patch602: mozilla-1516803.patch
|
||||
@ -564,6 +573,10 @@ This package contains results of tests executed during build.
|
||||
%patch407 -p1 -b .1667096
|
||||
%patch408 -p1 -b .D167159
|
||||
|
||||
%patch420 -p1 -b .libwebrtc-fix-serialization-of-cameraaccessstatus-enum
|
||||
%patch421 -p1 -b .libwebrtc-allow-videocapturemodulepipewire-be-shared-with-more-consumers
|
||||
%patch422 -p1 -b .libwebrtc-simplify-thread-and-lock-annotations
|
||||
|
||||
# PGO patches
|
||||
%if %{build_with_pgo}
|
||||
%if !%{build_with_clang}
|
||||
@ -1186,6 +1199,9 @@ fi
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
%changelog
|
||||
* Mon Feb 12 2024 Jan Grulich <jgrulich@redhat.com> - 122.0-7
|
||||
- Backport upstream fixes to PipeWire camera support
|
||||
|
||||
* Mon Feb 12 2024 Martin Stransky <stransky@redhat.com>- 122.0-6
|
||||
- Temporary removed proxy cache (rhbz#2262959)
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
|
||||
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
|
||||
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
|
||||
@@ -48,10 +48,11 @@
|
||||
const rtc::scoped_refptr<PipeWireSession> session_
|
||||
RTC_GUARDED_BY(capture_checker_);
|
||||
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_);
|
||||
|
||||
struct pw_stream* stream_ RTC_GUARDED_BY(pipewire_checker_) = nullptr;
|
||||
struct spa_hook stream_listener_ RTC_GUARDED_BY(pipewire_checker_);
|
||||
};
|
||||
diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
|
||||
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
|
||||
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
|
||||
@@ -46,11 +46,14 @@
|
||||
return VideoType::kUnknown;
|
||||
}
|
||||
|
||||
VideoCaptureModulePipeWire::VideoCaptureModulePipeWire(
|
||||
VideoCaptureOptions* options)
|
||||
- : VideoCaptureImpl(), session_(options->pipewire_session()) {}
|
||||
+ : VideoCaptureImpl(),
|
||||
+ session_(options->pipewire_session()),
|
||||
+ initialized_(false),
|
||||
+ started_(false) {}
|
||||
|
||||
VideoCaptureModulePipeWire::~VideoCaptureModulePipeWire() {
|
||||
RTC_DCHECK_RUN_ON(&api_checker_);
|
||||
|
||||
StopCapture();
|
||||
@@ -119,10 +122,18 @@
|
||||
int32_t VideoCaptureModulePipeWire::StartCapture(
|
||||
const VideoCaptureCapability& capability) {
|
||||
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
|
||||
RTC_DCHECK_RUN_ON(&api_checker_);
|
||||
|
||||
+ if (initialized_) {
|
||||
+ if (capability == _requestedCapability) {
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ StopCapture();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
uint8_t buffer[1024] = {};
|
||||
|
||||
RTC_LOG(LS_VERBOSE) << "Creating new PipeWire stream for node " << node_id_;
|
||||
|
||||
PipeWireThreadLoopLock thread_loop_lock(session_->pw_main_loop_);
|
||||
@@ -169,10 +180,12 @@
|
||||
<< spa_strerror(res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
_requestedCapability = capability;
|
||||
+ initialized_ = true;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t VideoCaptureModulePipeWire::StopCapture() {
|
||||
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
|
17
libwebrtc-fix-serialization-of-cameraaccessstatus-enum.patch
Normal file
17
libwebrtc-fix-serialization-of-cameraaccessstatus-enum.patch
Normal file
@ -0,0 +1,17 @@
|
||||
diff --git a/dom/media/systemservices/CamerasTypes.h b/dom/media/systemservices/CamerasTypes.h
|
||||
--- a/dom/media/systemservices/CamerasTypes.h
|
||||
+++ b/dom/media/systemservices/CamerasTypes.h
|
||||
@@ -50,11 +50,11 @@
|
||||
mozilla::camera::CaptureEngine::InvalidEngine,
|
||||
mozilla::camera::CaptureEngine::MaxEngine> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::camera::CamerasAccessStatus>
|
||||
- : public ContiguousEnumSerializer<
|
||||
+ : public ContiguousEnumSerializerInclusive<
|
||||
mozilla::camera::CamerasAccessStatus,
|
||||
mozilla::camera::CamerasAccessStatus::Granted,
|
||||
mozilla::camera::CamerasAccessStatus::Error> {};
|
||||
} // namespace IPC
|
||||
|
||||
|
144
libwebrtc-simplify-thread-and-lock-annotations.patch
Normal file
144
libwebrtc-simplify-thread-and-lock-annotations.patch
Normal file
@ -0,0 +1,144 @@
|
||||
diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
|
||||
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
|
||||
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.h
|
||||
@@ -41,22 +41,20 @@
|
||||
static void OnStreamProcess(void* data);
|
||||
|
||||
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
|
||||
|
||||
#endif // MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_PIPEWIRE_H_
|
||||
diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
|
||||
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
|
||||
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
|
||||
@@ -119,11 +119,10 @@
|
||||
return static_cast<spa_pod*>(spa_pod_builder_pop(builder, &frames[0]));
|
||||
}
|
||||
|
||||
int32_t VideoCaptureModulePipeWire::StartCapture(
|
||||
const VideoCaptureCapability& capability) {
|
||||
- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
|
||||
RTC_DCHECK_RUN_ON(&api_checker_);
|
||||
|
||||
if (initialized_) {
|
||||
if (capability == _requestedCapability) {
|
||||
return 0;
|
||||
@@ -132,14 +131,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
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_);
|
||||
+
|
||||
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);
|
||||
|
||||
if (!stream_) {
|
||||
@@ -186,15 +192,17 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -223,18 +231,18 @@
|
||||
uint32_t id,
|
||||
const struct spa_pod* format) {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (spa_format_parse(format, &media_type, &media_subtype) < 0) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to parse video format.";
|
||||
@@ -329,11 +337,10 @@
|
||||
pw_stream_state state,
|
||||
const char* error_message) {
|
||||
VideoCaptureModulePipeWire* that =
|
||||
static_cast<VideoCaptureModulePipeWire*>(data);
|
||||
RTC_DCHECK(that);
|
||||
- RTC_CHECK_RUNS_SERIALIZED(&that->capture_checker_);
|
||||
|
||||
MutexLock lock(&that->api_lock_);
|
||||
switch (state) {
|
||||
case PW_STREAM_STATE_STREAMING:
|
||||
that->started_ = true;
|
||||
@@ -372,11 +379,11 @@
|
||||
return kVideoRotation_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;
|
||||
h = static_cast<struct spa_meta_header*>(
|
||||
spa_buffer_find_meta_data(buffer->buffer, SPA_META_Header, sizeof(*h)));
|
||||
diff --git a/third_party/libwebrtc/moz-patch-stack/541f202354.no-op-cherry-pick-msg b/third_party/libwebrtc/moz-patch-stack/541f202354.no-op-cherry-pick-msg
|
||||
new file mode 100644
|
||||
--- /dev/null
|
||||
+++ b/third_party/libwebrtc/moz-patch-stack/541f202354.no-op-cherry-pick-msg
|
||||
@@ -0,0 +1 @@
|
||||
+We cherry-picked this in bug 1879752.
|
||||
|
Loading…
Reference in New Issue
Block a user