ISOMedia.MdatSource (ISOMedia v0.1.0)

Copy Markdown View Source

Resolves an absolute file byte range to a payload segment, given the top-level mdat boxes of a parsed tree. Returns a %FileSlice{} when the containing mdat is lazy, or a binary slice when it is in memory. Shared by Extract and Trim.

Summary

Functions

Capture each top-level mdat's absolute payload range from a single Layout walk: [%{box: mdat, payload_start: abs, payload_size: len}]. The walk uses the same Layout.box_size/1 the serializer uses, so the offsets are byte-identical to the written file — the basis for drift-free recursive resolution.

Resolve the absolute offset..offset+length range to a payload segment, given the records from collect/1. Returns a binary, a %FileSlice{}, or (for a segment-list mdat) a nested segment list. Uses relative = offset - payload_start, so a physical FileSlice acts as a local byte provider (fs.offset + relative) independent of the absolute target.

Functions

collect(boxes)

Capture each top-level mdat's absolute payload range from a single Layout walk: [%{box: mdat, payload_start: abs, payload_size: len}]. The walk uses the same Layout.box_size/1 the serializer uses, so the offsets are byte-identical to the written file — the basis for drift-free recursive resolution.

segment(records, offset, length)

Resolve the absolute offset..offset+length range to a payload segment, given the records from collect/1. Returns a binary, a %FileSlice{}, or (for a segment-list mdat) a nested segment list. Uses relative = offset - payload_start, so a physical FileSlice acts as a local byte provider (fs.offset + relative) independent of the absolute target.