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§
Sourcefn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
The rate it encodes at.
Sourcefn frame_size(&self) -> usize
fn frame_size(&self) -> usize
Samples per channel in each frame it takes.
Sourcefn bitrate(&self) -> u32
fn bitrate(&self) -> u32
The bits per second it encodes at: the configured rate, or the nearest the encoder takes.
Sourcefn submit(
&mut self,
pts: i64,
planes: &[Vec<f32>],
) -> Result<Submit, EncodeError>
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.
Sourcefn receive(&mut self, wait: bool) -> Result<EncodePoll, EncodeError>
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.
Sourcefn finish_input(&mut self) -> Result<(), EncodeError>
fn finish_input(&mut self) -> Result<(), EncodeError>
Sourcefn codec_private(&self) -> Option<Bytes>
fn codec_private(&self) -> Option<Bytes>
The codec’s setup data (AudioSpecificConfig, OpusHead), once known.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".