public class ContainerMediaChunk extends BaseMediaChunk implements ChunkExtractorWrapper.SingleTrackOutput
BaseMediaChunk
that uses an Extractor
to parse sample data.isMediaFormatFinal
chunkIndex, endTimeUs, startTimeUs
dataSource, dataSpec, format, NO_PARENT_ID, parentId, trigger, TRIGGER_ADAPTIVE, TRIGGER_CUSTOM_BASE, TRIGGER_INITIAL, TRIGGER_MANUAL, TRIGGER_TRICK_PLAY, TRIGGER_UNSPECIFIED, type, TYPE_CUSTOM_BASE, TYPE_DRM, TYPE_MANIFEST, TYPE_MEDIA, TYPE_MEDIA_INITIALIZATION, TYPE_UNSPECIFIED
Constructor and Description |
---|
ContainerMediaChunk(DataSource dataSource,
DataSpec dataSpec,
int trigger,
Format format,
long startTimeUs,
long endTimeUs,
int chunkIndex,
long sampleOffsetUs,
ChunkExtractorWrapper extractorWrapper,
MediaFormat mediaFormat,
int adaptiveMaxWidth,
int adaptiveMaxHeight,
DrmInitData drmInitData,
boolean isMediaFormatFinal,
int parentId) |
Modifier and Type | Method and Description |
---|---|
long |
bytesLoaded()
Gets the number of bytes that have been loaded.
|
void |
cancelLoad()
Cancels the load.
|
void |
drmInitData(DrmInitData drmInitData) |
void |
format(MediaFormat mediaFormat)
Invoked when the
MediaFormat of the track has been extracted from the stream. |
DrmInitData |
getDrmInitData()
Gets the
DrmInitData corresponding to the chunk. |
MediaFormat |
getMediaFormat()
Gets the
MediaFormat corresponding to the chunk. |
boolean |
isLoadCanceled()
Whether the load has been canceled.
|
void |
load()
Performs the load, returning on completion or cancelation.
|
int |
sampleData(ExtractorInput input,
int length,
boolean allowEndOfInput)
Invoked to write sample data to the output.
|
void |
sampleData(ParsableByteArray data,
int length)
Invoked to write sample data to the output.
|
void |
sampleMetadata(long timeUs,
int flags,
int size,
int offset,
byte[] encryptionKey)
Invoked when metadata associated with a sample has been extracted from the stream.
|
void |
seekMap(SeekMap seekMap) |
getFirstSampleIndex, getOutput, init
getNextChunkIndex
public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format, long startTimeUs, long endTimeUs, int chunkIndex, long sampleOffsetUs, ChunkExtractorWrapper extractorWrapper, MediaFormat mediaFormat, int adaptiveMaxWidth, int adaptiveMaxHeight, DrmInitData drmInitData, boolean isMediaFormatFinal, int parentId)
dataSource
- A DataSource
for loading the data.dataSpec
- Defines the data to be loaded.trigger
- The reason for this chunk being selected.format
- The format of the stream to which this chunk belongs.startTimeUs
- The start time of the media contained by the chunk, in microseconds.endTimeUs
- The end time of the media contained by the chunk, in microseconds.chunkIndex
- The index of the chunk.sampleOffsetUs
- An offset to add to the sample timestamps parsed by the extractor.extractorWrapper
- A wrapped extractor to use for parsing the data.mediaFormat
- The MediaFormat
of the chunk, if known. May be null if the data is
known to define its own format.adaptiveMaxWidth
- If this chunk contains video and is part of an adaptive playback, this
is the maximum width of the video in pixels that will be encountered during the playback.
MediaFormat.NO_VALUE
otherwise.adaptiveMaxHeight
- If this chunk contains video and is part of an adaptive playback, this
is the maximum height of the video in pixels that will be encountered during the playback.
MediaFormat.NO_VALUE
otherwise.drmInitData
- The DrmInitData
for the chunk. Null if the media is not drm
protected. May also be null if the data is known to define its own initialization data.isMediaFormatFinal
- True if mediaFormat
and drmInitData
are known to be
correct and final. False if the data may define its own format or initialization data.parentId
- Identifier for a parent from which this chunk originates.public final long bytesLoaded()
Chunk
bytesLoaded
in class Chunk
public final MediaFormat getMediaFormat()
BaseMediaChunk
MediaFormat
corresponding to the chunk.
See BaseMediaChunk.isMediaFormatFinal
for information about when this method is guaranteed to return
correct data.
getMediaFormat
in class BaseMediaChunk
MediaFormat
corresponding to this chunk.public final DrmInitData getDrmInitData()
BaseMediaChunk
DrmInitData
corresponding to the chunk.
See BaseMediaChunk.isMediaFormatFinal
for information about when this method is guaranteed to return
correct data.
getDrmInitData
in class BaseMediaChunk
DrmInitData
corresponding to this chunk.public final void seekMap(SeekMap seekMap)
seekMap
in interface ChunkExtractorWrapper.SingleTrackOutput
ExtractorOutput.seekMap(SeekMap)
public final void drmInitData(DrmInitData drmInitData)
drmInitData
in interface ChunkExtractorWrapper.SingleTrackOutput
ExtractorOutput.drmInitData(DrmInitData)
public final void format(MediaFormat mediaFormat)
TrackOutput
MediaFormat
of the track has been extracted from the stream.format
in interface TrackOutput
mediaFormat
- The extracted MediaFormat
.public final int sampleData(ExtractorInput input, int length, boolean allowEndOfInput) throws java.io.IOException, java.lang.InterruptedException
TrackOutput
sampleData
in interface TrackOutput
input
- An ExtractorInput
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 in C.RESULT_END_OF_INPUT
being returned. False if it
should be considered an error, causing an EOFException
to be thrown.java.io.IOException
- If an error occurred reading from the input.java.lang.InterruptedException
- If the thread was interrupted.public final void sampleData(ParsableByteArray data, int length)
TrackOutput
sampleData
in interface TrackOutput
data
- A ParsableByteArray
from which to read the sample data.length
- The number of bytes to read.public final void sampleMetadata(long timeUs, int flags, int size, int offset, byte[] encryptionKey)
TrackOutput
The corresponding sample data will have already been passed to the output via calls to
TrackOutput.sampleData(ExtractorInput, int, boolean)
or
TrackOutput.sampleData(ParsableByteArray, int)
.
sampleMetadata
in interface TrackOutput
timeUs
- The media timestamp associated with the sample, in microseconds.flags
- Flags associated with the sample. See SampleHolder.flags
.size
- The size of the sample data, in bytes.offset
- The number of bytes that have been passed to
TrackOutput.sampleData(ExtractorInput, int, boolean)
or
TrackOutput.sampleData(ParsableByteArray, int)
since the last byte belonging to the sample
whose metadata is being passed.encryptionKey
- The encryption key associated with the sample. May be null.public final void cancelLoad()
Loader.Loadable
cancelLoad
in interface Loader.Loadable
public final boolean isLoadCanceled()
Loader.Loadable
isLoadCanceled
in interface Loader.Loadable
public final void load() throws java.io.IOException, java.lang.InterruptedException
Loader.Loadable
load
in interface Loader.Loadable
java.io.IOException
java.lang.InterruptedException