View Source ExMP4.Read behaviour (MP4 Reader and Writer v0.1.0)

A behaviour defining how to read data from an mp4 input

Summary

Callbacks

Close the input stream.

Open the provided input in read mode

Seek and read from the input stream.

Read the specified amount of bytes from the input

Seek to the provided position in the input stream

Types

@type location() :: {:cur, offset :: integer()} | integer()
@type reason() :: any()
@type state() :: any()

Callbacks

@callback close(state()) :: :ok

Close the input stream.

@callback open(input :: any()) :: {:ok, state()} | {:error, reason()}

Open the provided input in read mode

The returned state will be the first argument on the other callbacks

Link to this callback

pread(state, location, chars)

View Source (optional)
@callback pread(state(), location(), chars :: non_neg_integer()) :: iodata() | :eof

Seek and read from the input stream.

Some stream may have optimised way of seeking and reading at the same time as the case for :file

@callback read(state(), chars :: non_neg_integer()) :: iodata() | :eof

Read the specified amount of bytes from the input

@callback seek(state(), location()) :: :ok

Seek to the provided position in the input stream