From 0c6e34ce5c4c5ebdab64bfa40b8dc970186fbd6d Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Tue, 15 Feb 2022 11:05:57 -0800 Subject: [PATCH] Ensure PipeWire doesn't use a Null SourceId This has mostly seemed to work fine until now; but there's a collision happening in chromium where if the source is being shown in the Window Picker it collides with the (also null) Dialog ID and is ignored. While we could patch that code to not count Null as a collision, there's the potential for other (future) code to simply ignore a capture source that it thinks is Null. Fixed: chromium:1295375 Change-Id: I4356084f0af97f4d56632938b0d9a24d327f7107 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251500 Reviewed-by: Mark Foltz Auto-Submit: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#36008} --- .../linux/wayland/base_capturer_pipewire.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc index c4ec92f919..b6120ee68c 100644 --- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc +++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc @@ -75,9 +75,14 @@ void BaseCapturerPipeWire::CaptureFrame() { bool BaseCapturerPipeWire::GetSourceList(SourceList* sources) { RTC_DCHECK(sources->size() == 0); - // List of available screens is already presented by the xdg-desktop-portal. - // But we have to add an empty source as the code expects it. - sources->push_back({0}); + // List of available screens is already presented by the xdg-desktop-portal, + // so we just need a (valid) source id for any callers to pass around, even + // though it doesn't mean anything to us. Until the user selects a source in + // xdg-desktop-portal we'll just end up returning empty frames. Note that "0" + // is often treated as a null/placeholder id, so we shouldn't use that. + // TODO(https://crbug.com/1297671): Reconsider type of ID when plumbing + // token that will enable stream re-use. + sources->push_back({1}); return true; }