public abstract class DataChunk extends Chunk
Chunk implementations where the data should be loaded into a
byte[] before being consumed.dataSource, dataSpec, endTimeUs, startTimeUs, trackFormat, trackSelectionData, trackSelectionReason, type| Constructor and Description |
|---|
DataChunk(DataSource dataSource,
DataSpec dataSpec,
int type,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
byte[] data) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelLoad()
Cancels the load.
|
protected abstract void |
consume(byte[] data,
int limit)
Called by
load(). |
byte[] |
getDataHolder()
Returns the array in which the data is held.
|
void |
load()
Performs the load, returning on completion or cancellation.
|
bytesLoaded, getDurationUs, getResponseHeaders, getUripublic DataChunk(DataSource dataSource, DataSpec dataSpec, int type, Format trackFormat, int trackSelectionReason, java.lang.Object trackSelectionData, byte[] data)
dataSource - The source from which the data should be loaded.dataSpec - Defines the data to be loaded.type - See Chunk.type.trackFormat - See Chunk.trackFormat.trackSelectionReason - See Chunk.trackSelectionReason.trackSelectionData - See Chunk.trackSelectionData.data - An optional recycled array that can be used as a holder for the data.public byte[] getDataHolder()
This method should be used for recycling the holder only, and not for reading the data.
public final void cancelLoad()
Loader.Loadablepublic final void load()
throws java.io.IOException,
java.lang.InterruptedException
Loader.Loadablejava.io.IOException - If the input could not be loaded.java.lang.InterruptedException - If the thread was interrupted.protected abstract void consume(byte[] data,
int limit)
throws java.io.IOException
load(). Implementations should override this method to consume the loaded
data.data - An array containing the data.limit - The limit of the data.java.io.IOException - If an error occurs consuming the loaded data.