ISOMedia.Box (ISOMedia v0.1.0)

Copy Markdown View Source

A single generic ISOBMFF box.

  • container = data: nil with children
  • leaf = data: binary with no children
  • size_mode records how the original size field was encoded so serialization can reproduce exact bytes.

Summary

Functions

True when the box holds child boxes rather than a raw payload.

Return the first box matching the type-path, or nil.

Return every box matching the type-path.

Insert new_box into the children of the container found at path. at is :start, :end, or a zero-based integer index.

True when the box holds a raw payload rather than children.

Return a leaf box's payload bytes, reading the file if it's a FileSlice. Returns nil for a container.

Remove every box matching the type-path; returns a new tree.

Replace a box's payload, making it a leaf (drops any children).

Apply fun to every box matching the type-path; returns a new tree.

Types

t()

@type t() :: %ISOMedia.Box{
  children: [t()],
  data:
    binary()
    | ISOMedia.FileSlice.t()
    | [binary() | ISOMedia.FileSlice.t()]
    | nil,
  size_mode: :compact | :large | :eof,
  source_offset: non_neg_integer() | nil,
  source_size: non_neg_integer() | nil,
  type: String.t(),
  uuid: <<_::128>> | nil
}

Functions

container?(box)

True when the box holds child boxes rather than a raw payload.

find(boxes, path)

Return the first box matching the type-path, or nil.

find_all(boxes, list)

Return every box matching the type-path.

insert(boxes, path, new_box, at \\ :end)

Insert new_box into the children of the container found at path. at is :start, :end, or a zero-based integer index.

leaf?(box)

True when the box holds a raw payload rather than children.

read_data(box)

Return a leaf box's payload bytes, reading the file if it's a FileSlice. Returns nil for a container.

remove(boxes, list)

Remove every box matching the type-path; returns a new tree.

replace_data(box, binary)

Replace a box's payload, making it a leaf (drops any children).

update(boxes, list, fun)

Apply fun to every box matching the type-path; returns a new tree.