Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@nicolo-mn
Copy link
Contributor

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 given WlOutput. The original idea was to pick a random WlOutput from the connection, performing a 1-pixel screenshot to obtain the valid formats using wlr-screencopy protocol, and saving them in a LazyCell. I preferred to capture the entire screen from a given WlOutput passed as parameter instead, to return a vector of FrameFormat which 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 as capture_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 pub visibility modifier was removed from capture_output_frame_get_state_shm, as it was added in an attempt to tackle the issues that get_available_frame_formats solves.

- "capture_output_frame_shm_fd_with_format": like "capture_output_frame_shm_fd" but takes a wl_shm::Format parameter and only writes into the provided file descriptor if that format is supported by the compositor.
- "get_available_frame_formats": performs a trial screenshot on the given WlOutput and returns the list of advertised FrameFormats.
@Decodetalkers
Copy link
Collaborator

@Shinyzenith I think this change is good

@Decodetalkers
Copy link
Collaborator

I think it will be ok, merged

@Decodetalkers Decodetalkers merged commit ff47e49 into waycrate:main Sep 3, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants