Commit graph

259 commits

Author SHA1 Message Date
vaxerski
e2cfaf3eee minor nix fixes 2022-12-03 23:42:56 +00:00
vaxerski
37c76fd7d8 start at pos 7 to avoid a warn 2022-12-03 23:40:08 +00:00
vaxerski
2dc95fe02f Allow region sharing 2022-12-03 22:42:21 +00:00
vaxerski
80775707ea Implement hyprland-share-picker 2022-12-03 21:27:49 +00:00
columbarius
c83b3cc514 screenshot: Announce version property 2022-09-12 23:33:54 +02:00
columbarius
723934d0b0 screencast: check if a valid format was received from wlr_screencopy
When a screencast is started we do a roundtrip on get the offered
formats from wlr_screencopy. This roundtrip can fail [1]. In this case
the formats won't be initialized and we will just error out of the
screencast session.

[1] https://github.com/emersion/xdg-desktop-portal-wlr/issues/214
2022-06-09 11:19:54 +02:00
columbarius
0bbd652c1c screencast: send pesentation timestamp via PipeWire 2022-06-01 21:12:46 +02:00
columbarius
b5491df0c0 screencast: destroy session if output is removed
We teardown all existing screencast_instances using the removed output
by destroying the frame, removing all timers and then marking the
instance as ready for teardown so we can destroy it after the last connected
session is closed.

Any wlr_screencopy_frame_v1 has to be destroyed before the connected
output can be removed. Otherwise wlr_screencopy_frame_v1_destroy
segfaults the whole program. To ensure this we will make all frame
callbacks safe to be triggered for a previous destroyed frame.
2022-05-31 01:23:34 +02:00
columbarius
ab0a07142d screencast: use wl_array for format-modifier-pairs
wl_array is a better fit than wl_list. It's less intensive on memory and
fits nicely with the flow of dmabuf_feedback announcing all format
modifier pairs at once and reseting them on change.
2022-05-31 01:22:48 +02:00
columbarius
2d54aeb36d screencast: fix handler logging for tranche_formats 2022-05-26 09:39:14 +02:00
columbarius
e70a1efa43 screencast: skip duplicated format-modifier pairs 2022-05-26 09:00:40 +02:00
columbarius
2219db7508 screencast: use dmabuf_feedback
The compositor can announce it's default rendering device via
linux_dmabuf_feedback as the main_device [1]. We should use this device
whenever possible. If aquiring this device fails we are adviced to use
force linear layout on buffers allocated with the implicit api.

With linux_dmabuf_v1 the modifier event is deprecated. Instead the
format_table event in combination with the tranches of
linux_dmabuf_feedback_v1 has to be used.

[1] https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/unstable/linux-dmabuf/feedback.rst
2022-05-26 09:00:40 +02:00
columbarius
14852efb05 screencast: Remove MESA hack from the old gbm api fallback
Calling gbm_bo_create_with_modifiers2(...) and setting the modifiers
pointer to NULL for the same result as gmb_bo_create(...) is a MESA hack,
which I missed to remove from 84282e9b5f.
2022-05-05 18:13:02 +02:00
columbarius
29f86168b6 screencast: announce supported explicit modifiers
We query the supported modifiers via a wrapper and announce them via
PipeWire.

This wrapper queries the supported formats from wlroots and returns them
as a simple array. The purpose of this wrapper is to ease the use of the
query functions which are kept in the style of the equivalent egl
queries.
2022-04-24 21:46:39 +02:00
columbarius
18efde6dde screencast: add function to query supported modifiers for a format
This function follows the structure of the equivalent function in egl
operating on basis of the announced format modifier pairs by wlroots.
2022-04-24 21:46:39 +02:00
columbarius
2ca2b7b603 screencast: get supported format modifier pairs from wlroots
Registering a zwp_linux_dmabuf_v1_listener gives access to the supported
format modifier pairs of the compositor.

