0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00
Commit Graph

80 Commits

Author SHA1 Message Date
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
Translation Updater
7c5560bf1b Update translations from Crowdin 2023-03-27 13:39:03 +00:00
PatTheMav
349372b3b3 cmake: Add changes for CMake build framework 3.0
New code path only taken if OBS_CMAKE_VERSION is set to 3.0.0 or
greater, old functionality remains unchanged.
2023-03-26 18:20:38 -04:00
tytan652
4d5cf98de0 linux-pipewire: Add missing struct typedef for older PipeWire
This allows building against PipeWire versions lower than 0.3.62.

The missing structure is copied verbatim from:
https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1423
2023-03-25 22:02:29 -04:00
Kurt Kartaltepe
9bde0afc74 linux-pipewire: Report modifiers in hex
Use hex for modifiers because they are generally formed from a high byte
and low bytes. This makes it easier to see these bytes and identify
unusual modifiers.
2023-03-17 10:48:51 -03:00
Robert Mader
0a36dc9d80 linux-pipewire: Clear cursor texture on empty bitmap
If we receive an empty cursor bitmap - one without valid size - we
should hide the cursor. Do so by clearing the texture.

This fixes visible cursors when recording various games with Wayland
compositors.

Closes https://github.com/obsproject/obs-studio/issues/4895
2023-03-14 10:52:17 -03:00
Georges Basile Stavracas Neto
f62f370edd linux-pipewire: Remove unnecessary variable
No functional changes. The code is just ever so slightly easier to
read now.
2023-03-01 20:47:49 -03:00
Georges Basile Stavracas Neto
436787c1f4 linux-pipewire: Check for effective crop region
Some compositors send buffer crop information even when the crop
matches the buffer size. It doesn't really matter in practice,
but it's good hygiene to check for the effective crop instead of
simply checking if crop exists.
2023-03-01 20:47:49 -03:00
Georges Basile Stavracas Neto
d68b061d57 linux-pipewire: Adjust cosmetics
Move code into auxiliary functions, to improve the legibility of the
draw function. It also gets rid of these pesky switch fallthroughs.
No functional changes.
2023-03-01 20:47:49 -03:00
Georges Basile Stavracas Neto
925888b763 linux-pipewire: Fix wrong error message
In the non-DMA path, we are logging an error message saying that
the DMA format is wrong. That's not the DMA format, it's the raw
buffer format.

Fix the message.
2023-03-01 20:47:49 -03:00
Georges Basile Stavracas Neto
f520b251fb linux-pipewire: Demote yet another error to debug
This was an oversight from commit be629b93c.
2023-03-01 20:47:49 -03:00
columbarius
8abc3528cf linux-pipewire: Read buffer transformation from PipeWire
PipeWire allows since 0.3.62 [1] to attach metadata to a buffer
describing a transformation of the buffercontent. Clients should then
undo that transformation to import it correctly.

We can enable this feature using macro guards and runtime server version
checks on supported systems.

[1] https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1423
2023-02-25 11:49:51 -03:00
Jan Beich
e98c9fbd65 linux-pipewire: Drop unused Linux-only header
<dma-buf.h> provides DMA_BUF_IOCTL_* which were never used by OBS.
2023-02-15 14:44:36 -05:00
Georges Basile Stavracas Neto
be629b93ce linux-pipewire: Demote error to debug message
Receiving buffers flagged as corrupted, or empty, is a casualty of
how things are implemented in various compositors, and it's not
a critical situation to be afraid of. We can expect a few buffers
to be flagged as corrupted here and there, and that's fine.

Demote these warnings to debug messages, as they're still useful
for debugging.
2023-02-14 18:50:57 -03:00
Georges Basile Stavracas Neto
fad7420198 linux-pipewire: Trivially shuffle some code around
A trivial cosmetic change. This groups the constructor and
destructor together. Two sides of the same coin, yin and yang,
bound by their nature, and linked by their position in code.
2023-02-13 12:28:09 -03:00
Georges Basile Stavracas Neto
f8a7b13cd3 linux-pipewire: Rename obs_pipewire_data to obs_pipewire
Next commits will introduce new obs_pipewire_* types, so this
renaming will make it slightly easier to read the code with
different types.
2023-02-13 12:28:09 -03:00
Georges Basile Stavracas Neto
b7daa89f85 linux-pipewire: Split initialization of core and streams
This commit introduces an important distinction in the initialization
process that is essential to future camera and audio work: it splits
creating and connecting to the PipeWire socket, from connecting to
specific PipeWire nodes.

Right now, for the only consumer in existence - the ScreenCast portal
code - this distinction is irrelevant, but from an API perspective it
just makes sense to model it this way.
2023-02-13 12:28:09 -03:00
Georges Basile Stavracas Neto
5065e86bb9 linux-pipewire: Remove unnecessary struct field
We don't actually need to restore the node id anymore, since this
is handled by the screencast-portal.c code now.

Remove the pipewire_node field, and just create the stream directly
from the passed file descriptor now.
2023-02-13 12:28:09 -03:00
Georges Basile Stavracas Neto
890ca94b0b linux-pipewire: Inline play_pipewire_stream()
This separation of obs_pipewire_create() and play_pipewire_stream()
was an artifact of how the original code was written, and there is
no reason to keep this separation anymore. Inlining it will help
future commits too.
2023-02-13 12:28:09 -03:00
columbarius
86be35ae99 linux-pipewire: Move stream properties to constructors
And let each portal pass the stream properties relevant to them.
This makes the pipewire.c more independent of the actual portal
by providing a wrapper to create a stream. This will be relevant
later, when linux-pipewire introduces more portals like the Camera
one.
2023-02-13 12:28:09 -03:00
Georges Basile Stavracas Neto
874c30cb88 linux-pipewire: Cleanup D-Bus proxy on unload
When the linux-pipewire plugin is unloaded, make sure to cleanup
the D-Bus proxy for the ScreenCast portal too. This effectively
doesn't change anything, but it's always good to keep up with the
code hygiene.
2023-02-13 12:28:09 -03:00
Georges Basile Stavracas Neto
b8cfe1aab1 linux-pipewire: Return actual type in obs_pipewire_create
Instead of returning an opaque void* pointer, return the leaf
C type obs_pipewire_data*.

This commit introduces no functional changes.
2023-02-13 12:28:09 -03:00