Add utility functions to support screencasting in xdg-desktop-portal-luminous #207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two utility functions, designed to be used by
xdg-desktop-portal-luminous:get_available_frame_formats: returns a vector of valid formats for a givenWlOutput. The original idea was to pick a randomWlOutputfrom the connection, performing a 1-pixel screenshot to obtain the valid formats usingwlr-screencopyprotocol, and saving them in aLazyCell. I preferred to capture the entire screen from a givenWlOutputpassed as parameter instead, to return a vector ofFrameFormatwhich contain additional information such as the size and the stride of the buffer. This makes the function more general purpose, allowing it to be used in multiple contexts. For example, right now only 4-bytes pixel formats are supported; if other pixel formats need to be supported in the future, this information could be useful to properly set PipeWire streams' parameters.capture_output_frame_shm_fd_with_format: same ascapture_output_frame_shm_fd, but enforces a format to perform the screen capture. Needed since the PipeWire server communicates a preferred video format among the available ones, that must be enforced when capturing video frames.Additionally, some refactoring was done to avoid code repetitions and
pubvisibility modifier was removed fromcapture_output_frame_get_state_shm, as it was added in an attempt to tackle the issues thatget_available_frame_formatssolves.