DefaultExtractorsFactory


@UnstableApi
public final class DefaultExtractorsFactory implements ExtractorsFactory


An ExtractorsFactory that provides an array of extractors for the following formats:

Summary

Public constructors

Public methods

synchronized Extractor[]

Returns an array of new Extractor instances.

synchronized Extractor[]
createExtractors(Uri uri, Map<StringList<String>> responseHeaders)

Returns an array of new Extractor instances.

synchronized DefaultExtractorsFactory
experimentalSetTextTrackTranscodingEnabled(
    boolean textTrackTranscodingEnabled
)

Enables transcoding of text track samples to APPLICATION_MEDIA3_CUES before the data is emitted to TrackOutput.

synchronized DefaultExtractorsFactory

Sets flags for AdtsExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets flags for AmrExtractor instances created by the factory.

synchronized DefaultExtractorsFactory
@CanIgnoreReturnValue
setConstantBitrateSeekingAlwaysEnabled(
    boolean constantBitrateSeekingAlwaysEnabled
)

Convenience method to set whether approximate seeking using constant bitrate assumptions should be enabled for all extractors that support it, and if it should be enabled even if the content length (and hence the duration of the media) is unknown.

synchronized DefaultExtractorsFactory
@CanIgnoreReturnValue
setConstantBitrateSeekingEnabled(
    boolean constantBitrateSeekingEnabled
)

Convenience method to set whether approximate seeking using constant bitrate assumptions should be enabled for all extractors that support it.

synchronized DefaultExtractorsFactory

Sets flags for FlacExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets flags for FragmentedMp4Extractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets flags for JpegExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets flags for MatroskaExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets flags for Mp3Extractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets flags for Mp4Extractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets a SubtitleParser.Factory to use when transcoding text tracks.

synchronized DefaultExtractorsFactory
@CanIgnoreReturnValue
setTextTrackTranscodingEnabled(boolean textTrackTranscodingEnabled)

This method is deprecated.

Use experimentalSetTextTrackTranscodingEnabled instead.

synchronized DefaultExtractorsFactory

Sets flags for DefaultTsPayloadReaderFactorys used by TsExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets the mode for TsExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets the number of bytes searched to find a timestamp for TsExtractor instances created by the factory.

synchronized DefaultExtractorsFactory

Sets a list of subtitle formats to pass to the DefaultTsPayloadReaderFactory used by TsExtractor instances created by the factory.

Inherited Constants

From androidx.media3.extractor.ExtractorsFactory
static final ExtractorsFactory

Extractor factory that returns an empty list of extractors.

Public constructors

DefaultExtractorsFactory

public DefaultExtractorsFactory()

Public methods

createExtractors

synchronized public Extractor[] createExtractors()

Returns an array of new Extractor instances.

createExtractors

synchronized public Extractor[] createExtractors(Uri uri, Map<StringList<String>> responseHeaders)

Returns an array of new Extractor instances.

Parameters
Uri uri

The Uri of the media to extract.

Map<StringList<String>> responseHeaders

The response headers of the media to extract, or an empty map if there are none. The map lookup should be case-insensitive.

Returns
Extractor[]

The Extractor instances.

experimentalSetTextTrackTranscodingEnabled

synchronized public DefaultExtractorsFactory experimentalSetTextTrackTranscodingEnabled(
    boolean textTrackTranscodingEnabled
)

Enables transcoding of text track samples to APPLICATION_MEDIA3_CUES before the data is emitted to TrackOutput.

Transcoding is disabled by default.

This method is experimental and will be renamed or removed in a future release.

Parameters
boolean textTrackTranscodingEnabled

Whether to enable transcoding.

Returns
DefaultExtractorsFactory

The factory, for convenience.

setAdtsExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setAdtsExtractorFlags(@AdtsExtractor.Flags int flags)

Sets flags for AdtsExtractor instances created by the factory.

Parameters
@AdtsExtractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
AdtsExtractor

setAmrExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setAmrExtractorFlags(@AmrExtractor.Flags int flags)

Sets flags for AmrExtractor instances created by the factory.

Parameters
@AmrExtractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
AmrExtractor

setConstantBitrateSeekingAlwaysEnabled

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setConstantBitrateSeekingAlwaysEnabled(
    boolean constantBitrateSeekingAlwaysEnabled
)