This handler emits events for each format modifier pair. Those are stored
and will later be used to announce capabilities via PipeWire.
2022-04-24 21:46:39 +02:00
columbarius
b9c4472c50 screencast: stop assuming that allocation with implicit modifier works
It has shown that the assumption: "Allocation with implicit modifier will
always be available" doesn't hold true in all cases. Thus if allocation
of any dmabuf fails we mark the session to avoid dmabufs, thus falling
back to shm transport.
2022-04-24 21:46:39 +02:00
columbarius
84282e9b5f screencast: fixate modifier from PipeWire format negotiation result
This implements the modifier fixation procedure. The producer of a
stream has to ensure that it can create a buffer with the negotiated
properties. To do that we will take the result of the intersection of
supported modifiers by PipeWire and select the "best" modifier from that
list.

To do this we do the following allocations and fixate on the
modifier of the created buffer should the allocation suceed.
* Try to allocate a buffer with explicit modifiers using the list
  provided by PipeWire
* Walk the list of modifiers and do single allocations for implicit and
  linear modifiers using the old api.

If none of the allocations above succeed we fall back to shm buffers.
This is implemented in the next commit.

If an allocation was successfull we fixate the modifier with
fixate_format().
This function creates an EnumFormat like build_format, but will only
announce support for a single modifier.
It is used to finish the negotiation process by announcing it together
with EnumFormats of our full supported formats.
2022-04-24 21:46:39 +02:00
columbarius
a70a1195d4 screencast: check if pipewire returns a modifier list
Using SPA_POD_PROP_FLAG_DONT_FIXATE pipewire can return a list of
supported modifiers. In that case are we responsible to select one
modifier and fixate it.
2022-04-24 21:46:39 +02:00
columbarius
77bcd14ad2 screencast: support allocation of buffers with explicit modifiers 2022-04-24 21:46:39 +02:00
columbarius
1a7276068b screencast: support multiplane buffers with xdpw_buffer 2022-04-24 21:46:39 +02:00
columbarius
5799adeb57 screencast: enqueue pipewire when screencopy failed
Keeping a buffer when the copy failed has the risk of having this buffer
removed while we wait for the next buffer_done event. To prevent this we
just enqueue the buffer marking it as corrupt. A new buffer will be
dequeued at the buffer_done event.
2022-04-24 21:46:39 +02:00
columbarius
2f32d17448 screencast: remove swap_buffer function
Dequeuing a new buffer imidiately creates a problem when the buffer is
destroid while renegotiation of a valid modifier because we can end up using
a buffer which was freed while waiting for the buffer_done event. Then
xdpw will segfault when requesting a copy with a nonexisting buffer. To fix
this we can just dequeue a buffer right before we need it. This makes
the fallback via on_process obsolete since we dequeue the buffer at the
lates possible time.
2022-04-24 21:46:39 +02:00
Alias Gram
657b9edad5 chore(logging): change config file error to info 2022-04-18 18:44:47 +02:00
columbarius
6cec421f92 screencast: improve logging for pipewire events
We should log buffer add and remove events in the debug loglevel, since
they signal starts, stops and renegotiations of the buffer transfer.
Additionaly logging the negotiated pwr_format should help classify
issues from the DEBUG loglevel.
2022-04-10 13:38:01 +02:00
columbarius
852e1c95c7 screencast: HACK set an arbitrary chunk size for dmabufs
Clients have wrongly used the chunk size to detect if a buffer was valid
or not. Since dmabufs might not have a well defined buffer size we will
set an arbitrary value until clients are patched.
2022-04-10 13:38:01 +02:00
columbarius
0683f7ca7e screencast: add option to force implicit modifier to be linear
Linear buffer layouts are supported by most gpu vendors and as such
should be compatible in mixed mutli gpu setup where the implicit
modifier of one gpu is not supported by the other.

This option should make xdpw work in these environemnts.

The option is marked as experimental since it might be removed if
explicit modifiers provide a better solution.
2022-04-10 13:38:01 +02:00
columbarius
9085996111 screencast: announce implicit modifier via PipeWire 2022-04-10 13:38:01 +02:00
columbarius
d89631c792 screencast: allocate dmabuf with implicit modifier
This is using the older gbm api without support for explicit modifiers.
This is required to support AMD gpus using the GFX8 or older
architecture and older intel gpus.
2022-04-10 13:38:01 +02:00
columbarius
b2c5a94e8c screencast: add linux_dmabuf to registry 2022-04-10 13:38:01 +02:00
columbarius
9d620273e5 screencast: create gbm device
This is done by using the first device returned by getDRMDevices2
containing a render node (DRM_NODE_RENDER).
2022-04-10 13:38:01 +02:00
columbarius
bae393a684 screencast: support modifiers in build_format
When announcing support for dmabufs via PipeWire this is done by adding
the SPA_FORMAT_VIDEO_modifier property to an EnumFormat. Producers can
choose between two different ways [1]:

