Class Chunk
- java.lang.Object
-
- com.google.android.exoplayer2.source.chunk.Chunk
-
- All Implemented Interfaces:
Loader.Loadable
- Direct Known Subclasses:
DataChunk,InitializationChunk,MediaChunk
public abstract class Chunk extends Object implements Loader.Loadable
An abstract base class forLoader.Loadableimplementations that load chunks of data required for the playback of streams.
-
-
Field Summary
Fields Modifier and Type Field Description protected StatsDataSourcedataSourceDataSpecdataSpecTheDataSpecthat defines the data to be loaded.longendTimeUsThe end time of the media contained by the chunk, orC.TIME_UNSETif the data being loaded does not contain media samples.longloadTaskIdIdentifies the load task for this loadable.longstartTimeUsThe start time of the media contained by the chunk, orC.TIME_UNSETif the data being loaded does not contain media samples.FormattrackFormatThe format of the track to which this chunk belongs.ObjecttrackSelectionDataOptional data associated with the selection of the track to which this chunk belongs.@com.google.android.exoplayer2.C.SelectionReason inttrackSelectionReasonOne of theselection reasonsif the chunk belongs to a track.@com.google.android.exoplayer2.C.DataType inttypeThedata typeof the chunk.
-
Constructor Summary
Constructors Constructor Description Chunk(DataSource dataSource, DataSpec dataSpec, @com.google.android.exoplayer2.C.DataType int type, Format trackFormat, @com.google.android.exoplayer2.C.SelectionReason int trackSelectionReason, Object trackSelectionData, long startTimeUs, long endTimeUs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longbytesLoaded()Returns the number of bytes that have been loaded.longgetDurationUs()Returns the duration of the chunk in microseconds.Map<String,List<String>>getResponseHeaders()Returns the response headers associated with the lastDataSource.open(com.google.android.exoplayer2.upstream.DataSpec)call.UrigetUri()Returns theUriassociated with the lastDataSource.open(com.google.android.exoplayer2.upstream.DataSpec)call.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.upstream.Loader.Loadable
cancelLoad, load
-
-
-
-
Field Detail
-
loadTaskId
public final long loadTaskId
Identifies the load task for this loadable.
-
type
public final @com.google.android.exoplayer2.C.DataType int type
Thedata typeof the chunk. For reporting only.
-
trackFormat
public final Format trackFormat
The format of the track to which this chunk belongs.
-
trackSelectionReason
public final @com.google.android.exoplayer2.C.SelectionReason int trackSelectionReason
One of theselection reasonsif the chunk belongs to a track.C.SELECTION_REASON_UNKNOWNif the chunk does not belong to a track, or if the selection reason is unknown.
-
trackSelectionData
@Nullable public final Object trackSelectionData
Optional data associated with the selection of the track to which this chunk belongs. Null if the chunk does not belong to a track, or if there is no associated track selection data.
-
startTimeUs
public final long startTimeUs
The start time of the media contained by the chunk, orC.TIME_UNSETif the data being loaded does not contain media samples.
-
endTimeUs
public final long endTimeUs
The end time of the media contained by the chunk, orC.TIME_UNSETif the data being loaded does not contain media samples.
-
dataSource
protected final StatsDataSource dataSource
-
-
Constructor Detail
-
Chunk
public Chunk(DataSource dataSource, DataSpec dataSpec, @com.google.android.exoplayer2.C.DataType int type, Format trackFormat, @com.google.android.exoplayer2.C.SelectionReason int trackSelectionReason, @Nullable Object trackSelectionData, long startTimeUs, long endTimeUs)
- Parameters:
dataSource- The source from which the data should be loaded.dataSpec- Defines the data to be loaded.type- Seetype.trackFormat- SeetrackFormat.trackSelectionReason- SeetrackSelectionReason.trackSelectionData- SeetrackSelectionData.startTimeUs- SeestartTimeUs.endTimeUs- SeeendTimeUs.
-
-
Method Detail
-
getDurationUs
public final long getDurationUs()
Returns the duration of the chunk in microseconds.
-
bytesLoaded
public final long bytesLoaded()
Returns the number of bytes that have been loaded. Must only be called after the load completed, failed, or was canceled.
-
getUri
public final Uri getUri()
Returns theUriassociated with the lastDataSource.open(com.google.android.exoplayer2.upstream.DataSpec)call. If redirection occurred, this is the redirected uri. Must only be called after the load completed, failed, or was canceled.- See Also:
DataSource.getUri()
-
getResponseHeaders
public final Map<String,List<String>> getResponseHeaders()
Returns the response headers associated with the lastDataSource.open(com.google.android.exoplayer2.upstream.DataSpec)call. Must only be called after the load completed, failed, or was canceled.- See Also:
DataSource.getResponseHeaders()
-
-