public static interface SampleSource.SampleSourceReader
SampleSource
.Modifier and Type | Method and Description |
---|---|
boolean |
continueBuffering(int track,
long positionUs)
Indicates to the source that it should still be buffering data for the specified track.
|
void |
disable(int track)
Disable the specified track.
|
void |
enable(int track,
long positionUs)
Enable the specified track.
|
long |
getBufferedPositionUs()
Returns an estimate of the position up to which data is buffered.
|
MediaFormat |
getFormat(int track)
Returns the format of the specified track.
|
int |
getTrackCount()
Returns the number of tracks exposed by the source.
|
void |
maybeThrowError()
If the source is currently having difficulty preparing or loading samples, then this method
throws the underlying error.
|
boolean |
prepare(long positionUs)
Prepares the source.
|
int |
readData(int track,
long positionUs,
MediaFormatHolder formatHolder,
SampleHolder sampleHolder)
Attempts to read a sample or a new format from the source.
|
long |
readDiscontinuity(int track)
Attempts to read a pending discontinuity from the source.
|
void |
release()
Releases the
SampleSource.SampleSourceReader . |
void |
seekToUs(long positionUs)
Seeks to the specified time in microseconds.
|
void maybeThrowError() throws IOException
IOException
- The underlying error.boolean prepare(long positionUs)
Preparation may require reading from the data source (e.g. to determine the available tracks
and formats). If insufficient data is available then the call will return false
rather than block. The method can be called repeatedly until the return value indicates
success.
positionUs
- The player's current playback position.int getTrackCount()
This method should only be called after the source has been prepared.
MediaFormat getFormat(int track)
Note that whilst the format of a track will remain constant, the format of the actual media
stream may change dynamically. An example of this is where the track is adaptive
(i.e. @link MediaFormat.adaptive
is true). Hence the track formats returned through
this method should not be used to configure decoders. Decoder configuration should be
performed using the formats obtained when reading the media stream through calls to
readData(int, long, MediaFormatHolder, SampleHolder)
.
This method should only be called after the source has been prepared.
track
- The track index.void enable(int track, long positionUs)
readData(int, long, MediaFormatHolder, SampleHolder)
.
This method should only be called after the source has been prepared, and when the specified track is disabled.
track
- The track to enable.positionUs
- The player's current playback position.boolean continueBuffering(int track, long positionUs)
This method should only be called when the specified track is enabled.
track
- The track to continue buffering.positionUs
- The current playback position.long readDiscontinuity(int track)
This method should only be called when the specified track is enabled.
track
- The track from which to read.SampleSource.NO_DISCONTINUITY
.int readData(int track, long positionUs, MediaFormatHolder formatHolder, SampleHolder sampleHolder)
This method should only be called when the specified track is enabled.
Note that where multiple tracks are enabled, SampleSource.NOTHING_READ
may be returned if the
next piece of data to be read from the SampleSource
corresponds to a different track
than the one for which data was requested.
This method will always return SampleSource.NOTHING_READ
in the case that there's a pending
discontinuity to be read from readDiscontinuity(int)
for the specified track.
track
- The track from which to read.positionUs
- The current playback position.formatHolder
- A MediaFormatHolder
object to populate in the case of a new
format.sampleHolder
- A SampleHolder
object to populate in the case of a new sample.
If the caller requires the sample data then it must ensure that SampleHolder.data
references a valid output buffer.SampleSource.SAMPLE_READ
, SampleSource.FORMAT_READ
,
SampleSource.NOTHING_READ
or SampleSource.END_OF_STREAM
.void seekToUs(long positionUs)
This method should only be called when at least one track is enabled.
positionUs
- The seek position in microseconds.long getBufferedPositionUs()
This method should only be called when at least one track is enabled.
TrackRenderer.END_OF_TRACK_US
if data is buffered to the end of the stream,
or TrackRenderer.UNKNOWN_TIME_US
if no estimate is available.void disable(int track)
This method should only be called when the specified track is enabled.
track
- The track to disable.void release()
SampleSource.SampleSourceReader
.
This method should be called when access to the SampleSource
is no longer required.