@UnstableApi
interface TrackOutput

Known direct subclasses
DiscardingTrackOutput

A TrackOutput that consumes and discards all reported samples.

DummyTrackOutput

This class is deprecated.

Use DiscardingTrackOutput instead.

FakeTrackOutput

A fake TrackOutput.

ForwardingTrackOutput

An overridable TrackOutput implementation forwarding all methods to another track output.

PlayerEmsgHandler.PlayerTrackEmsgHandler

Handles emsg messages for a specific track for the player.

SampleQueue

A queue of media samples.


Receives track level data extracted by an Extractor.

Summary

Nested types

Holds data required to decrypt a sample.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation TrackOutput.SampleDataPart

Defines the part of the sample data to which a call to sampleData corresponds.

Constants

const Int

Sample encryption data.

const Int

Main media sample data.

const Int

Sample supplemental data.

Public functions

Unit
format(format: Format!)

Called when the Format of the track has been extracted from the stream.

Unit
sampleData(data: ParsableByteArray!, length: Int)

Equivalent to sampleData sampleData(data, length, SAMPLE_DATA_PART_MAIN)}.

Unit
sampleData(
    data: ParsableByteArray!,
    length: Int,
    @TrackOutput.SampleDataPart sampleDataPart: Int
)

Called to write sample data to the output.

Int
sampleData(input: DataReader!, length: Int, allowEndOfInput: Boolean)

Equivalent to sampleData(input, length, allowEndOfInput, SAMPLE_DATA_PART_MAIN).

Int
sampleData(
    input: DataReader!,
    length: Int,
    allowEndOfInput: Boolean,
    @TrackOutput.SampleDataPart sampleDataPart: Int
)

Called to write sample data to the output.

Unit
sampleMetadata(
    timeUs: Long,
    @C.BufferFlags flags: Int,
    size: Int,
    offset: Int,
    cryptoData: TrackOutput.CryptoData?
)

Called when metadata associated with a sample has been extracted from the stream.

Constants

SAMPLE_DATA_PART_ENCRYPTION

const val SAMPLE_DATA_PART_ENCRYPTION = 1: Int

Sample encryption data.

The format for encryption information is:

  • (1 byte) encryption_signal_byte: Most significant bit signals whether the encryption data contains subsample encryption data. The remaining bits contain initialization_vector_size.
  • (initialization_vector_size bytes) Initialization vector.
  • If subsample encryption data is present, as per encryption_signal_byte, the encryption data also contains:
    • (2 bytes) subsample_encryption_data_length.
    • (subsample_encryption_data_length * 6 bytes) Subsample encryption data (repeated subsample_encryption_data_length times:
      • (2 bytes) Size of a clear section in sample.
      • (4 bytes) Size of an encryption section in sample.

SAMPLE_DATA_PART_MAIN

const val SAMPLE_DATA_PART_MAIN = 0: Int

Main media sample data.

SAMPLE_DATA_PART_SUPPLEMENTAL

const val SAMPLE_DATA_PART_SUPPLEMENTAL = 2: Int

Sample supplemental data.

If a sample contains supplemental data, the format of the entire sample data will be:

  • If the sample has the BUFFER_FLAG_ENCRYPTED flag set, all encryption information.
  • (4 bytes) sample_data_size: The size of the actual sample data, not including supplemental data or encryption information.
  • (sample_data_size bytes): The media sample data.
  • (remaining bytes) The supplemental data.

Public functions

format

fun format(format: Format!): Unit

Called when the Format of the track has been extracted from the stream.

Parameters
format: Format!

The extracted Format.

sampleData

fun sampleData(data: ParsableByteArray!, length: Int): Unit

Equivalent to sampleData sampleData(data, length, SAMPLE_DATA_PART_MAIN)}.

sampleData

fun sampleData(
    data: ParsableByteArray!,
    length: Int,
    @TrackOutput.SampleDataPart sampleDataPart: Int
): Unit

Called to write sample data to the output.

Parameters
data: ParsableByteArray!

A ParsableByteArray from which to read the sample data.

length: Int

The number of bytes to read, starting from data.getPosition().

@TrackOutput.SampleDataPart sampleDataPart: Int

The part of the sample data to which this call corresponds.

sampleData

fun sampleData(input: DataReader!, length: Int, allowEndOfInput: Boolean): Int

Equivalent to sampleData(input, length, allowEndOfInput, SAMPLE_DATA_PART_MAIN).

sampleData

fun sampleData(
    input: DataReader!,
    length: Int,
    allowEndOfInput: Boolean,
    @TrackOutput.SampleDataPart sampleDataPart: Int
): Int

Called to write sample data to the output.

Parameters
input: DataReader!

A DataReader from which to read the sample data.

length: Int

The maximum length to read from the input.

allowEndOfInput: Boolean

True if encountering the end of the input having read no data is allowed, and should result in RESULT_END_OF_INPUT being returned. False if it should be considered an error, causing an EOFException to be thrown.

@TrackOutput.SampleDataPart sampleDataPart: Int

The part of the sample data to which this call corresponds.

Returns
Int

The number of bytes appended.

Throws
java.io.IOException

If an error occurred reading from the input.

sampleMetadata

fun sampleMetadata(
    timeUs: Long,
    @C.BufferFlags flags: Int,
    size: Int,
    offset: Int,
    cryptoData: TrackOutput.CryptoData?
): Unit

Called when metadata associated with a sample has been extracted from the stream.

The corresponding sample data will have already been passed to the output via calls to sampleData or sampleData.

Parameters
timeUs: Long

The media timestamp associated with the sample, in microseconds.

@C.BufferFlags flags: Int

Flags associated with the sample. See C.BUFFER_FLAG_*.

size: Int

The size of the sample data, in bytes.

offset: Int

The number of bytes that have been passed to sampleData or sampleData since the last byte belonging to the sample whose metadata is being passed.

cryptoData: TrackOutput.CryptoData?

The encryption data required to decrypt the sample. May be null.