Commit graph

306 commits

Author SHA1 Message Date
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
Simon Ser
7c0f352560 build: bump version to 0.5.0 2021-11-05 16:25:28 +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
Jan Beich
71730982da ci: drop FreeBSD workaround after 22af25749e
inih exposes required CFLAGS/LDFLAGS via pkg-config, so manually
adding /usr/local to search path is no longer necessary.
2021-06-01 18:24:28 +02:00
Simon Ser
65cb6d5630 build: bump version to 0.4.0
Forgot to do it. Again.
2021-06-01 17:34:08 +02:00
Simon Ser
28a82d0568 readme: update IRC channel 2021-05-26 08:35:38 +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
Simon Ser
efcbcb60aa contrib/systemd: add ConditionEnvironment
This makes it clear xdpw requires WAYLAND_DISPLAY to be set before
being started.

Inspired by the mako service [1].

[1]: https://github.com/emersion/mako/blob/master/contrib/systemd/mako.service
2021-05-03 18:17:29 -04:00
Simon Ser
884a2e808e readme: add dbus-update-activation-environment command
Add a dbus-update-activation-environment invocation that users can
add to their config file. This should work for most users, assuming
Sway, systemd, and D-Bus activation.

The --systemd flag also imports the variables to the systemd user
session.
2021-05-03 18:07:10 -04:00
Simon Ser
835a928bd4 readme: update "Manual startup" section
Add -r flag to xdpw to make sure any currently running process gets
replaced.

Remove the /usr/lib/xdg-desktop-portal invocation since xdpw can now be
replaced.

Adapt the wording to the latest xdpw changes.
2021-05-03 18:07:10 -04: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