85157a42c7
Also backport upstream fixes for PipeWire camera support. Resolves: RHEL-64749
62 lines
2.9 KiB
Diff
62 lines
2.9 KiB
Diff
From 12b7d28d858fdcfa80795a2af49a71d3b5142733 Mon Sep 17 00:00:00 2001
|
|
From: Jan Grulich <grulja@gmail.com>
|
|
Date: Tue, 12 Nov 2024 12:28:19 +0000
|
|
Subject: [PATCH] Bug 1930598 - WebRTC backport: PipeWire camera: use better
|
|
unique device name for camera devices r=pehrsons,webrtc-reviewers
|
|
|
|
Originally we used node id from PipeWire as an unique device name and
|
|
while this works, it will change everytime PipeWire is restarted. This
|
|
has an impact on default camera selection, where for example Firefox can
|
|
automatically request a camera device that was used before, but this can
|
|
break with the next PipeWire restart.
|
|
|
|
This is a simple backport of an WebRTC upstream change.
|
|
|
|
Upstream commit: a5d71009ac1dce7da23813dc9413c03073cfa8ca
|
|
|
|
Differential Revision: https://phabricator.services.mozilla.com/D228635
|
|
---
|
|
.../modules/video_capture/linux/pipewire_session.cc | 2 +-
|
|
.../video_capture/linux/video_capture_pipewire.cc | 11 +++++++----
|
|
.../moz-patch-stack/a5d71009ac.no-op-cherry-pick-msg | 1 +
|
|
3 files changed, 9 insertions(+), 5 deletions(-)
|
|
create mode 100644 third_party/libwebrtc/moz-patch-stack/a5d71009ac.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 641e5238ea..dd187c0358 100644
|
|
--- a/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
|
|
+++ b/third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc
|
|
@@ -74,7 +74,7 @@ PipeWireNode::PipeWireNode(PipeWireSession* session,
|
|
: session_(session),
|
|
id_(id),
|
|
display_name_(spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION)),
|
|
- unique_id_(rtc::ToString(id)) {
|
|
+ unique_id_(spa_dict_lookup(props, PW_KEY_NODE_NAME)) {
|
|
RTC_LOG(LS_VERBOSE) << "Found Camera: " << display_name_;
|
|
|
|
proxy_ = static_cast<pw_proxy*>(pw_registry_bind(
|
|
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 2338fa6d87..888b8f386f 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
|
|
@@ -82,12 +82,15 @@ int32_t VideoCaptureModulePipeWire::Init(const char* deviceUniqueId) {
|
|
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
|
|
RTC_DCHECK_RUN_ON(&api_checker_);
|
|
|
|
- absl::optional<int> id;
|
|
- id = rtc::StringToNumber<int>(deviceUniqueId);
|
|
- if (id == absl::nullopt)
|
|
+ auto node =
|
|
+ std::find_if(session_->nodes_.begin(), session_->nodes_.end(),
|
|
+ [deviceUniqueId](const PipeWireNode::PipeWireNodePtr& node) {
|
|
+ return node->unique_id() == deviceUniqueId;
|
|
+ });
|
|
+ if (node == session_->nodes_.end())
|
|
return -1;
|
|
|
|
- node_id_ = id.value();
|
|
+ node_id_ = (*node)->id();
|
|
|
|
const int len = strlen(deviceUniqueId);
|
|
_deviceUniqueId = new (std::nothrow) char[len + 1];
|