pub trait AudioEncoder: Send {
// Required methods
fn encode(
&mut self,
frame: &AudioFrame,
) -> Result<Vec<EncodedAudioPacket>, AudioError>;
fn flush(&mut self) -> Result<Vec<EncodedAudioPacket>, AudioError>;
fn pre_skip(&self) -> u16;
fn extra_data(&self) -> Vec<u8> ⓘ;
}Required Methods§
Sourcefn encode(
&mut self,
frame: &AudioFrame,
) -> Result<Vec<EncodedAudioPacket>, AudioError>
fn encode( &mut self, frame: &AudioFrame, ) -> Result<Vec<EncodedAudioPacket>, AudioError>
Encode one input frame. The encoder buffers up to one output frame’s worth of samples internally — Opus’s smallest frame is 2.5 ms, default 20 ms — so this returns 0..N packets.
Sourcefn flush(&mut self) -> Result<Vec<EncodedAudioPacket>, AudioError>
fn flush(&mut self) -> Result<Vec<EncodedAudioPacket>, AudioError>
Drain any buffered samples. May produce a final partial packet.
Sourcefn pre_skip(&self) -> u16
fn pre_skip(&self) -> u16
Lookahead samples at 48 kHz (Opus convention). For Opus,
queried via OPUS_GET_LOOKAHEAD and scaled to 48 kHz when the
encoder is internally running at a non-48k rate.
Sourcefn extra_data(&self) -> Vec<u8> ⓘ
fn extra_data(&self) -> Vec<u8> ⓘ
The codec-specific extra_data the muxer puts in the sample
entry’s config box. For Opus this is the dOps body per RFC
7845 §4.5 (11 bytes for channel-mapping family 0).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".