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

## Class MediaParserChunkExtractor

- java.lang.Object
- - com.google.android.exoplayer2.source.chunk.MediaParserChunkExtractor

- All Implemented Interfaces:
    `ChunkExtractor`

      public final class MediaParserChunkExtractor
      extends Object
      implements ChunkExtractor

  `ChunkExtractor` implemented on top of the platform's `MediaParser`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.chunk.ChunkExtractor

      `ChunkExtractor.Factory, ChunkExtractor.TrackOutputProvider`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static ChunkExtractor.Factory` | `FACTORY` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MediaParserChunkExtractor​(int primaryTrackType, Format manifestFormat, List<Format> closedCaptionFormats)` | Creates a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ChunkIndex` | `getChunkIndex()` | Returns the `ChunkIndex` most recently obtained from the chunks, or null if a `ChunkIndex` has not been obtained.
    `Format[]` | `getSampleFormats()` | Returns the sample `Format`s for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks.
    `void` | `init​(ChunkExtractor.TrackOutputProvider trackOutputProvider, long startTimeUs, long endTimeUs)` | Initializes the wrapper to output to `TrackOutput`s provided by the specified `ChunkExtractor.TrackOutputProvider`, and configures the extractor to receive data from a new chunk.
    `boolean` | `read​(ExtractorInput extractorInput)` | Reads from the given `ExtractorInput`.
    `void` | `release()` | Releases any held resources.

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

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

- - ### Field Detail

    - #### FACTORY

          public static final ChunkExtractor.Factory FACTORY

  - ### Constructor Detail

    - #### MediaParserChunkExtractor

          public MediaParserChunkExtractor​(int primaryTrackType,
                                           Format manifestFormat,
                                           List<Format> closedCaptionFormats)

      Creates a new instance.
      Parameters:
        `primaryTrackType` - The type of the primary track, or `C.TRACK_TYPE_NONE` if there is no primary track. Must be one of the `C.TRACK_TYPE_*` constants.
        `manifestFormat` - The chunks `Format` as obtained from the manifest.
        `closedCaptionFormats` - A list containing the `Formats` of the closed-caption tracks in the chunks.

  - ### Method Detail

    - #### init

          public void init​(@Nullable
                           ChunkExtractor.TrackOutputProvider trackOutputProvider,
                           long startTimeUs,
                           long endTimeUs)

      Description copied from interface: `ChunkExtractor`
      Initializes the wrapper to output to `TrackOutput`s provided by the specified `ChunkExtractor.TrackOutputProvider`, and configures the extractor to receive data from a new chunk.
      Specified by:
        `init` in interface `ChunkExtractor`
      Parameters:
        `trackOutputProvider` - The provider of `TrackOutput`s that will receive sample data.
        `startTimeUs` - The start position in the new chunk, or `C.TIME_UNSET` to output samples from the start of the chunk.
        `endTimeUs` - The end position in the new chunk, or `C.TIME_UNSET` to output samples to the end of the chunk.

    - #### release

          public void release()

      Description copied from interface: `ChunkExtractor`
      Releases any held resources.
      Specified by:
        `release` in interface `ChunkExtractor`

    - #### read

          public boolean read​(ExtractorInput extractorInput)
                       throws IOException

      Description copied from interface: `ChunkExtractor`
      Reads from the given `ExtractorInput`.
      Specified by:
        `read` in interface `ChunkExtractor`
      Parameters:
        `extractorInput` - The input to read from.
      Returns:
        Whether there is any data left to extract. Returns false if the end of input has been reached.
      Throws:
        `IOException` - If an error occurred reading from or parsing the input.

    - #### getChunkIndex

          @Nullable
          public ChunkIndex getChunkIndex()

      Description copied from interface: `ChunkExtractor`
      Returns the `ChunkIndex` most recently obtained from the chunks, or null if a `ChunkIndex` has not been obtained.
      Specified by:
        `getChunkIndex` in interface `ChunkExtractor`

    - #### getSampleFormats

          @Nullable
          public Format[] getSampleFormats()

      Description copied from interface: `ChunkExtractor`
      Returns the sample `Format`s for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks.
      Specified by:
        `getSampleFormats` in interface `ChunkExtractor`