MediaParserChunkExtractor


@RequiresApi(value = 30)
@UnstableApi
public final class MediaParserChunkExtractor implements ChunkExtractor


ChunkExtractor implemented on top of the platform's MediaParser.

Summary

Constants

static final ChunkExtractor.Factory

Public fields

@Nullable Format[]

Public constructors

MediaParserChunkExtractor(
    @C.TrackType int primaryTrackType,
    Format manifestFormat,
    List<Format> closedCaptionFormats,
    PlayerId playerId
)

Creates a new instance.

Public methods

@Nullable ChunkIndex

Returns the ChunkIndex most recently obtained from the chunks, or null if a has not been obtained.

@Nullable Format[]

Returns the sample Formats for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks.

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

Initializes the wrapper to output to TrackOutputs provided by the specified , and configures the extractor to receive data from a new chunk.

boolean

Reads from the given ExtractorInput.

void

Releases any held resources.

Constants

FACTORY

public static final ChunkExtractor.Factory FACTORY

Public fields

sampleFormats

public @Nullable Format[] sampleFormats

Public constructors

MediaParserChunkExtractor

public MediaParserChunkExtractor(
    @C.TrackType int primaryTrackType,
    Format manifestFormat,
    List<Format> closedCaptionFormats,
    PlayerId playerId
)

Creates a new instance.

Parameters
@C.TrackType int primaryTrackType

The type of the primary track. TRACK_TYPE_NONE if there is no primary track.

Format manifestFormat

The chunks Format as obtained from the manifest.

List<Format> closedCaptionFormats

A list containing the Formats of the closed-caption tracks in the chunks.

PlayerId playerId

The PlayerId of the player this chunk extractor is used for.

Public methods

getChunkIndex

public @Nullable ChunkIndex getChunkIndex()

Returns the ChunkIndex most recently obtained from the chunks, or null if a has not been obtained.

getSampleFormats

public @Nullable Format[] getSampleFormats()

Returns the sample Formats for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks.

init

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

Initializes the wrapper to output to TrackOutputs provided by the specified , and configures the extractor to receive data from a new chunk.

Parameters
@Nullable ChunkExtractor.TrackOutputProvider trackOutputProvider

The provider of TrackOutputs that will receive sample data.

long startTimeUs

The start position in the new chunk, or TIME_UNSET to output samples from the start of the chunk.

long endTimeUs

The end position in the new chunk, or TIME_UNSET to output samples to the end of the chunk.

read

public boolean read(ExtractorInput input)

Reads from the given ExtractorInput.

Parameters
ExtractorInput input

The input to read from.

Returns
boolean

Whether there is any data left to extract. Returns false if the end of input has been reached.

Throws
java.io.IOException

If an error occurred reading from or parsing the input.

release

public void release()

Releases any held resources.