Skip to main content

RealtimeComposer

Struct RealtimeComposer 

Source
pub struct RealtimeComposer { /* private fields */ }
Expand description

Composites externally-decoded frames from several layers into one frame, reusing a single built filter graph across frames.

Build once with new; then per output frame, push_layer one frame for every layer and pull the composited result. The output frame is rgba. The graph (and any lut3d file its effects load) is built once, so it is suitable for real-time playback.

Implementations§

Source§

impl RealtimeComposer

Source

pub fn new(layers: &[RealtimeLayer]) -> Result<Self, FilterError>

Builds a compositor for the given layers (at least one required).

§Errors

Returns FilterError::CompositionFailed when layers is empty or the underlying FFmpeg graph cannot be built.

Source

pub fn with_canvas( layers: &[RealtimeLayer], canvas: Option<(u32, u32)>, ) -> Result<Self, FilterError>

Like new, but composites onto a project canvas of canvas = (width, height) pixels: every layer, the base included, is placed in canvas pixels by its x / y / scale / rotation (ADR-0016), and the output is exactly canvas-sized. A base whose frames are not canvas-sized sits at its native size from the top-left; framing against the canvas is a FitMode effect, never implicit. None uses the base layer’s own size as the canvas (identical to new).

§Errors

Returns FilterError::CompositionFailed when layers is empty or the underlying FFmpeg graph cannot be built.

Source

pub fn layer_count(&self) -> usize

Number of layers (== number of input slots).

Source

pub fn push_layer( &mut self, idx: usize, frame: &VideoFrame, ) -> Result<(), FilterError>

Pushes one frame into layer idx’s input slot.

Push exactly one frame per layer before each pull. The frame must match the layer’s declared width/height/pixel format.

§Errors

Returns FilterError::InvalidInput if idx is not a layer slot, and the graph’s error if the frame cannot be pushed. After a push error the composer’s current tick is incomplete and it must be rebuilt.

Source

pub fn pull(&mut self) -> Result<Option<VideoFrame>, FilterError>

Pulls the next composited frame (rgba), or None if not yet available.

§Errors

Returns FilterError on an unexpected FFmpeg error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.