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 <mfoltz@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#36008}
This commit is contained in:
Alex Cooper 2022-02-15 11:05:57 -08:00 committed by WebRTC LUCI CQ
parent 0b02d637c0
commit 0c6e34ce5c

View File

@ -75,9 +75,14 @@ void BaseCapturerPipeWire::CaptureFrame() {
bool BaseCapturerPipeWire::GetSourceList(SourceList* sources) { bool BaseCapturerPipeWire::GetSourceList(SourceList* sources) {
RTC_DCHECK(sources->size() == 0); RTC_DCHECK(sources->size() == 0);
// List of available screens is already presented by the xdg-desktop-portal. // 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. // so we just need a (valid) source id for any callers to pass around, even
sources->push_back({0}); // 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; return true;
} }