Skip to main content

open

Function open 

Source
pub fn open(path: &Path) -> Result<Box<dyn ContainerDecoder>>
Expand description

Sniff the container by magic bytes and open the matching decoder.

Reads the first 12 bytes of path, matches the magic signature, and returns a boxed ContainerDecoder for the sniffed container. The caller should then call ContainerDecoder::open on the returned box to obtain a StreamInfo before iterating ContainerDecoder::next_frame.

§Errors

§Example

use audio_codec_bsd::{open, ContainerDecoder};
use std::path::Path;

let mut dec = open(Path::new("song.flac"))?;
let info = dec.open(Path::new("song.flac"))?;
while let Some(_frame) = dec.next_frame()? {
    // push into a lock-free ring for the RT thread.
}