Skip to content

Camera portal (feat. PipeWire) - #9771

Merged
GeorgesStavracas merged 14 commits into
obsproject:masterfrom
GeorgesStavracas:gbsneto/pipewire-camera
Jan 11, 2024
Merged

GeorgesStavracas merged 14 commits into
obsproject:masterfrom
GeorgesStavracas:gbsneto/pipewire-camera

Conversation

@GeorgesStavracas

@GeorgesStavracas GeorgesStavracas commented Oct 28, 2023 •

Copy link
Copy Markdown
Member

This is not ready for prime time, but it's close enough to at least raise some awareness of it.

This patchset includes patches from columbarius, wim, and myself. I've absorbed Wim's patches into this patchset as well.

TODO:

  • Mark it as experimental, somehow
  • Camera resolutions
  • Camera framerate
  • Bugs:
    • Sometimes the video stream starts to cycle through old buffers
    • Sometimes the selected camera is not automatically started

Description

Adjust the PipeWire stream code to be able to be able to receive external registry vtables. That enables fetching devices that the PipeWire connection has, into a separate owner / object.

Then, add code to request permission to access cameras using the Camera portal; and to create and use a PipeWire stream from the portal as well.

Motivation and Context

The Camera portal + PipeWire combo is the future of cameras on the Linux desktop, but sadly the lack of real consumers of these APIs is blocking more progress. This gets us closer to this future 🙂

How Has This Been Tested?

  • Add the new Camera (PipeWire) source
  • Grant OBS Studio permission to access cameras
  • Select a camera

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@GeorgesStavracas GeorgesStavracas added Seeking Testers Build artifacts on CI platform/linux Categorizes issue or PR as affecting Linux specifically kind/feature Functionality or other elements that the project doesn't currently have. labels Oct 28, 2023
Comment thread plugins/linux-pipewire/CMakeLists.txt Resolved

@tytan652 tytan652 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have too much knowledge about PipeWire, but I'll try to take a deeper look.

Comment thread plugins/linux-pipewire/formats.c Resolved
Comment thread plugins/linux-pipewire/pipewire.c Resolved
Comment thread plugins/linux-pipewire/pipewire.c Resolved
@tytan652 tytan652 mentioned this pull request Nov 13, 2023
6 tasks done
@GeorgesStavracas
GeorgesStavracas force-pushed the gbsneto/pipewire-camera branch 4 times, most recently from 066374f to b9ac1ae Compare December 14, 2023 15:41
@GeorgesStavracas
GeorgesStavracas marked this pull request as ready for review December 14, 2023 16:11

@tytan652 tytan652 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a quick pass.

Don't forget my previous reviews about blog() usage.

There is various switches not enforcing the enum spa_media_subtype type which can lead to unwanted omission.

Comment thread plugins/linux-pipewire/pipewire.h Resolved
Comment thread plugins/linux-pipewire/pipewire.c Resolved
Comment thread plugins/linux-pipewire/pipewire.c Resolved
@GeorgesStavracas

Copy link
Copy Markdown
Member Author

After looking at how MJPEG and h264 streams aren't really working, I have decided to split it into a separate, follow-up pull request, so that we can review it separately from the this one.

This PR still supports YUY2 cameras so many of them are covered for the time being.

@tytan652 tytan652 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (not an PipeWire expert), beside some issue issue with my camera that are likely issue in the young new stack introduce by this portal (libcamera - PipeWire - xdg-desktop-portal).

GeorgesStavracas and others added 11 commits January 11, 2024 09:24
This will allow consumers of obs_pipewire to handle the device
registry themselves. This is not useful for the screencast code
since there's always only one node in the registry, but it will
be used by the camera and audio code to list hardware devices.
Generalize the async server roundtrip wait so that future consumers
can, for example, wait for all devices to be listed before acting
on the registry.
Make it a bit more semantic, and matching of PipeWire API.
This plugin adds a camera source for capture devices available
via PipeWire using the Camera portal.
List it in addition to YUV formats.

Co-authored-by: Georges Basile Stavracas Neto
<[email protected]>
This will help share these formats with the upcoming Camera portal
code.
Wait with starting the camera until we find the device in the
registry. Avoids cases where the camera stays unlinked.
Collect the controls on the node. Enumerate the controls as
properties.

Co-authored-by: Georges Basile Stavracas Neto
<[email protected]>
Trigger a renegotiation of the camera stream when either the
resolution or the framerate change.
wtay and others added 3 commits January 11, 2024 09:24
g_strerror only works for errno values, SPA errors are negative errno
values.
Rebuild the camera list when a camera was added or removed.
This allows the stream negotiation to set the camera values right
from the start.
@GeorgesStavracas
GeorgesStavracas merged commit 0335896 into obsproject:master Jan 11, 2024
@GeorgesStavracas
GeorgesStavracas deleted the gbsneto/pipewire-camera branch January 11, 2024 12:57
@GeorgesStavracas GeorgesStavracas mentioned this pull request Feb 1, 2024
5 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Functionality or other elements that the project doesn't currently have. platform/linux Categorizes issue or PR as affecting Linux specifically Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants