Skip to main content

AudioEncodeBackend

Trait AudioEncodeBackend 

Source
pub trait AudioEncodeBackend: Send {
    // Required methods
    fn name(&self) -> &str;
    fn sample_rate(&self) -> u32;
    fn frame_size(&self) -> usize;
    fn bitrate(&self) -> u32;
    fn submit(
        &mut self,
        pts: i64,
        planes: &[Vec<f32>],
    ) -> 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 priming(&self) -> u32;
}
Expand description

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

Required Methods§

Source

fn name(&self) -> &str

The encoder’s name, for reports.

Source

fn sample_rate(&self) -> u32

The rate it encodes at.

Source

fn frame_size(&self) -> usize

Samples per channel in each frame it takes.

Source

fn bitrate(&self) -> u32

The bits per second it encodes at: the configured rate, or the nearest the encoder takes.

Source

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

Queues one frame of planar samples starting at sample pts of the encoded stream; only the last frame may be short.

§Errors

A failed encoder.

Source

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

Takes an encoded packet, timestamps in samples at Self::sample_rate counted from the first decoded sample, priming included. 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 codec’s setup data (AudioSpecificConfig, OpusHead), once known.

Source

fn priming(&self) -> u32

Samples of priming at the start of the decoded stream, which the container’s edit list skips.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§