* Supporting only implicit modifiers by adding the property as a sigle
  value together with the SPA_POD_PROP_FLAG_MANDATORY flag
* Support for multiple modifiers. This is done by announcing a
  SPA_CHOICE_ENUM array together with the use of the
  SPA_POD_PROP_FLAG_MANDATORY and SPA_POD_PROP_FLAG_DONT_FIXATE flag

[1] https://docs.pipewire.org/page_dma_buf.html
2022-04-10 13:38:01 +02:00
columbarius
6630525b7a screencast: implement wlr_frame_linux_dmabuf 2022-04-10 13:38:01 +02:00
columbarius
12de0cd144 screencast: introduce buffer_type
We want to support WL_SHM and DMABUFS based buffers. The buffer_type
member tracks the type of a xdpw_buffer and screencopy_frame_info of the
screencast_instance will be an array with an element for each buffer type
indexed by the value of the buffer_type enum. Only members of the
xdpw_screencopy_frame_info relevant to the buffer type should be used.
2022-04-10 13:38:01 +02:00
columbarius
88a8a9cb7e screencast: add build_buffer function
This function makes it easier to omit attributes like size or stride for
cases where they won't be well defined like muliplanar dmabufs
2022-04-10 13:38:01 +02:00
columbarius
0835d8287b screencast: introduce build_formats
We build EnumFormats from our supported format multiple times. This
commit just creates a function to do that. This makes it easier to
handle the announcement of multiple buffer types.
2022-04-10 13:38:01 +02:00
columbarius
ba0f40e45c screencast: disable instance sharing
PipeWire currently will not renegotiate the used format of a stream when
a new client connects. This causes clients to get stuck when they are
incompatible with the format negotiated for the existing stream.
This will be problematic when some clients support dmabuf transport
while others won't. Thus we disable it until a solution is found.
2022-04-10 13:38:01 +02:00
columbarius
3a57c24437 screencast: use drm format instead of wl_shm
drm format defined by drm_fourcc.h is the standard to describe the
format of a buffer. This will be used when dealing with dmabufs and to
simplify things we should drm_formats for all internal structs.
2022-04-10 13:38:01 +02:00
columbarius
ce9d77c90c screencast: relax buffer flip
In case a client doesn't return a buffer early enough we can give it a
second chance by triggering on_process before we pass the buffer to
wlroots in the frame_buffer_done event.
2022-04-04 15:37:53 +02:00
columbarius
074e62d0c3 screencast: restructure the screencopy flow
The previous implemented way to use wlr_screencopy events to cicle the
screencast had issues, like halting the stream if it was paused and
resumed before PipeWire triggered a recreation of buffers. This came
from not returning a dequeued buffer. This is now mititgated by
enqueuing the current pw_buffer imidiately on a paused event and trying
to dequeue a buffer just before requesting a screencopy if none is
present.
2022-04-04 15:37:53 +02:00
columbarius
058bd97815 screencast: introduce xdpw_buffer
It showed that handling self contained buffers is much easier then have
the metadata of the buffer seperated from the actual buffer attached to
the screencast instance.

The goal of the following changes is to separate the meta informations
like requested buffer attributes and wlr_screencast data from the actual
buffers.

This enables us to:
* Simplify the flow between the PipeWire loop and the wlroots one
* Track and apply damage to each used buffer (ext_screencopy)
2022-04-04 15:37:53 +02:00
columbarius
e28f5e06e6 screencast: rename screencopy_frame to screencopy_frame_info 2022-04-04 15:37:53 +02:00
columbarius
21d26fe23e session: destroy screencast_instance directly when paused
A PipeWire client might pause the stream which enables us to stop
requesting buffers from the compositor. In this case the the quit bool
won't be enacted on and thus we should destroy it directly from here.
2022-04-04 15:37:53 +02:00
columbarius
10a07f7e90 screencast: don't use the PipeWire event to trigger screencast
Using the on_process event of the PipeWire can create a race condition
when a previous started screencast hasn't finished before the next
event.
2022-04-04 15:37:53 +02:00
columbarius
c34d09877c screencast: fix check on loop_iterate
According to the documentation [1] pw_loop_iterate (a macro for
spa_loop_control_iterate) will return the number of dispatched fd's
and thus we should check only negative return values.

