public class InitializationChunk extends Chunk implements ChunkExtractorWrapper.SingleTrackOutput
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 |
---|
InitializationChunk(DataSource dataSource,
DataSpec dataSpec,
int trigger,
Format format,
ChunkExtractorWrapper extractorWrapper) |
InitializationChunk(DataSource dataSource,
DataSpec dataSpec,
int trigger,
Format format,
ChunkExtractorWrapper extractorWrapper,
int parentId)
Constructor for a chunk of media samples.
|
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()
Returns a
DrmInitData parsed from the chunk, or null. |
MediaFormat |
getFormat()
Returns a
MediaFormat parsed from the chunk, or null. |
SeekMap |
getSeekMap()
Returns a
SeekMap parsed from the chunk, or null. |
boolean |
hasDrmInitData()
True if a
DrmInitData was parsed from the chunk. |
boolean |
hasFormat()
True if a
MediaFormat was parsed from the chunk. |
boolean |
hasSeekMap()
True if a
SeekMap was parsed from 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) |
public InitializationChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format, ChunkExtractorWrapper extractorWrapper)
public InitializationChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format, ChunkExtractorWrapper extractorWrapper, int parentId)
dataSource
- A DataSource
for loading the initialization data.dataSpec
- Defines the initialization data to be loaded.trigger
- The reason for this chunk being selected.format
- The format of the stream to which this chunk belongs.extractorWrapper
- A wrapped extractor to use for parsing the initialization data.parentId
- Identifier for a parent from which this chunk originates.public long bytesLoaded()
Chunk
bytesLoaded
in class Chunk
public boolean hasFormat()
MediaFormat
was parsed from the chunk. False otherwise.
Should be called after loading has completed.
public MediaFormat getFormat()
MediaFormat
parsed from the chunk, or null.
Should be called after loading has completed.
public boolean hasDrmInitData()
DrmInitData
was parsed from the chunk. False otherwise.
Should be called after loading has completed.
public DrmInitData getDrmInitData()
DrmInitData
parsed from the chunk, or null.
Should be called after loading has completed.
public boolean hasSeekMap()
SeekMap
was parsed from the chunk. False otherwise.
Should be called after loading has completed.
public SeekMap getSeekMap()
SeekMap
parsed from the chunk, or null.
Should be called after loading has completed.
public void seekMap(SeekMap seekMap)
seekMap
in interface ChunkExtractorWrapper.SingleTrackOutput
ExtractorOutput.seekMap(SeekMap)
public void drmInitData(DrmInitData drmInitData)
drmInitData
in interface ChunkExtractorWrapper.SingleTrackOutput
ExtractorOutput.drmInitData(DrmInitData)
public void format(MediaFormat mediaFormat)
TrackOutput
MediaFormat
of the track has been extracted from the stream.format
in interface TrackOutput
mediaFormat
- The extracted MediaFormat
.public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput) throws IOException, 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.IOException
- If an error occurred reading from the input.InterruptedException
- If the thread was interrupted.public 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 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 void cancelLoad()
Loader.Loadable
cancelLoad
in interface Loader.Loadable
public boolean isLoadCanceled()
Loader.Loadable
isLoadCanceled
in interface Loader.Loadable
public void load() throws IOException, InterruptedException
Loader.Loadable
load
in interface Loader.Loadable
IOException
InterruptedException