129 Commits

Author SHA1 Message Date
Barnabás Pőcze
5d04d51011 linux-pipewire: Fix uninitialized camera resolution access
The use of `SPA_POD_OPT_Rectangle()` means that if the rectangle cannot be
parsed, then no error will be returned. In that case uninitialized variables
will be used. This can happen if the pod object contains e.g. a list of
resolutions (`SPA_CHOICE_Enum`).

Fix that by using `SPA_POD_Rectangle()`, which enforces successful parsing.
2026-03-08 00:09:24 -05:00
tytan652
0d1f61b04b linux-pipewire: Fix camera framerate listing
The SPA format (pixelformat) was compared with a libobs video format
value.

Also removes the SPA format support check since at this point it already
has been done while listing formats.
2026-01-23 10:57:10 -05:00
Barnabás Pőcze
c13c7c0c3f linux-pipewire: Fix format description
The resolution and aspect ration should be added to the description of
the format even if there are no available frame rates.

The code is restructured a bit to avoid having to call `dstr_free()`
before each `continue`.

Fixes: 4cfcfc8c35 ("linux-pipewire: Make camera framerate non-mandatory")
2026-01-16 14:50:27 -05:00
tytan652
4cfcfc8c35 linux-pipewire: Make camera framerate non-mandatory
Formats can be without any framerate options.
2026-01-14 14:25:27 -05:00
Matt Gajownik
a5f0988933 Update translations from Crowdin 2026-01-10 01:02:43 -05:00
Matt Gajownik
99c3a4b797 Update translations from Crowdin 2025-09-08 22:38:40 -04:00
tytan652
2fe0385d13 linux-pipewire: Add aspect ratio to video capture format name 2025-08-22 14:34:28 -04:00
tytan652
3cce28a1d3 linux-pipewire: Add framerates to video capture format name 2025-08-22 14:34:28 -04:00
tytan652
c11253bb08 linux-pipewire: Use list-based format selector for video capture
Negotiation is now made with the user selected format.

Also fixes a typo in the name of a structure.
2025-08-22 14:34:28 -04:00
tytan652
24597a7b8e Revert "linux-pipewire: Fix 10- and 16-bit captures"
This reverts commit 4dfd0b31e4.

Also adds a FIXME comment.
2025-07-25 15:30:52 -04:00
Ivan Molodetskikh
fb09098fd7 linux-pipewire: Ensure the release point is always signaled
Since video rendering happens on a separate thread from PipeWire buffer
ingestion, it may happen that two buffers are ingested in quick
succession without the rendering thread ever getting to them. Since,
prior to this commit, the release sync point is only "primed" (set to
signal in the future) only on the video rendering thread, this results
in the buffer being returned to PipeWire's pool without anything ever
signaling the release point, effectively blocking it from ever getting
reused in the future. This quickly clogs up the buffer pool and leaves
only one buffer to circulate between the screencast source and OBS.

This commit adds a flag tracking whether the release point had been
primed. If, when ingesting a new PW buffer, the old buffer's release
point hadn't been primed, that means the video rendering thread never
got to that buffer, so the release point is immediately signaled,
marking the buffer reusable by the screencast source.
2025-07-25 13:55:31 -04:00
Ivan Molodetskikh
a7de3f4bde linux-pipewire: Dup syncobj fds
PipeWire format renegotiation runs in parallel with video rendering.

When the stream format is renegotiated, PipeWire removes the existing
buffers and closes the syncobj file descriptors. At the same time, the
video rendering thread may try to import the (already closed) syncobj
acquire fd, and hang on waiting for the fence to become available.

This is not a problem for the dmabuf fd because it's imported into a
texture right away, which doesn't disappear when PipeWire closes the fd.

This commit adds duping to the syncobj fds so that they too remain open
as long as the rendering thread may access them.
2025-07-25 13:55:31 -04:00
Ivan Molodetskikh
7092bc17db linux-pipewire: Require Gio 2.76
Subsequent commits use g_clear_fd() added in GLib 2.76.
2025-07-25 13:55:31 -04:00
Matt Gajownik
ffef7504ac Update translations from Crowdin 2025-06-09 14:55:50 -04:00
PancakeTAS
f614064eb4 linux-pipewire: Fix render technique in captures 2025-05-27 14:14:26 -04:00
PancakeTAS
4dfd0b31e4 linux-pipewire: Fix 10- and 16-bit captures 2025-04-01 16:01:29 -04:00
Doğukan Korkmaztürk
c2b4823075 linux-pipewire: Add explicit sync support
It is possible for OBS to receive incomplete frames from the compositor
if the graphics drivers in use do not support implicit synchronization.
The compositors usually try to workaround this issue by waiting all
render operations to complete before sharing frames with OBS. However,
this has performance implications for the compositors. Similarly, OBS
should also make sure that all the rendering operations sourcing the
received buffer are complete before returning the respective pw_buffer
back to the compositor, or it would risk the image it is working on
getting overwritten without some type of synchronization.

This change leverages PipeWire's ability to share DRM syncobj fds to
implement an explicit synchronization solution to solve the problem
described above. The usage of these DRM syncobjs is negotiated with the
compositor that OBS is running on. So OBS can still work even if the
compositor does not support explicit synchronization.

