firefox/002-libwebrtc-pipewire-camera-support-additional-formats-and-fix-rgb-bgr-mapping.patch
Jan Grulich 85157a42c7 Enable PipeWire camera support for RHEL 10
Also backport upstream fixes for PipeWire camera support.

Resolves: RHEL-64749
2024-11-28 12:50:27 +01:00

88 lines
3.9 KiB
Diff

From fef1904f95dc592deef7044debe71a02c5d7046c Mon Sep 17 00:00:00 2001
From: Jan Grulich <jgrulich@redhat.com>
Date: Sat, 20 Jul 2024 07:04:27 +0000
Subject: [PATCH] Bug 1907013 - WebRTC backport: PipeWire camera: support
additional formats and fix RGB/BGR mapping r=jib,webrtc-reviewers
This is a simple backprot of an WebRTC upstream change.
Upstream commit: b1ebcfbfd6afb57f314b6689ca001aca1b13a5b4
Differential Revision: https://phabricator.services.mozilla.com/D216138
---
.../modules/video_capture/linux/pipewire_session.cc | 6 ++++++
.../video_capture/linux/video_capture_pipewire.cc | 12 ++++++++++--
.../moz-patch-stack/b1ebcfbfd6.no-op-cherry-pick-msg | 1 +
3 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 third_party/libwebrtc/moz-patch-stack/b1ebcfbfd6.no-op-cherry-pick-msg
diff --git a/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc b/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
index d52d6aacc8005..107ea3dfbd954 100644
--- a/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
+++ b/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
@@ -35,12 +35,18 @@ VideoType PipeWireRawFormatToVideoType(uint32_t id) {
return VideoType::kYUY2;
case SPA_VIDEO_FORMAT_UYVY:
return VideoType::kUYVY;
+ case SPA_VIDEO_FORMAT_RGB16:
+ return VideoType::kRGB565;
case SPA_VIDEO_FORMAT_RGB:
+ return VideoType::kBGR24;
+ case SPA_VIDEO_FORMAT_BGR:
return VideoType::kRGB24;
case SPA_VIDEO_FORMAT_BGRA:
return VideoType::kARGB;
case SPA_VIDEO_FORMAT_RGBA:
return VideoType::kABGR;
+ case SPA_VIDEO_FORMAT_ARGB:
+ return VideoType::kBGRA;
default:
return VideoType::kUnknown;
}
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
index 9ff4fdb9b1c98..1672b7583f582 100644
--- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
+++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc
@@ -34,10 +34,15 @@ struct {
{SPA_VIDEO_FORMAT_YUY2, VideoType::kYUY2},
{SPA_VIDEO_FORMAT_UYVY, VideoType::kUYVY},
// PipeWire is big-endian for the formats, while libyuv is little-endian
- // This means that BGRA == ARGB and RGBA == ABGR
+ // This means that BGRA == ARGB, RGBA == ABGR and similar
+ // This follows mapping in libcamera PipeWire plugin:
+ // https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/spa/plugins/libcamera/libcamera-utils.cpp
{SPA_VIDEO_FORMAT_BGRA, VideoType::kARGB},
{SPA_VIDEO_FORMAT_RGBA, VideoType::kABGR},
- {SPA_VIDEO_FORMAT_RGB, VideoType::kRGB24},
+ {SPA_VIDEO_FORMAT_ARGB, VideoType::kBGRA},
+ {SPA_VIDEO_FORMAT_RGB, VideoType::kBGR24},
+ {SPA_VIDEO_FORMAT_BGR, VideoType::kRGB24},
+ {SPA_VIDEO_FORMAT_RGB16, VideoType::kRGB565},
};
VideoType VideoCaptureModulePipeWire::PipeWireRawFormatToVideoType(
@@ -302,13 +307,16 @@ void VideoCaptureModulePipeWire::OnFormatChanged(const struct spa_pod* format) {
break;
case VideoType::kYUY2:
case VideoType::kUYVY:
+ case VideoType::kRGB565:
stride = configured_capability_.width * 2;
break;
case VideoType::kRGB24:
+ case VideoType::kBGR24:
stride = configured_capability_.width * 3;
break;
case VideoType::kARGB:
case VideoType::kABGR:
+ case VideoType::kBGRA:
stride = configured_capability_.width * 4;
break;
default:
diff --git a/third_party/libwebrtc/moz-patch-stack/b1ebcfbfd6.no-op-cherry-pick-msg b/third_party/libwebrtc/moz-patch-stack/b1ebcfbfd6.no-op-cherry-pick-msg
new file mode 100644
index 0000000000000..e795b816b1382
--- /dev/null
+++ b/third_party/libwebrtc/moz-patch-stack/b1ebcfbfd6.no-op-cherry-pick-msg
@@ -0,0 +1 @@
+We cherry-picked this in bug 1907013.