From a717c7ada811411e31bd7308168b4dbee5b956fa Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Wed, 6 Sep 2023 11:57:00 +0200 Subject: [PATCH] Video Capture PipeWire: Filter out non-camera nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can be helpful in various situations, such as debugging with an unrestricted Pipewire socket or for downstream projects like B2G/Capyloon. Additionally it will help once we move from the camera portal to the more generic device portal. Original patch by Fabrice Desré Bug: webrtc:15464 Change-Id: Iae6802f242d68244bca85947cb15ef3eee923ab0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318642 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/main@{#40706} --- AUTHORS | 1 + modules/video_capture/linux/pipewire_session.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/AUTHORS b/AUTHORS index eb393ef057..f4b6f8d65c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -104,6 +104,7 @@ Raman Budny Ramprakash Jelari Riku Voipio Robert Bares +Robert Mader Robert Mader Robert Nagy Ryan Yoakum diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc index 3f52b3dd61..4d1b200aca 100644 --- a/modules/video_capture/linux/pipewire_session.cc +++ b/modules/video_capture/linux/pipewire_session.cc @@ -360,6 +360,10 @@ void PipeWireSession::OnRegistryGlobal(void* data, if (!spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION)) return; + auto node_role = spa_dict_lookup(props, PW_KEY_MEDIA_ROLE); + if (!node_role || strcmp(node_role, "Camera")) + return; + that->nodes_.emplace_back(that, id, props); that->PipeWireSync(); }