View Source ExMP4.Track.SampleTable (MP4 Reader and Writer v0.4.0)
A module that defines a structure and functions allowing to store samples, assemble them into chunks and flush when needed. Its public functions take care of recording information required to build a sample table.
Summary
Functions
Get the current chunk duration.
Flush the current chunk.
Store a new sample.
Get the total size of the samples in the sample table.
Types
@type t() :: %ExMP4.Track.SampleTable{ chunk: [binary()], chunk_first_dts: non_neg_integer() | nil, chunk_offsets: [non_neg_integer()], chunk_sample_index: non_neg_integer(), composition_offsets: [ %{sample_composition_offset: Ratio.t(), sample_count: pos_integer()} ], decoding_deltas: [%{sample_delta: Ratio.t(), sample_count: pos_integer()}], elapsed_duration: non_neg_integer(), last_dts: non_neg_integer() | nil, sample_count: non_neg_integer(), sample_index: non_neg_integer(), sample_size: non_neg_integer(), sample_sizes: [pos_integer()], samples_per_chunk: [ %{first_chunk: pos_integer(), sample_count: pos_integer()} ], sync_samples: [pos_integer()] }
Functions
@spec chunk_duration(t()) :: ExMP4.duration()
Get the current chunk duration.
Samples are added and buffered in the sample table into chunks, once a chunk duration
is reached, it can be flushed using flush_chunk/2
.
@spec flush_chunk(t(), non_neg_integer()) :: {binary(), t()}
Flush the current chunk.
Flushing update the internal structure of the sample table and assemble the samples payload into a binary that can be stored.
@spec store_sample(t(), ExMP4.Sample.t()) :: t()
Store a new sample.
@spec total_size(t()) :: non_neg_integer()
Get the total size of the samples in the sample table.