pub trait GraphicsCaptureApiHandler: Sized {
    type Flags;
    type Error: Send + Sync;

    // Required methods
    fn new(flags: Self::Flags) -> Result<Self, Self::Error>;
    fn on_frame_arrived(
        &mut self,
        frame: &mut Frame<'_>,
        capture_control: InternalCaptureControl
    ) -> Result<(), Self::Error>;

    // Provided methods
    fn start<T: TryInto<GraphicsCaptureItem>>(
        settings: Settings<Self::Flags, T>
    ) -> Result<(), GraphicsCaptureApiError<Self::Error>>
       where Self: Send + 'static,
             <Self as GraphicsCaptureApiHandler>::Flags: Send { ... }
    fn start_free_threaded<T: TryInto<GraphicsCaptureItem> + Send + 'static>(
        settings: Settings<Self::Flags, T>
    ) -> Result<CaptureControl<Self, Self::Error>, GraphicsCaptureApiError<Self::Error>>
       where Self: Send + 'static,
             <Self as GraphicsCaptureApiHandler>::Flags: Send { ... }
    fn on_closed(&mut self) -> Result<(), Self::Error> { ... }
}
Expand description

A trait representing a graphics capture handler.

Required Associated Types§

source

type Flags

The type of flags used to get the values from the settings.

source

type Error: Send + Sync

The type of error that can occur during capture, the error will be returned from CaptureControl and start functions.

Required Methods§

source

fn new(flags: Self::Flags) -> Result<Self, Self::Error>

Function that will be called to create the struct. The flags can be passed from settings.

§Arguments
  • flags - The flags used to create the struct.
§Returns

Returns Ok(Self) if the struct creation was successful, otherwise returns an error of type Self::Error.

source

fn on_frame_arrived( &mut self, frame: &mut Frame<'_>, capture_control: InternalCaptureControl ) -> Result<(), Self::Error>

Called every time a new frame is available.

§Arguments
  • frame - A mutable reference to the captured frame.
  • capture_control - The internal capture control.
§Returns

Returns Ok(()) if the frame processing was successful, otherwise returns an error of type Self::Error.

Provided Methods§

source

fn start<T: TryInto<GraphicsCaptureItem>>( settings: Settings<Self::Flags, T> ) -> Result<(), GraphicsCaptureApiError<Self::Error>>
where Self: Send + 'static, <Self as GraphicsCaptureApiHandler>::Flags: Send,

Starts the capture and takes control of the current thread.

§Arguments
  • settings - The capture settings.
§Returns

Returns Ok(()) if the capture was successful, otherwise returns an error of type GraphicsCaptureApiError.

source

fn start_free_threaded<T: TryInto<GraphicsCaptureItem> + Send + 'static>( settings: Settings<Self::Flags, T> ) -> Result<CaptureControl<Self, Self::Error>, GraphicsCaptureApiError<Self::Error>>
where Self: Send + 'static, <Self as GraphicsCaptureApiHandler>::Flags: Send,

Starts the capture without taking control of the current thread.

§Arguments
  • settings - The capture settings.
§Returns

Returns Ok(CaptureControl) if the capture was successful, otherwise returns an error of type GraphicsCaptureApiError.

source

fn on_closed(&mut self) -> Result<(), Self::Error>

Optional handler called when the capture item (usually a window) closes.

§Returns

Returns Ok(()) if the handler execution was successful, otherwise returns an error of type Self::Error.

Object Safety§

This trait is not object safe.

Implementors§