Convenience method to set whether approximate seeking using constant bitrate assumptions should be enabled for all extractors that support it, and if it should be enabled even if the content length (and hence the duration of the media) is unknown. If set to true, the flags required to enable this functionality will be OR'd with those passed to the setters when creating extractor instances. If set to false then the flags passed to the setters will be used without modification.

When seeking into content where the length is unknown, application code should ensure that requested seek positions are valid, or should be ready to handle playback failures reported through onPlayerError with errorCode set to ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE.

Parameters
boolean constantBitrateSeekingAlwaysEnabled

Whether approximate seeking using a constant bitrate assumption should be enabled for all extractors that support it, including when the content duration is unknown.

Returns
DefaultExtractorsFactory

The factory, for convenience.

setConstantBitrateSeekingEnabled

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setConstantBitrateSeekingEnabled(
    boolean constantBitrateSeekingEnabled
)

Convenience method to set whether approximate seeking using constant bitrate assumptions should be enabled for all extractors that support it. If set to true, the flags required to enable this functionality will be OR'd with those passed to the setters when creating extractor instances. If set to false then the flags passed to the setters will be used without modification.

Parameters
boolean constantBitrateSeekingEnabled

Whether approximate seeking using a constant bitrate assumption should be enabled for all extractors that support it.

Returns
DefaultExtractorsFactory

The factory, for convenience.

setFlacExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setFlacExtractorFlags(@FlacExtractor.Flags int flags)

Sets flags for FlacExtractor instances created by the factory. The flags are also used by androidx.media3.decoder.flac.FlacExtractor instances if the FLAC extension is being used.

Parameters
@FlacExtractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
FlacExtractor

setFragmentedMp4ExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setFragmentedMp4ExtractorFlags(@FragmentedMp4Extractor.Flags int flags)

Sets flags for FragmentedMp4Extractor instances created by the factory.

Parameters
@FragmentedMp4Extractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

setJpegExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setJpegExtractorFlags(@JpegExtractor.Flags int flags)

Sets flags for JpegExtractor instances created by the factory.

Parameters
@JpegExtractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
JpegExtractor

setMatroskaExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setMatroskaExtractorFlags(@MatroskaExtractor.Flags int flags)

Sets flags for MatroskaExtractor instances created by the factory.

Parameters
@MatroskaExtractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

setMp3ExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setMp3ExtractorFlags(@Mp3Extractor.Flags int flags)

Sets flags for Mp3Extractor instances created by the factory.

Parameters
@Mp3Extractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
Mp3Extractor

setMp4ExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setMp4ExtractorFlags(@Mp4Extractor.Flags int flags)

Sets flags for Mp4Extractor instances created by the factory.

Parameters
@Mp4Extractor.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
Mp4Extractor

setSubtitleParserFactory

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)

Sets a SubtitleParser.Factory to use when transcoding text tracks.

This is only works if experimentalSetTextTrackTranscodingEnabled is enabled.

Parameters
SubtitleParser.Factory subtitleParserFactory

The factory for SubtitleParser instances.

Returns
DefaultExtractorsFactory

The factory, for convenience.

setTextTrackTranscodingEnabled

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setTextTrackTranscodingEnabled(boolean textTrackTranscodingEnabled)

setTsExtractorFlags

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setTsExtractorFlags(@DefaultTsPayloadReaderFactory.Flags int flags)

Sets flags for DefaultTsPayloadReaderFactorys used by TsExtractor instances created by the factory.

Parameters
@DefaultTsPayloadReaderFactory.Flags int flags

The flags to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
TsExtractor

setTsExtractorMode

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setTsExtractorMode(@TsExtractor.Mode int mode)

Sets the mode for TsExtractor instances created by the factory.

Parameters
@TsExtractor.Mode int mode

The mode to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
TsExtractor

setTsExtractorTimestampSearchBytes

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setTsExtractorTimestampSearchBytes(int timestampSearchBytes)

Sets the number of bytes searched to find a timestamp for TsExtractor instances created by the factory.

Parameters
int timestampSearchBytes

The number of search bytes to use.

Returns
DefaultExtractorsFactory

The factory, for convenience.

See also
TsExtractor

setTsSubtitleFormats

@CanIgnoreReturnValue
synchronized public DefaultExtractorsFactory setTsSubtitleFormats(List<Format> subtitleFormats)

Sets a list of subtitle formats to pass to the DefaultTsPayloadReaderFactory used by TsExtractor instances created by the factory.

Parameters
List<Format> subtitleFormats

The subtitle formats.

Returns
DefaultExtractorsFactory

The factory, for convenience.