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
impl RealtimeComposer
Sourcepub fn new(layers: &[RealtimeLayer]) -> Result<Self, FilterError>
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.
Sourcepub fn layer_count(&self) -> usize
pub fn layer_count(&self) -> usize
Number of layers (== number of input slots).
Sourcepub fn push_layer(
&mut self,
idx: usize,
frame: &VideoFrame,
) -> Result<(), FilterError>
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 if idx is out of range or the frame cannot be
pushed.
Sourcepub fn pull(&mut self) -> Result<Option<VideoFrame>, FilterError>
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.