pub trait VideoEncoderSession {
// Required methods
fn codec(&self) -> &CodecId;
fn config(&self) -> &VideoEncoderConfig;
fn encode_frame(&mut self, frame: Frame) -> Result<VideoEncodeOutput>;
// Provided method
fn flush(&mut self) -> Result<VideoEncodeOutput> { ... }
}Expand description
One continuous video stream with persistent codec state.
Current no-reordering modes must return complete frame output per call, before finalization. Internal storage must be bounded by frame geometry and codec reference/scratch requirements, independent of stream duration. Future reordering/lookahead modes must declare explicit delay and storage bounds. Consume or transfer each returned step before submitting another frame; recording output history is an explicit caller-owned allocation.
Native AV2 and VVC implement incremental sessions through their shared
per-codec state. See docs/api-v0.md in the repository for retention,
validation coverage and the separate unfinished WASM wrapper.
Required Methods§
Sourcefn config(&self) -> &VideoEncoderConfig
fn config(&self) -> &VideoEncoderConfig
Configuration used to create this session.
Sourcefn encode_frame(&mut self, frame: Frame) -> Result<VideoEncodeOutput>
fn encode_frame(&mut self, frame: Frame) -> Result<VideoEncodeOutput>
Encode one frame and transfer this step’s output to the caller.
Invalid input must not advance state. An error after codec state advances terminally fails the session; later encode/flush calls must report failure. This synchronous operation has no internal input queue or async readiness protocol. Consumer backpressure is applied by waiting before the next call.
Provided Methods§
Sourcefn flush(&mut self) -> Result<VideoEncodeOutput>
fn flush(&mut self) -> Result<VideoEncodeOutput>
Terminally finish the stream and release retained reference frames.
Return any remaining output. Successful repeated flushes return empty
output; encoding afterward returns MediaError::EncodeAfterFlush. A
failed session must continue reporting failure. This does not flush a
caller’s writer or acknowledge transport delivery.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".