MediaParserHlsMediaChunkExtractor


@RequiresApi(value = 30)
@UnstableApi
class MediaParserHlsMediaChunkExtractor : HlsMediaChunkExtractor


HlsMediaChunkExtractor implemented on top of the platform's MediaParser.

Summary

Constants

const HlsExtractorFactory!

HlsExtractorFactory implementation that produces for all container formats except WebVTT, for which a is returned.

Public constructors

MediaParserHlsMediaChunkExtractor(
    mediaParser: MediaParser!,
    outputConsumerAdapter: OutputConsumerAdapterV30!,
    format: Format!,
    overrideInBandCaptionDeclarations: Boolean,
    muxedCaptionMediaFormats: ImmutableList<MediaFormat!>!,
    leadingBytesToSkip: Int,
    playerId: PlayerId!
)

Creates a new instance.

Public functions

Unit
init(extractorOutput: ExtractorOutput!)

Initializes the extractor with an ExtractorOutput.

Boolean

Returns whether this is a packed audio extractor, as defined in RFC 8216, Section 3.4.

Boolean

Returns whether this instance can be used for extracting multiple continuous segments.

Unit

Resets the sample parsing state.

Boolean
read(extractorInput: ExtractorInput!)

Extracts data read from a provided ExtractorInput.

HlsMediaChunkExtractor!

Returns a new instance for extracting the same type of media as this one.

Constants

FACTORY

const val FACTORYHlsExtractorFactory!

HlsExtractorFactory implementation that produces for all container formats except WebVTT, for which a is returned.

Public constructors

MediaParserHlsMediaChunkExtractor

MediaParserHlsMediaChunkExtractor(
    mediaParser: MediaParser!,
    outputConsumerAdapter: OutputConsumerAdapterV30!,
    format: Format!,
    overrideInBandCaptionDeclarations: Boolean,
    muxedCaptionMediaFormats: ImmutableList<MediaFormat!>!,
    leadingBytesToSkip: Int,
    playerId: PlayerId!
)

Creates a new instance.

Parameters
mediaParser: MediaParser!

The MediaParser instance to use for extraction of segments. The provided instance must have completed sniffing, or must have been created by name.

outputConsumerAdapter: OutputConsumerAdapterV30!

The OutputConsumerAdapterV30 with which mediaParser was created.

format: Format!

The Format associated with the segment.

overrideInBandCaptionDeclarations: Boolean

Whether to ignore any in-band caption track declarations in favor of using the muxedCaptionMediaFormats instead. If false, caption declarations found in the extracted media will be used, causing muxedCaptionMediaFormats to be ignored instead.

muxedCaptionMediaFormats: ImmutableList<MediaFormat!>!

The list of in-band caption MediaFormats that MediaParser should expose.

leadingBytesToSkip: Int

The number of bytes to skip from the start of the input before starting extraction.

playerId: PlayerId!

The PlayerId of the player using this chunk extractor.

Public functions

init

fun init(extractorOutput: ExtractorOutput!): Unit

Initializes the extractor with an ExtractorOutput. Called at most once.

Parameters
extractorOutput: ExtractorOutput!

An ExtractorOutput to receive extracted data.

isPackedAudioExtractor

fun isPackedAudioExtractor(): Boolean

Returns whether this is a packed audio extractor, as defined in RFC 8216, Section 3.4.

isReusable

fun isReusable(): Boolean

Returns whether this instance can be used for extracting multiple continuous segments.

onTruncatedSegmentParsed

fun onTruncatedSegmentParsed(): Unit

Resets the sample parsing state.

Resetting the parsing state allows support for Fragmented MP4 EXT-X-I-FRAME-STREAM-INF segments. EXT-X-I-FRAME-STREAM-INF segments are truncated to include only a leading key frame. After parsing said keyframe, an extractor may reach an unexpected end of file. By resetting its state, we can continue feeding samples from the following segments to the extractor. See #7512 for context.

read

fun read(extractorInput: ExtractorInput!): Boolean

Extracts data read from a provided ExtractorInput. Must not be called before init.

A single call to this method will block until some progress has been made, but will not block for longer than this. Hence each call will consume only a small amount of input data.

When this method throws an IOException, extraction may continue by providing an ExtractorInput with an unchanged read position to a subsequent call to this method.

Parameters
extractorInput: ExtractorInput!

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.

recreate

fun recreate(): HlsMediaChunkExtractor!

Returns a new instance for extracting the same type of media as this one. Can only be called on instances that are not reusable.