Skip to main content

create_decoder

Function create_decoder 

Source
pub fn create_decoder(
    codec: &str,
    extra_data: Option<&[u8]>,
    sample_rate: u32,
    channels: u8,
) -> Result<Box<dyn AudioDecoder>, AudioError>
Expand description

Construct an audio decoder for the given codec name.

codec is matched case-insensitively. Supported tokens:

  • mp3 / mpeg
  • vorbis (raw audio packet form — caller is responsible for feeding the three Xiph setup packets first via the extra_data parameter on first construction, then the audio packets via decode)

extra_data, sample_rate, and channels come from the demux side’s container metadata. For codecs that carry full setup in the stream (MP3) extra_data may be None.