public final class HlsExtractorWrapper extends Object implements ExtractorOutput
Extractor
, adding functionality to enable reading of the extracted samples.Modifier and Type | Field and Description |
---|---|
Format |
format |
long |
startTimeUs |
int |
trigger |
Constructor and Description |
---|
HlsExtractorWrapper(int trigger,
Format format,
long startTimeUs,
Extractor extractor,
boolean shouldSpliceIn,
int adaptiveMaxWidth,
int adaptiveMaxHeight) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears queues for all tracks, returning all allocations to the allocator.
|
void |
configureSpliceTo(HlsExtractorWrapper nextExtractor)
Attempts to configure a splice from this extractor to the next.
|
void |
discardUntil(int track,
long timeUs)
Discards samples for the specified track up to the specified time.
|
void |
drmInitData(DrmInitData drmInit)
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. |
long |
getAdjustedEndTimeUs() |
long |
getLargestParsedTimestampUs()
Gets the largest timestamp of any sample parsed by the extractor.
|
MediaFormat |
getMediaFormat(int track)
Gets the
MediaFormat of the specified track. |
boolean |
getSample(int track,
SampleHolder holder)
Gets the next sample for the specified track.
|
int |
getTrackCount()
Gets the number of available tracks.
|
boolean |
hasSamples(int track)
Whether samples are available for reading from
getSample(int, SampleHolder) for the
specified track. |
void |
init(Allocator allocator)
Initializes the wrapper for use.
|
boolean |
isPrepared()
Whether the extractor is prepared.
|
int |
read(ExtractorInput input)
Reads from the provided
ExtractorInput . |
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 final int trigger
public final Format format
public final long startTimeUs
public void init(Allocator allocator)
allocator
- An allocator for obtaining allocations into which extracted data is written.public boolean isPrepared()
public void clear()
public long getLargestParsedTimestampUs()
Long.MIN_VALUE
if no samples have been parsed.public final void configureSpliceTo(HlsExtractorWrapper nextExtractor)
The splice is performed such that for each track the samples read from the next extractor start with a keyframe, and continue from where the samples read from this extractor finish. A successful splice may discard samples from either or both extractors.
Splice configuration may fail if the next extractor is not yet in a state that allows the splice to be performed. Calling this method is a noop if the splice has already been configured. Hence this method should be called repeatedly during the window within which a splice can be performed.
This method must only be called after the extractor has been prepared.
nextExtractor
- The extractor being spliced to.public int getTrackCount()
This method must only be called after the extractor has been prepared.
public MediaFormat getMediaFormat(int track)
MediaFormat
of the specified track.
This method must only be called after the extractor has been prepared.
track
- The track index.public boolean getSample(int track, SampleHolder holder)
This method must only be called after the extractor has been prepared.
track
- The track from which to read.holder
- A SampleHolder
into which the sample should be read.public void discardUntil(int track, long timeUs)
This method must only be called after the extractor has been prepared.
track
- The track from which samples should be discarded.timeUs
- The time up to which samples should be discarded, in microseconds.public boolean hasSamples(int track)
getSample(int, SampleHolder)
for the
specified track.
This method must only be called after the extractor has been prepared.
getSample(int, SampleHolder)
for the specified track. False otherwise.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 long getAdjustedEndTimeUs()
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 drmInit)
ExtractorOutput
DrmInitData
has been extracted from the stream.drmInitData
in interface ExtractorOutput
drmInit
- The extracted DrmInitData
.