[1] https://docs.pipewire.org/group__spa__loop.html#ga3bae0b32100f5752b3372a505c8e04f6
2022-01-20 16:27:35 +01:00
columbarius
55d73ab647 screencast: fix missing return value assignement 2022-01-18 13:30:17 +01:00
Quantum
d0c6b7f3a9 Implement xdpw_format_pw_strip_alpha for 10-bit colour
This was missed in the original PR adding support for 10-bit colour.
2021-12-28 09:37:58 +01:00
Quantum
74307ceabf Add support for 10-bit colour formats
This makes PipeWire 0.3.41 the minimum required version.
2021-12-20 10:09:16 +01:00
columbarius
b2f1a10023 screencast: use the pipewire callback process to start screencast
We can trigger that with pw_stream_trigger_process when we are the
driver of the stream. Additionally this let's us run passivly with the
consumer driving the stream.
2021-11-06 16:51:36 +01:00
columbarius
5eed00bb66 screencast: use asserts for fatal errors 2021-11-06 16:51:36 +01:00
columbarius
8f05ade2a2 screencast: mark buffer as invalid when screencopy fails 2021-11-06 16:51:36 +01:00
columbarius
cd30bd0f8e screencast: don't fail when copy_buffer was unsuccessfull
When a buffer is destroyed while used in the copy_buffer request the
screencopy protocoll will answer with the failed event. This can happen
anytime when PipeWire calls the remove_buffer callback, eg. on
renegotiation. This is not fatal, so we don't need to close the
screencast.

cast->err should only be used for fatal errors.
2021-11-06 16:51:36 +01:00
columbarius
35cba50409 screencast: drop imported PipeWire buffer on remove_buffer
PipeWire can request to destroy the allocated buffers anytime. This
isn't a problem for us, since the screencopy protocol can handle
disappearing buffers. The only thing we have to do is not to use a
destroyed buffer.
2021-11-06 16:51:36 +01:00
columbarius
66db43ea0e screencast: introduce xdpw_frame_state and xdpw_wlr_stream_finish
The enum xdpw_frame_state is used to track the state of the xdpw_frame through
the screencopy callbacks. xdpw_wlr_stream_finish is used as the new
endpoint of the screencopy callbacks. Here we clean up the
screencopy_frame, enqueue the pipewire buffer and restart the screencopy
loop if needed.
2021-11-06 16:51:36 +01:00
columbarius
b986020050 screencast: reorder screencopy callbacks
They callbacks are now in the order they are used by screencopy.
2021-11-06 16:51:36 +01:00
columbarius
1534a6a17e screencast: only end the fps measurement when it was started before
Sometimes it can happen that the first frame of the active stream
triggers the renegotiation and destroy the frame without copy and with
that starting the fps_limit counter. This triggers an assert in
fps_limit_measure_end. To avoid it, we only engage the fps_limiter after
a frame was copied successfully.
2021-11-06 16:51:36 +01:00
columbarius
27d1e42ec0 screencast: cleanup screencopy_frame
Move duplicated information to xdpw_frame and remove them from
xdpw_screencopy_frame.
2021-11-06 16:51:36 +01:00
columbarius
4d892f2a43 screencast: use pipewire buffers directly for wlroots screencopy
Instead of using one wl_buffer to export buffers from wlroots and then
copy the content into the buffer dequed from pipewire, we can create a
wl_buffer for each pipewire buffer directly at allocation time and
attach it to the data attribute. Those wl_buffers can be directly handed
over to the wlroots screencopy protocol and so removing one copy.
2021-11-06 16:51:36 +01:00
columbarius
78efdff460 screencast: implement buffer property checks wrt. xdpw_frame and xdpw_screencopy_frame
Since we gather the information of the currently used buffer on
importing it, we can check if the imported and the announce buffer by
wlroots are compatible.

