TrackSampleTable


@UnstableApi
public final class TrackSampleTable


Sample table for a track in an MP4 file.

Summary

Public fields

final long

The duration of the track sample table in microseconds.

final int[]

Sample flags.

final boolean

Whether all samples in the track are sync samples.

final int

Maximum sample size in sizes.

final long[]

Sample offsets in bytes.

final int

Number of samples.

final int[]

Sample sizes in bytes.

final int[]

The indices of sync samples, sorted in ascending order.

final long[]

Sample timestamps in microseconds.

final Track

The track corresponding to this sample table.

Public constructors

TrackSampleTable(
    Track track,
    long[] offsets,
    int[] sizes,
    int maximumSize,
    long[] timestampsUs,
    int[] flags,
    int[] syncSampleIndices,
    boolean hasOnlySyncSamples,
    long durationUs,
    int sampleCount
)

Public methods

int

Returns the sample index of the closest synchronization sample at or before the given timestamp, if one is available.

int

Returns the sample index of the closest synchronization sample at or after the given timestamp, if one is available.

boolean

Returns whether the per-sample mapping arrays (such as offsets, sizes, timestampsUs, and flags) are populated.

Public fields

durationUs

public final long durationUs

The duration of the track sample table in microseconds.

flags

public final int[] flags

Sample flags. Populated only if hasSampleTableData is true.

hasOnlySyncSamples

public final boolean hasOnlySyncSamples

Whether all samples in the track are sync samples.

maximumSize

public final int maximumSize

Maximum sample size in sizes.

offsets

public final long[] offsets

Sample offsets in bytes. Populated only if hasSampleTableData is true.

sampleCount

public final int sampleCount

Number of samples.

sizes

public final int[] sizes

Sample sizes in bytes. Populated only if hasSampleTableData is true.

syncSampleIndices

public final int[] syncSampleIndices

The indices of sync samples, sorted in ascending order. This array is only populated if hasOnlySyncSamples is false.

timestampsUs

public final long[] timestampsUs

Sample timestamps in microseconds. Populated only if hasSampleTableData is true.

track

public final Track track

The track corresponding to this sample table.

Public constructors

TrackSampleTable

public TrackSampleTable(
    Track track,
    long[] offsets,
    int[] sizes,
    int maximumSize,
    long[] timestampsUs,
    int[] flags,
    int[] syncSampleIndices,
    boolean hasOnlySyncSamples,
    long durationUs,
    int sampleCount
)

Public methods

getIndexOfEarlierOrEqualSynchronizationSample

public int getIndexOfEarlierOrEqualSynchronizationSample(long timeUs)

Returns the sample index of the closest synchronization sample at or before the given timestamp, if one is available.

Parameters
long timeUs

Timestamp adjacent to which to find a synchronization sample.

Returns
int

Index of the synchronization sample, or INDEX_UNSET if none.

getIndexOfLaterOrEqualSynchronizationSample

public int getIndexOfLaterOrEqualSynchronizationSample(long timeUs)

Returns the sample index of the closest synchronization sample at or after the given timestamp, if one is available.

Parameters
long timeUs

Timestamp adjacent to which to find a synchronization sample.

Returns
int

index Index of the synchronization sample, or INDEX_UNSET if none.

hasSampleTableData

public boolean hasSampleTableData()

Returns whether the per-sample mapping arrays (such as offsets, sizes, timestampsUs, and flags) are populated.

When FLAG_OMIT_TRACK_SAMPLE_TABLE is set, this returns false while sampleCount may still be greater than 0.