Skip to main content

AudioEncoder

Trait AudioEncoder 

Source
pub trait AudioEncoder: Send {
    // Required methods
    fn encode(&mut self, pcm: &[i16], output: &mut Vec<u8>) -> usize;
    fn payload_type(&self) -> u8;
    fn codec_type(&self) -> CodecType;
}
Expand description

Trait for audio encoders.

Implementations encode PCM audio (signed 16-bit samples) to a compressed format.

Required Methods§

Source

fn encode(&mut self, pcm: &[i16], output: &mut Vec<u8>) -> usize

Encode PCM samples to the codec format.

§Arguments
  • pcm - Input PCM samples (signed 16-bit, mono)
  • output - Output buffer for encoded data (appended to)
§Returns

Number of samples consumed from input.

Source

fn payload_type(&self) -> u8

Get the RTP payload type for this encoder.

Source

fn codec_type(&self) -> CodecType

Get the codec type.

Implementors§