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 |
|---|---|
long |
bytesLoaded()
Returns the number of bytes that have been loaded.
|
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.
|
boolean |
isLoadCanceled()
Returns whether the load has been canceled.
|
void |
load()
Performs the load, returning on completion or cancellation.
|
getDurationUspublic 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 long bytesLoaded()
ChunkbytesLoaded in class Chunkpublic final void cancelLoad()
Loader.Loadablepublic final boolean isLoadCanceled()
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.