Also the comparison between the announced buffer properties and the
format used by the pipewire stream was moved to wlr_frame_buffer_done.
This lets us implement all checks in the same callback and makes it
easier to extend those checks for future dmabuf sharing.
2021-11-06 16:51:36 +01:00
columbarius
fc85f6738b screencast: only restart wlroots loop if stream is active
This prevents the wlroots loop from running after the first roundtrip to
query the buffer informations from the screencopy protocol.
2021-11-06 16:51:36 +01:00
columbarius
f77b751649 screencast: rename xdpw_frame into xdpw_screencopy_frame 2021-11-06 16:51:36 +01:00
columbarius
566fb7c1a0 screencast: pipewire add import_wl_shm_buffer function
This function lets us create a wl_buffer from any shared memory
filedescriptor.
2021-11-06 16:51:36 +01:00
columbarius
9bf7367320 screencast: remove pipewire on_event callback
Since we are driving the screencast there are no events on the pipewire loop
calling the on_event callback. We want to import and export (if possible) on
every frame of the wlroots loop, so this event is no longer needed.
2021-11-06 16:51:36 +01:00
columbarius
11de00735f screencast: use dequeue/enqueue functions instead of on_process event to interact with pipewire 2021-11-06 16:51:36 +01:00
columbarius
4b03a5acfd screencast: pipewire add functions to dequeue and enqueue a buffer 2021-11-06 16:51:36 +01:00
Tobias Langendorf
9ef1d6aa2b Fix exec_before/after leaving a zombie process behind 2021-09-01 21:54:08 +02:00
columbarius
5f5a29ccfd screencast: fix pipewire default id_node
The default node_id is SPA_ID_INVALID.

We are casting pipewire uint32_t node_id to int for printing since they are
currently staying in the range of low integer numbers. This makes
spotting an uninitialized node_id (casted to -1) much easier. Should be
corrected if that becomes an issue in the future.
2021-08-10 13:10:10 +02:00
columbarius
6cc3a01741 screencast: pipewire change to self allocation of shm buffers 2021-07-02 12:12:17 +02:00
columbarius
a33034acce screencast: pipewire remove uneeded PW_STREAM_FLAG_MAP_BUFFERS flag 2021-07-02 12:12:17 +02:00
columbarius
6a3832277f screencast: pipewire move buffer information from pwr_on_event to pwr_handle_stream_add_buffer 2021-07-02 12:12:17 +02:00
columbarius
03146fa1d7 screencast: pipewire add {add,remove}_buffer handler 2021-07-02 12:12:17 +02:00
columbarius
9653abc330 screencast: announce supported buffer type 2021-07-02 12:12:17 +02:00
columbarius
ac5c248340 screencast: update pipewire params on buffer change 2021-07-02 09:45:46 +02:00
columbarius
f2d08cc5b5 screencast: create pwr_update_stream_param
This will let us notify pipewire that our buffer has changed and trigger a renegotiation cycle which will take care of reallocating the buffers
2021-07-02 09:45:46 +02:00
columbarius
50cb55ed1d screencast: add logging to pwr_handle_stream_param_changed in pipewire_sreencast.c 2021-07-02 09:45:46 +02:00
columbarius
ab8e3bea00 pipewire: stop announcing a range as the video size
We can only serve a video with a size as send from the compositor,
so no need to announce any range.
2021-07-02 08:58:13 +02:00
columbarius
dee06d015d pipewire: add the striped format inside of build_format 2021-07-02 08:58:13 +02:00
columbarius
773186d2ed pipewire: move enumformat creation into seperate function 2021-07-02 08:58:13 +02:00
GermainZ
668509e317 Fix potential memory corruption when reading bools
As per `man sd_bus_message_read`, boolean items should be read into an
int rather than a bool as the latter can cause memory corruption.
2021-07-01 13:49:31 +02:00
Simon Ser
e23e109e41 Handle POLLHUP
This makes xdpw exit when either the D-Bus daemon, the Wayland
compositor or Pipewire is shut down. This avoids having dangling
non-functional xdpw instances, e.g. when restarting the compositor.