Signed-off-by: Doğukan Korkmaztürk <dkorkmazturk@nvidia.com>
2025-02-05 16:20:15 -05:00
Translation Updater
0b2c85845e Update translations from Crowdin 2024-12-06 23:21:55 +00:00
dimtpap
7c523c495c linux-pipewire: Fix memory leaks 2024-10-29 15:47:19 -04:00
tytan652
641d651e55 linux-pipewire: Avoid trying to allocate 0 byte 2024-10-05 16:50:31 -07:00
Translation Updater
e6d9f73736 Update translations from Crowdin 2024-10-05 05:02:27 +00:00
Ryan Foster
a1fbf1015f clang-format: Increase column limit from 80 to 120 2024-10-04 18:19:27 -04:00
PatTheMav
6c590805e8 cmake: Update supported CMake version range to 3.28 and 3.30 2024-09-13 14:42:32 -04:00
tytan652
31385006d5 Remove legacy_check CMake macro
The macro was not removed in 72428ccd97
waiting for submodules to be be updated to a commit where their legacy
code path is removed.
2024-09-11 13:24:39 -04:00
tytan652
72428ccd97 Remove CMake legacy code path
Except submodules and legacy_check macro since the former depend on it.
2024-08-28 13:53:25 -04:00
PatTheMav
b8cfacaec3 Update formatting of CMake files 2024-08-14 12:07:47 -04:00
Norihiro Kamae
f811903e4f linux-pipewire: Remove unused function 2024-08-07 17:27:49 -04:00
Translation Updater
e7d6707fa7 Update translations from Crowdin 2024-07-17 09:34:12 +00:00
Translation Updater
8999d9fef9 Update translations from Crowdin 2024-06-07 09:47:58 +00:00
tytan652
dfef65c30f linux-pipewire: Unify ScreenCast sources as Screen Capture
Allow to select both main type of ScreenCast (monitor, window)
with only one source type rather than adding a source type per
ScreenCast type.

This change is made as a new Screen Capture source type which
obsoletes the use of the previous Screen Capture (monitor-only)
and Window Capture.
2024-05-09 14:55:18 -03:00
PatTheMav
4ecfdb722f plugins: Add Linux-specific plugins for CMake build framework 3.0 2024-04-13 23:48:38 -04:00
Kurt Kartaltepe
befce71219 linux-pipewire: Fix future compiler errors
Unused variables and missing switch branches will break in cmake 3.0,
and are breaking for me right now so let's merge this early.
2024-04-13 21:37:17 -04:00
Translation Updater
10b02e11d0 Update translations from Crowdin 2024-03-12 18:11:06 +00:00
Vainock
7ae66c72fd Update translations from Crowdin 2024-02-28 14:20:05 -05:00
Translation Updater
ac484a066f Update translations from Crowdin 2024-01-29 20:47:38 +00:00
Georges Basile Stavracas Neto
03358961aa linux-pipewire: Pass framerate and resolution at construction
This allows the stream negotiation to set the camera values right
from the start.
2024-01-11 09:57:08 -03:00
Wim Taymans
bc02779529 linux-pipewire: Handle camera hotplug
Rebuild the camera list when a camera was added or removed.
2024-01-11 09:57:08 -03:00
Wim Taymans
968d7259bf linux-pipewire: Use spa_strerror to convert SPA errors to string
g_strerror only works for errno values, SPA errors are negative errno
values.
2024-01-11 09:57:08 -03:00
Wim Taymans
a683c5f3ce linux-pipewire: Add float property support 2024-01-11 09:57:08 -03:00
Wim Taymans
a44228ef50 linux-pipewire: Add resolution and framerate list contents
Trigger a renegotiation of the camera stream when either the
resolution or the framerate change.
2024-01-11 09:57:08 -03:00
Wim Taymans
12eba3f5d7 linux-pipewire: Handle property changes 2024-01-11 09:57:08 -03:00
Wim Taymans
07cbbe9bec linux-pipewire: Collect device controls
Collect the controls on the node. Enumerate the controls as
properties.

Co-authored-by: Georges Basile Stavracas Neto
<georges.stavracas@gmail.com>
2024-01-11 09:57:08 -03:00
Wim Taymans
e6d98ebfbb linux-pipewire: Start camera only after we find the device
Wait with starting the camera until we find the device in the
registry. Avoids cases where the camera stays unlinked.
2024-01-11 09:57:08 -03:00
Georges Basile Stavracas Neto
364323e445 linux-pipewire: Factor out formats list into a file
This will help share these formats with the upcoming Camera portal
code.
2024-01-11 09:57:08 -03:00
Wim Taymans
7f765cdb4c linux-pipewire: Add NV12 support
List it in addition to YUV formats.

Co-authored-by: Georges Basile Stavracas Neto
<georges.stavracas@gmail.com>
2024-01-11 09:57:08 -03:00
Georges Basile Stavracas Neto
c1b3831ba2 linux-pipewire: Add PipeWire-based camera source
This plugin adds a camera source for capture devices available
via PipeWire using the Camera portal.
2024-01-11 09:57:08 -03:00
Georges Basile Stavracas Neto
261cb91c62 linux-pipewire: Rename a function
Make it a bit more semantic, and matching of PipeWire API.
2024-01-11 09:57:08 -03:00
Georges Basile Stavracas Neto
56d3720ffa linux-pipewire: Add obs_pipewire_roundtrip()
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.
2024-01-11 09:57:08 -03:00
Georges Basile Stavracas Neto
6499d01bec linux-pipewire: Allow passing registry events on creation
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.
2024-01-11 09:57:08 -03:00
Georges Basile Stavracas Neto
67c1202849 linux-pipewire: Add screencast cursor_visible prop
This commit adds the screencast-specific 'cursor_visible' field
in an anonymous struct within the constructor struct.

This slightly improves the connection code by properly treating
construction-time information in a constructor struct. It allows
removing the extra function call that sets cursor visibility from
the Screencast portal code.

Admittedly that's not much, but again, this will be an important
distinction when introducing the Camera portal code, since some
camera properties will need to trigger renegotiation.
2023-12-14 10:20:55 -03:00