Skip to main content

VideoEncodeBackend

Trait VideoEncodeBackend 

Source
pub trait VideoEncodeBackend: Send {
    // Required methods
    fn name(&self) -> &str;
    fn hardware(&self) -> bool;
    fn timescale(&self) -> u32;
    fn submit(
        &mut self,
        pts: i64,
        planes: &[PlaneBuffer],
        keyframe: bool,
    ) -> Result<Submit, EncodeError>;
    fn receive(&mut self, wait: bool) -> Result<EncodePoll, EncodeError>;
    fn finish_input(&mut self) -> Result<(), EncodeError>;
    fn codec_private(&self) -> Option<Bytes>;
    fn applied_rate_control(&self) -> AppliedRateControl;

    // Provided methods
    fn settle(&mut self) -> Result<(), EncodeError> { ... }
    fn lender(&mut self) -> Option<&mut dyn PoolLender> { ... }
}
Expand description

One video encoder session, used from one thread at a time.

A session the platform takes away fails the encoder unless the backend can resume it in place with the same configuration record, as VideoToolbox can and Android MediaCodec cannot.

Required Methods§

Source

fn name(&self) -> &str

The encoder’s name, for reports.

Source

fn hardware(&self) -> bool

Whether it runs on hardware.

Source

fn timescale(&self) -> u32

Units per second of the timestamps it takes and gives.

Source

fn submit( &mut self, pts: i64, planes: &[PlaneBuffer], keyframe: bool, ) -> Result<Submit, EncodeError>

Queues a frame at pts whose planes are in the configured layout.

§Errors

A failed encoder.

Source

fn receive(&mut self, wait: bool) -> Result<EncodePoll, EncodeError>

Takes an encoded packet, in decode order. With wait, blocks briefly for one. Once it answers EncodePoll::Drained it keeps answering it.

§Errors

A failed encoder.

Source

fn finish_input(&mut self) -> Result<(), EncodeError>

No more frames follow.

§Errors

A failed encoder.

Source

fn codec_private(&self) -> Option<Bytes>

The decoder configuration record (avcC, hvcC, av1C), once the first packet is out.

Source

fn applied_rate_control(&self) -> AppliedRateControl

Which form of the rate control the encoder runs.

Provided Methods§

Source

fn settle(&mut self) -> Result<(), EncodeError>

Finishes every frame submitted so far without ending the input, so none is inside the session while the app is away. The default does nothing.

§Errors

A failed encoder.

Source

fn lender(&mut self) -> Option<&mut dyn PoolLender>

The encoder’s pool, when it lends buffers the renderer draws frames into instead of taking planes. The default lends none.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§