fn read_dfla()

in mp4parse/src/lib.rs [5271:5294]


fn read_dfla<T: Read>(src: &mut BMFFBox<T>) -> Result<FLACSpecificBox> {
    let (version, flags) = read_fullbox_extra(src)?;
    if version != 0 {
        return Err(Error::Unsupported("unknown dfLa (FLAC) version"));
    }
    if flags != 0 {
        return Status::DflaFlagsNonzero.into();
    }
    let mut blocks = TryVec::new();
    while src.bytes_left() > 0 {
        let block = read_flac_metadata(src)?;
        blocks.push(block)?;
    }
    // The box must have at least one meta block, and the first block
    // must be the METADATA_BLOCK_STREAMINFO
    if blocks.is_empty() {
        return Status::DflaMissingMetadata.into();
    } else if blocks[0].block_type != 0 {
        return Status::DflaStreamInfoNotFirst.into();
    } else if blocks[0].data.len() != 34 {
        return Status::DflaStreamInfoBadSize.into();
    }
    Ok(FLACSpecificBox { version, blocks })
}