@UnstableApi
public final class Track


Encapsulates information describing an MP4 track.

Summary

Nested types

public final class Track.Builder

Builder for Track.

The transformation to apply to samples in the track, if any.

Constants

static final long

An unset or unknown timescale.

static final int

A transformation for caption samples in cdat atoms.

static final int

A no-op sample transformation.

Public fields

final int

The identifier of the associated chapter track, or INDEX_UNSET if there is none.

final long

The duration of the track in microseconds, or TIME_UNSET if unknown.

final @Nullable ImmutableLongArray

Durations of edit list segments in the movie timescale, or null if there is no edit list.

final @Nullable ImmutableLongArray

Media times for edit list segments in the track timescale, or null if there is no edit list.

final Format

The format.

final int

The track identifier.

final long

The duration of the media in microseconds, or TIME_UNSET if unknown.

final long

The movie timescale, or TIMESCALE_UNSET if unknown.

final int

The length in bytes of the NALUnitLength field in each sample.

final int

One of TRANSFORMATION_*.

final boolean

Whether the track should be exposed to the player.

final long

The track timescale, defined as the number of time units that pass in one second, or TIMESCALE_UNSET if unknown.

final int

One of TRACK_TYPE_AUDIO, TRACK_TYPE_VIDEO and TRACK_TYPE_TEXT.

Public constructors

Track(
    int id,
    @C.TrackType int type,
    long timescale,
    long movieTimescale,
    long durationUs,
    long mediaDurationUs,
    Format format,
    @Track.Transformation int sampleTransformation,
    @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes,
    int nalUnitLengthFieldLength,
    @Nullable long[] editListDurations,
    @Nullable long[] editListMediaTimes,
    boolean shouldBeExposed,
    int chapterTrackId
)

This method is deprecated.

Use Builder instead.

Public methods

Track.Builder

Returns a new Builder initialized with the values of this instance.

Track

This method is deprecated.

Use buildUpon instead.

Track

This method is deprecated.

Use buildUpon instead.

@Nullable TrackEncryptionBox
getSampleDescriptionEncryptionBox(int sampleDescriptionIndex)

Returns the TrackEncryptionBox for the given sample description index.

Constants

TIMESCALE_UNSET

public static final long TIMESCALE_UNSET = -1

An unset or unknown timescale.

TRANSFORMATION_CEA608_CDAT

public static final int TRANSFORMATION_CEA608_CDAT = 1

A transformation for caption samples in cdat atoms.

TRANSFORMATION_NONE

public static final int TRANSFORMATION_NONE = 0

A no-op sample transformation.

Public fields

chapterTrackId

public final int chapterTrackId

The identifier of the associated chapter track, or INDEX_UNSET if there is none.

durationUs

public final long durationUs

The duration of the track in microseconds, or TIME_UNSET if unknown.

editListDurations

public final @Nullable ImmutableLongArray editListDurations

Durations of edit list segments in the movie timescale, or null if there is no edit list.

editListMediaTimes

public final @Nullable ImmutableLongArray editListMediaTimes

Media times for edit list segments in the track timescale, or null if there is no edit list.

format

public final Format format

The format.

id

public final int id

The track identifier.

mediaDurationUs

public final long mediaDurationUs

The duration of the media in microseconds, or TIME_UNSET if unknown.

movieTimescale

public final long movieTimescale

The movie timescale, or TIMESCALE_UNSET if unknown.

nalUnitLengthFieldLength

public final int nalUnitLengthFieldLength

The length in bytes of the NALUnitLength field in each sample. 0 for tracks that don't use length-delimited NAL units.

sampleTransformation

@Track.Transformation
public final int sampleTransformation

One of TRANSFORMATION_*. Defines the transformation to apply before outputting each sample.

shouldBeExposed

public final boolean shouldBeExposed

Whether the track should be exposed to the player.

timescale

public final long timescale

The track timescale, defined as the number of time units that pass in one second, or TIMESCALE_UNSET if unknown.

type

@C.TrackType
public final int type

One of TRACK_TYPE_AUDIO, TRACK_TYPE_VIDEO and TRACK_TYPE_TEXT.

Public constructors

Track

public Track(
    int id,
    @C.TrackType int type,
    long timescale,
    long movieTimescale,
    long durationUs,
    long mediaDurationUs,
    Format format,
    @Track.Transformation int sampleTransformation,
    @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes,
    int nalUnitLengthFieldLength,
    @Nullable long[] editListDurations,
    @Nullable long[] editListMediaTimes,
    boolean shouldBeExposed,
    int chapterTrackId
)

Public methods

buildUpon

public Track.Builder buildUpon()

Returns a new Builder initialized with the values of this instance.

copyWithFormat

public Track copyWithFormat(Format format)

copyWithoutEditLists

public Track copyWithoutEditLists()

getSampleDescriptionEncryptionBox

public @Nullable TrackEncryptionBox getSampleDescriptionEncryptionBox(int sampleDescriptionIndex)

Returns the TrackEncryptionBox for the given sample description index.

Parameters
int sampleDescriptionIndex

The given sample description index

Returns
@Nullable TrackEncryptionBox

The TrackEncryptionBox for the given sample description index. Maybe null if no such entry exists.