Commit graph

101 commits

Author SHA1 Message Date
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
Georges Basile Stavracas Neto a1db8e5bde linux-pipewire: Factor out connection props in a struct
So that we can expand the number of construct-time connection
properties without changing the function signature every time.
This is mostly an ergonomic change for now, but it'll be very
useful when introducing the Camera portal code.
2023-12-14 10:20:55 -03:00
Georges Basile Stavracas Neto afab71aa80 linux-pipewire: Standardize argument names
Always name obs_pipewire_stream pointers 'obs_pw_stream', so as not
to confuse with obs_pipewire pointers which are called 'obs_pw'.
2023-12-14 10:20:55 -03:00
Translation Updater f674d17168 Update translations from Crowdin 2023-12-05 22:04:31 +00:00
Kurt Kartaltepe ea1d022c20 linux-pipewire: Ensure number of dmabufs is zero initialized
We use a size_t that can be 64bit while EGL uses 32bit for the
underlying value. Writes from our graphics function can leave high bits
uninitialized and cause iteration of the format list to overlfow.

fixes #9844
2023-11-12 13:32:24 -03:00
Kurt Kartaltepe 658657de35 linux-pipwire: Pass obs_pw_stream to renegotiation callback
We were passing the core pipewire pointer where renegotiation expected
the stream pointer. Somehow this worked, probably because the two are
very close.

fixes #9733
2023-10-28 18:26:29 -03:00
Kurt Kartaltepe 5cf0f06669 linux-pipewire: Load glad symbols on start
After the cmake 3.0 rebuild glad was transitioned to a static library.
This lead to the glad symbols being uninitialized and crashes when they
are used in some cases.
2023-10-24 09:34:38 -03:00
Kurt Kartaltepe 454fc559a2 linux-pipewire: Use the format properties for swap r/b
We refactored this data to be part of the format properties instead of
an out parameter. But forgot to start using this field instead.
2023-10-22 11:16:03 -03:00
Kurt Kartaltepe f0697980c3 linux-pipewire: Add locks to unsafe pipewire functions
These functions log that they should be used with the thread lock held,
so lets hold the lock before calling them.
2023-10-22 11:15:04 -03:00
Translation Updater 0d450a34a0 Update translations from Crowdin 2023-10-10 13:34:41 +00:00
Translation Updater ecf914dd67 Update translations from Crowdin 2023-08-13 14:09:15 +00:00
tytan652 7f4fd99f91 linux-pipewire: Replace dynamic arrays with allocations
Replace dynamic arrays added by 27630a8c0e
by allocations
2023-08-11 14:56:36 -03:00
tytan652 27630a8c0e linux-pipewire: Replace variable-length arrays with dynamic arrays
The in-tree simde is actually adding a pragma that makes -Wvla ignored
2023-08-06 01:31:02 +02:00
Georges Basile Stavracas Neto bdfead801e linux-pipewire: Explicitly handle NULL format strings
This is a workaround to the compiler complaining about directive
arguments being null.
2023-07-15 20:46:51 -03:00
Georges Basile Stavracas Neto 549c0f5850 linux-pipewire: Move portal signal subcription to portal.c
The D-Bus signal subscription is a very boring aspect of the
portals infrastructure that shouldn't really matter when reading
the code of pipewire.c.

Move it out to its natural place, portal.c.
2023-07-15 20:46:51 -03:00
columbarius 15b8c5b743 linux-pipewire: Add support for YUY2 2023-07-15 20:46:51 -03:00
columbarius 67f01c7a44 linux-pipewire: Add support for async sources
Cameras and audio streams will use the async output routines, but
not screencasting. This needs to be handled differently in the
processing callback.

As it is, the code is starting to get a bit messy, as we're now
dealing with two different frame processing approaches. Later on,
this code will be cleaned up and split in more logical pieces.

