Class PlayerEmsgHandler.PlayerTrackEmsgHandler
- java.lang.Object
-
- com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler
-
- All Implemented Interfaces:
TrackOutput
- Enclosing class:
- PlayerEmsgHandler
public final class PlayerEmsgHandler.PlayerTrackEmsgHandler extends Object implements TrackOutput
Handles emsg messages for a specific track for the player.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.extractor.TrackOutput
TrackOutput.CryptoData, TrackOutput.SampleDataPart
-
-
Field Summary
-
Fields inherited from interface com.google.android.exoplayer2.extractor.TrackOutput
SAMPLE_DATA_PART_ENCRYPTION, SAMPLE_DATA_PART_MAIN, SAMPLE_DATA_PART_SUPPLEMENTAL
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
format(Format format)
Called when theFormat
of the track has been extracted from the stream.boolean
maybeRefreshManifestBeforeLoadingNextChunk(long presentationPositionUs)
For live streaming, check if the DASH manifest is expired before the next segment start time.void
onChunkLoadCompleted(Chunk chunk)
Called when a chunk load has been completed.boolean
onChunkLoadError(Chunk chunk)
Called when a chunk load has encountered an error.void
release()
Release this track emsg handler.int
sampleData(DataReader input, int length, boolean allowEndOfInput, @com.google.android.exoplayer2.extractor.TrackOutput.SampleDataPart int sampleDataPart)
Called to write sample data to the output.void
sampleData(ParsableByteArray data, int length, @com.google.android.exoplayer2.extractor.TrackOutput.SampleDataPart int sampleDataPart)
Called to write sample data to the output.void
sampleMetadata(long timeUs, int flags, int size, int offset, TrackOutput.CryptoData cryptoData)
Called when metadata associated with a sample has been extracted from the stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.extractor.TrackOutput
sampleData, sampleData
-
-
-
-
Method Detail
-
format
public void format(Format format)
Description copied from interface:TrackOutput
Called when theFormat
of the track has been extracted from the stream.- Specified by:
format
in interfaceTrackOutput
- Parameters:
format
- The extractedFormat
.
-
sampleData
public int sampleData(DataReader input, int length, boolean allowEndOfInput, @com.google.android.exoplayer2.extractor.TrackOutput.SampleDataPart int sampleDataPart) throws IOException
Description copied from interface:TrackOutput
Called to write sample data to the output.- Specified by:
sampleData
in interfaceTrackOutput
- Parameters:
input
- ADataReader
from which to read the sample data.length
- The maximum length to read from the input.allowEndOfInput
- True if encountering the end of the input having read no data is allowed, and should result inC.RESULT_END_OF_INPUT
being returned. False if it should be considered an error, causing anEOFException
to be thrown.sampleDataPart
- The part of the sample data to which this call corresponds.- Returns:
- The number of bytes appended.
- Throws:
IOException
- If an error occurred reading from the input.
-
sampleData
public void sampleData(ParsableByteArray data, int length, @com.google.android.exoplayer2.extractor.TrackOutput.SampleDataPart int sampleDataPart)
Description copied from interface:TrackOutput
Called to write sample data to the output.- Specified by:
sampleData
in interfaceTrackOutput
- Parameters:
data
- AParsableByteArray
from which to read the sample data.length
- The number of bytes to read, starting fromdata.getPosition()
.sampleDataPart
- The part of the sample data to which this call corresponds.
-
sampleMetadata
public void sampleMetadata(long timeUs, int flags, int size, int offset, @Nullable TrackOutput.CryptoData cryptoData)
Description copied from interface:TrackOutput
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
TrackOutput.sampleData(DataReader, int, boolean)
orTrackOutput.sampleData(ParsableByteArray, int)
.- Specified by:
sampleMetadata
in interfaceTrackOutput
- Parameters:
timeUs
- The media timestamp associated with the sample, in microseconds.flags
- Flags associated with the sample. SeeC.BUFFER_FLAG_*
.size
- The size of the sample data, in bytes.offset
- The number of bytes that have been passed toTrackOutput.sampleData(DataReader, int, boolean)
orTrackOutput.sampleData(ParsableByteArray, int)
since the last byte belonging to the sample whose metadata is being passed.cryptoData
- The encryption data required to decrypt the sample. May be null.
-
maybeRefreshManifestBeforeLoadingNextChunk
public boolean maybeRefreshManifestBeforeLoadingNextChunk(long presentationPositionUs)
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
- The next load position in presentation time.- Returns:
- True if manifest refresh has been requested, false otherwise.
-
onChunkLoadCompleted
public void onChunkLoadCompleted(Chunk chunk)
Called when a chunk load has been completed.- Parameters:
chunk
- The chunk whose load has been completed.
-
onChunkLoadError
public boolean onChunkLoadError(Chunk chunk)
Called when a chunk load has encountered an error.- Parameters:
chunk
- The chunk whose load encountered an error.- Returns:
- Whether a manifest refresh has been requested.
-
release
public void release()
Release this track emsg handler. It should not be reused after this call.
-
-