Package com.google.android.exoplayer2.source.chunk

## Class ContainerMediaChunk

- java.lang.Object
- - com.google.android.exoplayer2.source.chunk.Chunk
  - - com.google.android.exoplayer2.source.chunk.MediaChunk
    - - com.google.android.exoplayer2.source.chunk.BaseMediaChunk
      - - com.google.android.exoplayer2.source.chunk.ContainerMediaChunk

- All Implemented Interfaces:
    `Loader.Loadable`

      public class ContainerMediaChunk
      extends BaseMediaChunk

  A `BaseMediaChunk` that uses an `Extractor` to decode sample data.

- - ### Field Summary

    - ### Fields inherited from class com.google.android.exoplayer2.source.chunk.BaseMediaChunk

      `clippedEndTimeUs, clippedStartTimeUs`

    - ### Fields inherited from class com.google.android.exoplayer2.source.chunk.MediaChunk

      `chunkIndex`

    - ### Fields inherited from class com.google.android.exoplayer2.source.chunk.Chunk

      `dataSource, dataSpec, endTimeUs, loadTaskId, startTimeUs, trackFormat, trackSelectionData, trackSelectionReason, type`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ContainerMediaChunk​(DataSource dataSource, DataSpec dataSpec, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long startTimeUs, long endTimeUs, long clippedStartTimeUs, long clippedEndTimeUs, long chunkIndex, int chunkCount, long sampleOffsetUs, ChunkExtractor chunkExtractor)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `cancelLoad()` | Cancels the load.
    `long` | `getNextChunkIndex()` | Returns the next chunk index or `C.INDEX_UNSET` if it is not known.
    `protected ChunkExtractor.TrackOutputProvider` | `getTrackOutputProvider​(BaseMediaChunkOutput baseMediaChunkOutput)` | Returns the `ChunkExtractor.TrackOutputProvider` to be used by the wrapped extractor.
    `boolean` | `isLoadCompleted()` | Returns whether the chunk has been fully loaded.
    `void` | `load()` | Performs the load, returning on completion or cancellation.

    - ### Methods inherited from class com.google.android.exoplayer2.source.chunk.BaseMediaChunk

      `getFirstSampleIndex, getOutput, init`

    - ### Methods inherited from class com.google.android.exoplayer2.source.chunk.Chunk

      `bytesLoaded, getDurationUs, getResponseHeaders, getUri`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ContainerMediaChunk

          public ContainerMediaChunk​(DataSource dataSource,
                                     DataSpec dataSpec,
                                     Format trackFormat,
                                     int trackSelectionReason,
                                     @Nullable
                                     Object trackSelectionData,
                                     long startTimeUs,
                                     long endTimeUs,
                                     long clippedStartTimeUs,
                                     long clippedEndTimeUs,
                                     long chunkIndex,
                                     int chunkCount,
                                     long sampleOffsetUs,
                                     ChunkExtractor chunkExtractor)

      Parameters:
        `dataSource` - The source from which the data should be loaded.
        `dataSpec` - Defines the data to be loaded.
        `trackFormat` - See `Chunk.trackFormat`.
        `trackSelectionReason` - See `Chunk.trackSelectionReason`.
        `trackSelectionData` - See `Chunk.trackSelectionData`.
        `startTimeUs` - The start time of the media contained by the chunk, in microseconds.
        `endTimeUs` - The end time of the media contained by the chunk, in microseconds.
        `clippedStartTimeUs` - The time in the chunk from which output will begin, or `C.TIME_UNSET` to output from the start of the chunk.
        `clippedEndTimeUs` - The time in the chunk from which output will end, or `C.TIME_UNSET` to output to the end of the chunk.
        `chunkIndex` - The index of the chunk, or `C.INDEX_UNSET` if it is not known.
        `chunkCount` - The number of chunks in the underlying media that are spanned by this instance. Normally equal to one, but may be larger if multiple chunks as defined by the underlying media are being merged into a single load.
        `sampleOffsetUs` - An offset to add to the sample timestamps parsed by the extractor.
        `chunkExtractor` - A wrapped extractor to use for parsing the data.

  - ### Method Detail

    - #### getNextChunkIndex

          public long getNextChunkIndex()

      Description copied from class: `MediaChunk`
      Returns the next chunk index or `C.INDEX_UNSET` if it is not known.
      Overrides:
        `getNextChunkIndex` in class `MediaChunk`

    - #### isLoadCompleted

          public boolean isLoadCompleted()

      Description copied from class: `MediaChunk`
      Returns whether the chunk has been fully loaded.
      Specified by:
        `isLoadCompleted` in class `MediaChunk`

    - #### cancelLoad

          public final void cancelLoad()

      Description copied from interface: `Loader.Loadable`
      Cancels the load.

      Loadable implementations should ensure that a currently executing `Loader.Loadable.load()` call will exit reasonably quickly after this method is called. The `Loader.Loadable.load()` call may exit either by returning or by throwing an `IOException`.

      If there is a currently executing `Loader.Loadable.load()` call, then the thread on which that call is being made will be interrupted immediately after the call to this method. Hence implementations do not need to (and should not attempt to) interrupt the loading thread themselves.

      Although the loading thread will be interrupted, Loadable implementations should not use the interrupted status of the loading thread in `Loader.Loadable.load()` to determine whether the load has been canceled. This approach is not robust [Internal ref: b/79223737]. Instead, implementations should use their own flag to signal cancelation (for example, using `AtomicBoolean`).

    - #### load

          public final void load()
                          throws IOException

      Description copied from interface: `Loader.Loadable`
      Performs the load, returning on completion or cancellation.
      Throws:
        `IOException` - If the input could not be loaded.

    - #### getTrackOutputProvider

          protected ChunkExtractor.TrackOutputProvider getTrackOutputProvider​(BaseMediaChunkOutput baseMediaChunkOutput)

      Returns the `ChunkExtractor.TrackOutputProvider` to be used by the wrapped extractor.
      Parameters:
        `baseMediaChunkOutput` - The `BaseMediaChunkOutput` most recently passed to `BaseMediaChunk.init(BaseMediaChunkOutput)`.
      Returns:
        A `ChunkExtractor.TrackOutputProvider` to be used by the wrapped extractor.