public class ChunkExtractorWrapper extends Object implements ExtractorOutput, TrackOutput
Extractor
wrapper for loading chunks containing a single track.
The wrapper allows switching of the ChunkExtractorWrapper.SingleTrackOutput
that receives parsed data.
Modifier and Type | Class and Description |
---|---|
static interface |
ChunkExtractorWrapper.SingleTrackOutput
Receives stream level data extracted by the wrapped
Extractor . |
Constructor and Description |
---|
ChunkExtractorWrapper(Extractor extractor) |
Modifier and Type | Method and Description |
---|---|
void |
drmInitData(DrmInitData drmInitData)
Invoked when
DrmInitData has been extracted from the stream. |
void |
endTracks()
Invoked when all tracks have been identified, meaning that
ExtractorOutput.track(int) will not be
invoked again. |
void |
format(MediaFormat format)
Invoked when the
MediaFormat of the track has been extracted from the stream. |
void |
init(ChunkExtractorWrapper.SingleTrackOutput output)
Initializes the extractor to output to the provided
ChunkExtractorWrapper.SingleTrackOutput , and configures
it to receive data from a new chunk. |
int |
read(ExtractorInput input)
Reads from the provided
ExtractorInput . |
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)
Invoked when a
SeekMap has been extracted from the stream. |
TrackOutput |
track(int id)
Called by the
Extractor to get the TrackOutput for a specific track. |
public ChunkExtractorWrapper(Extractor extractor)
extractor
- The extractor to wrap.public void init(ChunkExtractorWrapper.SingleTrackOutput output)
ChunkExtractorWrapper.SingleTrackOutput
, and configures
it to receive data from a new chunk.output
- The ChunkExtractorWrapper.SingleTrackOutput
that will receive the parsed data.public int read(ExtractorInput input) throws IOException, InterruptedException
ExtractorInput
.input
- The ExtractorInput
from which to read.Extractor.RESULT_CONTINUE
and Extractor.RESULT_END_OF_INPUT
.IOException
- If an error occurred reading from the source.InterruptedException
- If the thread was interrupted.public TrackOutput track(int id)
ExtractorOutput
Extractor
to get the TrackOutput
for a specific track.
The same TrackOutput
is returned if multiple calls are made with the same
trackId
.
track
in interface ExtractorOutput
id
- A track identifier.TrackOutput
for the given track identifier.public void endTracks()
ExtractorOutput
ExtractorOutput.track(int)
will not be
invoked again.endTracks
in interface ExtractorOutput
public void seekMap(SeekMap seekMap)
ExtractorOutput
SeekMap
has been extracted from the stream.seekMap
in interface ExtractorOutput
seekMap
- The extracted SeekMap
.public void drmInitData(DrmInitData drmInitData)
ExtractorOutput
DrmInitData
has been extracted from the stream.drmInitData
in interface ExtractorOutput
drmInitData
- The extracted DrmInitData
.public void format(MediaFormat format)
TrackOutput
MediaFormat
of the track has been extracted from the stream.format
in interface TrackOutput
format
- 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.