Skip to main content

Module pwcapture

Module pwcapture 

Source
Expand description

PipeWire consumer turning a portal monitor stream into host frames. PipeWire consumer for a portal monitor stream: one Video/Input stream per host output on the connection the portal opened, delivering the compositor’s frames to the host-capture consumer as [HostFrame]s.

The compositor allocates and fills the buffers, so a frame is never copied here: a dmabuf buffer becomes a Dmabuf the encoder imports in place (built once per buffer from duplicated fds, so the encoder’s import cache keeps hitting), a memfd buffer is mapped once and read in place by the CPU path. A buffer stays dequeued from the moment its frame is published until the consumer releases it, which is the same slot discipline the Wayland capture threads follow, so the retained frame an IDR re-encodes is still the compositor’s memory. Frames are handed on from the stream’s own thread the instant process runs, and the format offered to the compositor asks it to send at most the capture’s rate, so nothing is captured only to be dropped and nothing waits for a timer.

Format negotiation follows the modifier convention consumers and compositors agree on: each importable (fourcc, modifiers) pair the encoder’s EGL display reported is one format entry with a mandatory, non-fixating modifier choice, followed by plain entries the compositor answers with memfd buffers; the compositor picks, and the fixated format decides whether dmabuf or memfd buffers are requested. Cursor metadata is requested so a metadata-mode session delivers the host’s real cursor sprite to the cursor callback, and damage metadata so unchanged stripes are recognized.

Structs§

Negotiated
The fixated format of a stream.
PwCore
One PipeWire connection, shared by every stream of a portal session.
PwStream
One output’s stream: the consumer end of a portal monitor stream.
StreamConfig
What a stream asks the compositor for.