To test, start Sway nested in Sway, run xdpw with
WAYLAND_DISPLAY=wayland-2, and exit the nested Sway.
2021-07-01 11:58:26 +02:00
columbarius
96d2789d8f screencast: don't rely on the structure of xdpw_screencast_instance to convert formats 2021-06-29 15:08:02 +02:00
columbarius
bb24b226e4 screencast: respect the maximal framerate negotiated by pipewire 2021-06-23 09:32:08 +02:00
columbarius
976fa8374d screencast: limit screencast framerate by output framerate 2021-06-23 09:32:08 +02:00
columbarius
6438edb7b9 config: handle missing HOME env variable gracefully
Fixes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/149
2021-06-17 09:37:16 +02:00
Tobias Jakobi
0d23a5ea15 screencast: move xdpw_pwr_stream_destroy() up
- keep the order of functions in-sync with the header
2021-05-24 10:03:40 +02:00
Tobias Jakobi
f60bdcef71 screencast: improve cleanup on error in xdpw_screencast_init()
- currently the cleanup can segfault due to uninitialized
  list objects
- introduce xdpw_pwr_context_destroy() and fixup goto logic
2021-05-24 10:03:40 +02:00
Tobias Jakobi
d2fa4aa5e7 screencast: protect against NULL stream in xdpw_pwr_stream_destroy()
- this allows repeated calls of xdpw_pwr_stream_destroy() on a
  single screencast instance
2021-05-24 10:03:40 +02:00
Tobias Jakobi
dbe71a66c7 screencast: bring function names in line with the wlroots guidelines
- no functional changes
2021-05-24 10:03:40 +02:00
columbarius
b20b9d76d7 config: fix format specifier for max_fps 2021-05-22 12:26:50 +02:00
columbarius
bbd4f9d2b1 doc: add note about the list character of env XDG_CURRENT_DESKTOP 2021-05-21 19:35:58 +02:00
columbarius
feede20314 config: parse XDG_CURRENT_DESKTOP as a list 2021-05-20 22:45:10 +02:00
columbarius
c60b2b6ca8 config: fix memory leak config_home_fallback 2021-05-06 11:52:16 +02:00
Tobias Langendorf
5d4dd833a4 screenshot: implement PickColor method
closes #129
2021-05-03 23:56:06 +02:00
columbarius
47635b94eb screencast: add prompt to dmenu style default choosers 2021-05-03 15:58:40 +02:00
Tobias Langendorf
83086e9af8 screenshot: implement interactive option 2021-05-03 15:51:05 +02:00
columbarius
620946b320 config: add missing keys to print_config 2021-05-03 15:19:20 +02:00
columbarius
22af25749e config: use inih instead if iniparser 2021-05-03 15:19:20 +02:00
Simon Ser
7f6b4090e0 Add -r flag to slurp
This prevents the user from selecting a custom region, and forces
them to select a full output.
2021-05-03 11:57:11 +02:00
Simon Ser
5d3cf9a8fa Remove -o and -f options
These can be specified in the configuration file now.
2021-04-21 12:12:40 -04:00
columbarius
f978a6eb77 Revert "screencast: workaround corrupted output_list"
This reverts commit 94f1f5d0a8.
2021-04-19 15:42:50 +02:00
columbarius
e89c58c731 wlr_screencopy: make sure xdg_output_manager is supported 2021-04-19 15:42:50 +02:00
Stefano Ragni
ebb50839a5 wlr_screencast: fix return value on cmd failure 2021-04-18 19:56:54 +02:00
columbarius
5e4edae701 wlr_screencast: remove wl_display_dispatch
wl_display_dispatch is unnecessary and can cause hangs, if no new requests are queued
2021-04-17 16:25:54 +02:00
columbarius
ca46a98b86 wlr_screencast: add xdg_output_listener after output registration if possible 2021-04-17 11:33:48 +02:00
columbarius
3ca286b0b4 wlr_screencast: call wlr_remove_output only if global is an output 2021-04-17 11:33:48 +02:00
columbarius
d83431335d wlr_screencast: create clean xdpw_wlr_output and free on remove 2021-04-17 11:33:48 +02:00
Aleksei Bavshin
9ba958c7d2 Fix gcc warnings on invalid free call
```
../src/core/config.c: In function ‘finish_config’:
../src/core/config.c:26:9: error: ‘free’ called on pointer ‘config_7(D)’ with nonzero offset 16 [-Werror=free-nonheap-object]
   26 |         free(&config->screencast_conf.exec_before);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/core/config.c:27:9: error: ‘free’ called on pointer ‘config_7(D)’ with nonzero offset 24 [-Werror=free-nonheap-object]
   27 |         free(&config->screencast_conf.exec_after);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/core/config.c:28:9: error: ‘free’ called on pointer ‘config_7(D)’ with nonzero offset 32 [-Werror=free-nonheap-object]
   28 |         free(&config->screencast_conf.chooser_cmd);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```
2021-04-10 10:50:24 +02:00
columbarius
94f1f5d0a8 screencast: workaround corrupted output_list 2021-04-02 15:07:38 +02:00
columbarius
9d78b21695 screencast: add outputchooser with config option
Supports "dmenu" chooser type, which is called with a dmenu type list
piped to stdin, "simple" type, which recieves nothing on stdin and
default, which tries the hardcoded choosers.
Choosers are required to return the name of the choosen output as given
by the xdg-output protocol.

Thanks to piater for closing overlooked pipes.
Thanks to ericonr for suggestions regarding fork and pipes.
2021-04-02 15:07:38 +02:00
David96
4c2d8fc808 Add exec_before and exec_after
Adds an option to execute some program before and after screencast (e.g.
for disabling notifications during a cast)
2021-03-16 23:44:08 +01:00
Stefano Ragni
6c8f6ca78e pipewire: Fix building EnumFormat spa object
Make sure that in SPA_POD_CHOICE_ENUM_Id(n_vals, ...) we always pass
exactly n_vals arguments. For this we build the object with separate
spa_pod_builder_add calls, since n_vals is known at runtime.
Fix #102
2021-03-16 15:43:47 -04:00
Simon Ser
a18c298ad4 Don't use ~/.config when XDG_CONFIG_HOME is set
According to the spec, ~/.config is a fallback used when
XDG_CONFIG_HOME is unset. When the user has explicitly set
XDG_CONFIG_HOME, we shouldn't try to use the fallback.
2021-03-15 18:08:57 +01:00
Simon Ser
491cbb1cc6 Constify config_path arguments
These are not modified.
2021-03-15 18:08:57 +01:00
Simon Ser
b92ad3eb6b Drop /etc/xdg-desktop-portal-wlr/ from config file dirs
We were checking both /etc/xdg-desktop-portal-wlr/ and
/etc/xdg/xdg-desktop-portal-wlr/. These two directories serve the same
purpose, let's just settle on a single one.
2021-03-15 18:08:57 +01:00
Zsolt Donca
ab8ff54f4c Control how many frames are captured per second
The goal is to control the rate of capture while in screencast, as it
can represent a performance issue and can cause input lag and the
feeling of having a laggy mouse.

This commit addresses the issue reported in #66.

The code measures the time elapsed to make a single screen capture, and
calculates how much to wait for the next capture to achieve the targeted
frame rate. To delay the capturing of the next frame, the code
introduces timers into the event loop based on the event loop in
https://github.com/emersion/mako

Added a command-line argument and an entry in the config file as well
for the max FPS. The default value is 0, meaning no rate control.

Added code to measure the average FPS every 5 seconds and print it with
DEBUG level.
2021-03-08 16:59:17 +01:00
Simon Ser
d3ac33a0aa Fix segfault in config_parse_file
configfile is a `char *`. %s needs a `char *`, so we shouldn't
dereference the pointer here.

Closes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/91
2021-03-04 14:16:30 -05:00
columbarius
07154bb1e3
Add support for config file
Closes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/60
2021-03-03 10:29:56 +01:00
Simon Ser
5401e7f9f2 Add --replace flag
This allows replacing a running xdpw instance. xdg-desktop-portal
itself has this feature.

This is useful when developing, to stop the currently running
system instance.
2021-02-11 13:24:53 -05:00
Simon Ser
c6d52b4412 Remove extraneous whitespace 2021-02-11 18:55:48 +01:00
Simon Ser
9f72a6d874 Fix freeze on skipped frame
When a frame is skipped, we weren't destroying the wlr frame. Since
this function kicks off the next frame capture, the stream was getting
stuck.

Closes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/81
2021-02-11 18:55:48 +01:00
Jan Beich
a3e203584a screencast: prefix macros to avoid conflict with system definitions
In file included from ../src/screencast/wlr_screencast.c:18:
../include/pipewire_screencast.h:7:9: error: 'ALIGN' macro redefined [-Werror,-Wmacro-redefined]
 #define ALIGN 16
         ^
