PlayerEmsgHandler.PlayerTrackEmsgHandler


inner class PlayerEmsgHandler.PlayerTrackEmsgHandler : TrackOutput


Handles emsg messages for a specific track for the player.

Summary

Public functions

Unit
format(format: Format!)

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

Boolean
maybeRefreshManifestBeforeLoadingNextChunk(
    presentationPositionUs: Long
)

For live streaming, check if the DASH manifest is expired before the next segment start time.

Unit

Called when a chunk load has been completed.

Boolean

Called when a chunk load has encountered an error.

Unit

Release this track emsg handler.

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,
    @TrackOutput.SampleDataPart sampleDataPart: Int
)

Called to write sample data to the output.

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

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

Inherited Constants

From androidx.media3.extractor.TrackOutput
const Int

Sample encryption data.

const Int

Main media sample data.

const Int

Sample supplemental data.

Inherited functions

From androidx.media3.extractor.TrackOutput
Unit
sampleData(data: ParsableByteArray!, length: Int)

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

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

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

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.

maybeRefreshManifestBeforeLoadingNextChunk

fun maybeRefreshManifestBeforeLoadingNextChunk(
    presentationPositionUs: Long
): Boolean

For live streaming, check if the DASH manifest is expired before the next segment start time. If it is, the DASH media source will be notified to refresh the manifest.

Parameters
presentationPositionUs: Long

The next load position in presentation time.

Returns
Boolean

True if manifest refresh has been requested, false otherwise.

onChunkLoadCompleted

fun onChunkLoadCompleted(chunk: Chunk!): Unit

Called when a chunk load has been completed.

Parameters
chunk: Chunk!

The chunk whose load has been completed.

onChunkLoadError

fun onChunkLoadError(chunk: Chunk!): Boolean

Called when a chunk load has encountered an error.

Parameters
chunk: Chunk!

The chunk whose load encountered an error.

Returns
Boolean

Whether a manifest refresh has been requested.

release

fun release(): Unit

Release this track emsg handler. It should not be reused after this call.

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,
    @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,
    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.

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.