Skip to main content

CaptureBackend

Trait CaptureBackend 

Source
pub trait CaptureBackend: Send + Sync {
    // Required methods
    fn start_stream<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<PipeWireStream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop_stream<'life0, 'async_trait>(
        &'life0 self,
        stream: PipeWireStream,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pipewire_socket(&self) -> PathBuf;

    // Provided methods
    fn start_recording_stream<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<PipeWireStream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn stop_recording_stream<'life0, 'async_trait>(
        &'life0 self,
        stream: PipeWireStream,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn grab_screenshot<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stream: &'life1 PipeWireStream,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn start_recording<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        stream: &'life1 PipeWireStream,
        output_path: &'life2 Path,
        bitrate: u32,
        fps: u32,
    ) -> Pin<Box<dyn Future<Output = Result<VideoRecorder>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn stop_recording<'life0, 'async_trait>(
        &'life0 self,
        recorder: VideoRecorder,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Screen capture. Backends either return a PipeWire node id (the common path on mutter/KWin) that the default take_screenshot pipes through GStreamer, or override take_screenshot directly if they can produce a PNG without PipeWire (e.g. a future wlr-screencopy backend).

Required Methods§

Source

fn start_stream<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PipeWireStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start a PipeWire capture stream. The returned PipeWireStream stays alive until explicitly stopped.

Source

fn stop_stream<'life0, 'async_trait>( &'life0 self, stream: PipeWireStream, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop a previously started stream and release backend-side resources.

Source

fn pipewire_socket(&self) -> PathBuf

Path to the PipeWire socket the shared GStreamer helper should talk to (usually <runtime_dir>/pipewire-0).

Provided Methods§

Source

fn start_recording_stream<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PipeWireStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start a dedicated capture stream for a video recording, distinct from the interactive/keepalive stream returned by Self::start_stream.

The recorder must not share a node with the screenshot path. A recording pipeline is a continuous consumer; on compositors whose screencast node only emits frames on screen damage (mutter negotiates framerate=0/1), a screenshot consumer that attaches after the recorder is already draining the shared node never receives the initial frame and times out — a static app produces no further damage. Giving the recorder its own node keeps the screenshot consumer the node’s first/triggering consumer, which is what makes the recording-off path reliable.

Backends that don’t have this hazard may use the default, which simply opens another stream via Self::start_stream. The mutter backend overrides this to open a standalone (non-RemoteDesktop-linked) stream so it doesn’t perturb pointer routing or the active-stream path.

Source

fn stop_recording_stream<'life0, 'async_trait>( &'life0 self, stream: PipeWireStream, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop a stream previously opened by Self::start_recording_stream. The default delegates to Self::stop_stream; the mutter backend overrides it to avoid clearing the interactive stream’s active-stream path.

Source

fn grab_screenshot<'life0, 'life1, 'async_trait>( &'life0 self, stream: &'life1 PipeWireStream, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Capture a PNG from an already-running stream.

Source

fn start_recording<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, stream: &'life1 PipeWireStream, output_path: &'life2 Path, bitrate: u32, fps: u32, ) -> Pin<Box<dyn Future<Output = Result<VideoRecorder>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Start a continuous WebM recording of stream written to output_path at the given bitrate (bits/sec) and fps. Returns a handle whose stop() must be awaited to finalize the file cleanly.

Source

fn stop_recording<'life0, 'async_trait>( &'life0 self, recorder: VideoRecorder, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop a previously-started recording, flushing the WebM seekhead/cues before returning.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§