Co-authored-by: Georges Basile Stavracas Neto
<georges.stavracas@gmail.com>
2023-07-15 20:46:51 -03:00
Georges Basile Stavracas Neto c7e355e89c linux-pipewire: Store source when creating streams
We'll need to peek information about the source to determine how
to process frames, so store it for later usage.
2023-07-15 20:46:51 -03:00
columbarius 53ce8d5b65 linux-pipewire: Extend format_data
The media API requires it's own format (enum video_format) and
bytes per pixel (bpp).
2023-07-15 20:46:51 -03:00
Georges Basile Stavracas Neto 37fd856e91 linux-pipewire: Factor out format data in a struct
And use it instead of exhaustively open coding each field of
the anonymous struct into the arguments of the lookup function.
2023-07-15 20:46:51 -03:00
Georges Basile Stavracas Neto d40f5808f4 linux-pipewire: Move format info to streams
So far we've been treating format info on a per-connection basis,
but now that a single connection is capable of hosting multiple
streams, and each stream might negotiate a different format, it
is necessary to move format info to each stream individually.
2023-07-15 20:46:51 -03:00
Georges Basile Stavracas Neto 2f5c40b05b linux-pipewire: Track streams
Make obs_pipewire hold a list of streams created by itself, and
destroy these streams when closing the connection.
2023-07-15 20:46:51 -03:00
Georges Basile Stavracas Neto 330d54fada linux-pipewire: Separate PipeWire core and streams
Sorry, this is a painful commit to review :(

Until now, the only consumer of the PipeWire code is the screen
cast portal code. This portal code only ever has one PipeWire
connection, and one PipeWire stream, every time a monitor or a
window is selected. This is reflected on obs_pipewire, which only
handles a single stream for any given connection.

For cameras and audio, however, a single PipeWire connection can
and most likely always will provide multiple streams. For example,
computers with multiple webcams will have one PipeWire connection
reporting multiple PipeWire nodes, one node for each camera.

This commit breaks this one-stream-per-connection assumption, and
makes obs_pipewire_connect_stream() return an independent object
(obs_pipewire_stream) that represents a single stream.

The screencast portal code continues to only ever have one connection
and one stream.
2023-07-15 20:46:51 -03:00
columbarius a2b8ff2e35 linux-pipewire: Skip processing video buffer if import failed
After a failed import we should signal buffer renegotiaten and then just
skip processing this videobuffer.
2023-06-10 17:03:19 -07:00
columbarius 155fb8ad8f linux-pipewire: Support colour format GS_R10G10B10A2
PipeWire supports 10bit colour formats with little endian order.

Adding two new formats required increasing the buffer size for building
PipeWire buffers.

This formats are supported since PipeWire 0.3.41. To allow building
against
older PipeWire versions we will hide those formats. Complications when
running on a host with an older PipeWire version are not expected, since
format negotiation is only done via the numerical values.
2023-05-17 16:35:43 -03:00
Jim 8dbc4761a3 linux-pipewire: Reduce debug message verbosity 2023-05-02 01:50:13 -07:00
Translation Updater a0fbdc3c34 Update translations from Crowdin 2023-05-01 23:11:13 +00:00
Kurt Kartaltepe f0f704249f linux-pipewire: Only consider chunks with size set
Compositors did not agree on how to communicate invalid buffers until
recently, so e0a4d8628d resulted in
regressions on KDE. This restores our old behavior which is too
conservative but mostly works on old and new compositors (which contain
similar workarounds to pass in invalid but non-zero sizes for dma-bufs).

Once all old compositors are out of use we can remove this workaround
and then compositors can remove their random size workaround.
2023-04-22 16:45:50 -07:00
Asahi Lina 584de6b264 linux-pipewire: Use premultiplied alpha
Pipewire desktop portal capture assumes premultiplied alpha, so make
sure to use the right blend equation to make translucent pixels work
correctly.

This is still broken for emissive pixels (alpha < color) since OBS seems
to unpremultiply at some point during blending, but it works properly
for translucent pixels (emissive pixel support requires an end-to-end
premultiplied pipeline).
2023-04-01 16:11:19 -07:00