public final class InitializationChunk extends Chunk implements ChunkExtractorWrapper.SingleTrackMetadataOutput, TrackOutput
dataSource, dataSpec, endTimeUs, startTimeUs, trackFormat, trackSelectionData, trackSelectionReason, type
Constructor and Description |
---|
InitializationChunk(DataSource dataSource,
DataSpec dataSpec,
Format trackFormat,
int trackSelectionReason,
Object trackSelectionData,
ChunkExtractorWrapper extractorWrapper) |
Modifier and Type | Method and Description |
---|---|
long |
bytesLoaded()
Returns the number of bytes that have been loaded.
|
void |
cancelLoad()
Cancels the load.
|
void |
format(Format format)
Called when the
Format of the track has been extracted from the stream. |
Format |
getSampleFormat()
Returns a
Format parsed from the chunk, or null. |
SeekMap |
getSeekMap()
Returns a
SeekMap parsed from the chunk, or null. |
boolean |
isLoadCanceled()
Returns whether the load has been canceled.
|
void |
load()
Performs the load, returning on completion or cancellation.
|
int |
sampleData(ExtractorInput input,
int length,
boolean allowEndOfInput)
Called to write sample data to the output.
|
void |
sampleData(ParsableByteArray data,
int length)
Called to write sample data to the output.
|
void |
sampleMetadata(long timeUs,
int flags,
int size,
int offset,
byte[] encryptionKey)
Called when metadata associated with a sample has been extracted from the stream.
|
void |
seekMap(SeekMap seekMap) |
getDurationUs
public InitializationChunk(DataSource dataSource, DataSpec dataSpec, Format trackFormat, int trackSelectionReason, Object trackSelectionData, ChunkExtractorWrapper extractorWrapper)
dataSource
- The source from which the data should be loaded.dataSpec
- Defines the data to be loaded.trackFormat
- See Chunk.trackFormat
.trackSelectionReason
- See Chunk.trackSelectionReason
.trackSelectionData
- See Chunk.trackSelectionData
.extractorWrapper
- A wrapped extractor to use for parsing the initialization data.public long bytesLoaded()
Chunk
bytesLoaded
in class Chunk
public Format getSampleFormat()
Format
parsed from the chunk, or null.
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.SingleTrackMetadataOutput
ExtractorOutput.seekMap(SeekMap)
public void format(Format format)
TrackOutput
Format
of the track has been extracted from the stream.format
in interface TrackOutput
format
- The extracted Format
.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 C.BUFFER_FLAG_*
.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