/usr/include/machine/param.h:79:9: note: previous definition is here
 #define ALIGN(p)                _ALIGN(p)
         ^
2021-01-09 12:21:13 +01:00
columbarius
f0e1de02f4 Fix cursor_mode checks in screencast.c 2020-11-06 13:44:58 +01:00
columbarius
24bc68f0f2 Remove SPA_PARAM_BUFFERS_dataType
Don't announce a SPA_PARAM_BUFFERS_dataType. This is reserved for consumer
2020-11-04 11:09:09 -05:00
columbarius
dafb25fdb1
Update to wlr-screencopy-unstable-v1 version 3 2020-10-19 23:40:30 +02:00
columbarius
c2883a4e43 Add pipewire buffers_dataType parameter in pipwire_screencast.c 2020-09-19 10:22:44 +02:00
Manuel Romei
25e7719d18
Revert "Remove unnecessary check from wlr_screencast.c" (#54)
* Revert "Remove unnecessary check from wlr_screencast.c"

This reverts commit cc59abb124.
Fixes emersion/xdg-desktop-portal-wlr#50

* Clarify why the check in wlr_screencast is needed
2020-09-11 10:38:04 -04:00
columbarius
61db8968f9 Fix linewidth in wlr_screencast.c 2020-08-23 20:06:47 +02:00
columbarius
cc59abb124 Remove unnecessary check from wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
5ea10ef253 Remove TODO from wlr_sreencast.c 2020-08-18 15:47:44 +02:00
columbarius
a8d12c6163 Rename wlr_frame_buffer_clear to wlr_frame_buffer_destroy in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
24a793135c Add comments to wlr_frame_buffer_clear in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
06aa0a0bda Change loglevel for existing buffer in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
15e30ed35d Remove unecessary checks in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
c6253415c0 Add functions to clean simple_buffer.{data,buffer} in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
f23e9e4921 Change refresh logic and add tests in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
9d4193e5b2 Refresh buffer on change in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
9c353d6cfb Fix log messages in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
1245e9c353 munmap simple_frame.data only if needed in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
4c20660f74 Only recreate simple_frame on change in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius
e57beee43d Destroy wlr_buffer only on quit or error in wlr_screencast.c 2020-08-18 15:47:44 +02:00
Marian Buschsieweke
1e92d603a8 core/main: Clean up option handling
- Add a missing space in the usage string
- Drop short option "p", which is unused
2020-05-26 17:02:56 +02:00
Marian Buschsieweke
4cd31295cf core/main: Use EXIT_FAILURE / EXIT_SUCCESS 2020-05-26 12:58:13 +02:00
Marian Buschsieweke
05f44e7a7d core/main: Add static qualifier to internal func 2020-05-26 12:58:13 +02:00
Marian Buschsieweke
a105e0e363
core: fix error handling in main
The error handling at the `error:` label tears down the whole state. Thus, the
state needs to be fully initialized in order for the tear down to succeed.
Currently, if e.g. `sd_bus_open_user()` fails, a `segfault` is triggered by
the tear down. This commit adds individual tear down code that only touches
stuff that until that point was successfully initialized.
2020-05-21 16:44:47 +02:00
Simon Ser
f5bfe9fe12 Replace void * with correct type in start_screencast 2020-05-05 10:00:10 -04:00
Simon Ser
a7ea407e2f Remove --pixelformat flag
This hack is not needed anymore.
2020-05-05 10:00:10 -04:00
Simon Ser
26b6bf69aa Advertise format with alpha channel stripped 2020-05-05 10:00:10 -04:00
Dan Shick
229a34a9fe Globally define _POSIX_C_SOURCE in meson.build
Fix musl issue with time.h
2020-04-23 09:53:34 +02:00
Dan Shick
f6d14d9206 Check cast instance refcount before attaching 2020-04-21 14:45:55 +02:00
danshick
55f873dac4
Screencast session support (#22)
* Initial session support WIP
Remove libdrm dependency

Remove display from context, add dbus properties

Use random names for shm and pw_stream, init the stream only for new cast instances

Separate cast initialized flag from refcount, cleanup names and comments

* Refactor and stability improvements

Properly report xdp screencast implementation version
2020-04-16 10:21:55 +02:00