HlsMediaSource.Factory


public final class HlsMediaSource.Factory implements MediaSourceFactory


Factory for HlsMediaSources.

Summary

Public constructors

Factory(DataSource.Factory dataSourceFactory)

Creates a new factory for HlsMediaSources.

Factory(HlsDataSourceFactory hlsDataSourceFactory)

Creates a new factory for HlsMediaSources.

Public methods

HlsMediaSource

Returns a new HlsMediaSource using the current parameters.

HlsMediaSource.Factory
@CanIgnoreReturnValue
experimentalParseSubtitlesDuringExtraction(
    boolean parseSubtitlesDuringExtraction
)

Sets whether subtitles should be parsed as part of extraction (before being added to the sample queue) or as part of rendering (when being taken from the sample queue).

int[]

Returns the content types supported by media sources created by this factory.

HlsMediaSource.Factory
@CanIgnoreReturnValue
setAllowChunklessPreparation(boolean allowChunklessPreparation)

Sets whether chunkless preparation is allowed.

HlsMediaSource.Factory

Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem.

HlsMediaSource.Factory

Sets the factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).

HlsMediaSource.Factory

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem.

HlsMediaSource.Factory

Sets the factory for Extractors for the segments.

HlsMediaSource.Factory

Sets an optional LoadErrorHandlingPolicy.

HlsMediaSource.Factory

Sets the type of metadata to extract from the HLS source (defaults to METADATA_TYPE_ID3).

HlsMediaSource.Factory

Sets the factory from which playlist parsers will be obtained.

HlsMediaSource.Factory

Sets the HlsPlaylistTracker factory.

HlsMediaSource.Factory

Sets the SubtitleParser.Factory to be used for parsing subtitles during extraction if experimentalParseSubtitlesDuringExtraction is enabled.

HlsMediaSource.Factory
@CanIgnoreReturnValue
setTimestampAdjusterInitializationTimeoutMs(
    long timestampAdjusterInitializationTimeoutMs
)

Sets the timeout for the loading thread to wait for the timestamp adjuster to initialize, in milliseconds.The default value is zero, which is interpreted as an infinite timeout.

HlsMediaSource.Factory
@CanIgnoreReturnValue
setUseSessionKeys(boolean useSessionKeys)

Sets whether to use #EXT-X-SESSION-KEY tags provided in the multivariant playlist.

Public constructors

Factory

public Factory(DataSource.Factory dataSourceFactory)

Creates a new factory for HlsMediaSources.

The factory will use the following default components:

Parameters
DataSource.Factory dataSourceFactory

A data source factory that will be wrapped by a to create DataSources for manifests, segments and keys.

Factory

public Factory(HlsDataSourceFactory hlsDataSourceFactory)

Creates a new factory for HlsMediaSources.

The factory will use the following default components:

Parameters
HlsDataSourceFactory hlsDataSourceFactory

An HlsDataSourceFactory for DataSources for manifests, segments and keys.

Public methods

createMediaSource

public HlsMediaSource createMediaSource(MediaItem mediaItem)

Returns a new HlsMediaSource using the current parameters.

Parameters
MediaItem mediaItem

The MediaItem.

Returns
HlsMediaSource

The new HlsMediaSource.

experimentalParseSubtitlesDuringExtraction

@CanIgnoreReturnValue
public HlsMediaSource.Factory experimentalParseSubtitlesDuringExtraction(
    boolean parseSubtitlesDuringExtraction
)

Sets whether subtitles should be parsed as part of extraction (before being added to the sample queue) or as part of rendering (when being taken from the sample queue). Defaults to false (i.e. subtitles will be parsed as part of rendering).

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

Parameters
boolean parseSubtitlesDuringExtraction

Whether to parse subtitles during extraction or rendering.

Returns
HlsMediaSource.Factory

This factory, for convenience.

getSupportedTypes

@C.ContentType
public int[] getSupportedTypes()

Returns the content types supported by media sources created by this factory.

setAllowChunklessPreparation

@CanIgnoreReturnValue
public HlsMediaSource.Factory setAllowChunklessPreparation(boolean allowChunklessPreparation)

Sets whether chunkless preparation is allowed. If true, preparation without chunk downloads will be enabled for streams that provide sufficient information in their multivariant playlist.

Parameters
boolean allowChunklessPreparation

Whether chunkless preparation is allowed.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setCmcdConfigurationFactory

@CanIgnoreReturnValue
public HlsMediaSource.Factory setCmcdConfigurationFactory(
    CmcdConfiguration.Factory cmcdConfigurationFactory
)

Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setCompositeSequenceableLoaderFactory

@CanIgnoreReturnValue
public HlsMediaSource.Factory setCompositeSequenceableLoaderFactory(
    CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory
)

Sets the factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).

Parameters
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory

A factory to create composite s for when this media source loads data from multiple streams (video, audio etc...).

Returns
HlsMediaSource.Factory

This factory, for convenience.

setDrmSessionManagerProvider

@CanIgnoreReturnValue
public HlsMediaSource.Factory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setExtractorFactory

@CanIgnoreReturnValue
public HlsMediaSource.Factory setExtractorFactory(@Nullable HlsExtractorFactory extractorFactory)

Sets the factory for Extractors for the segments. The default value is DEFAULT.

Parameters
@Nullable HlsExtractorFactory extractorFactory

An HlsExtractorFactory for Extractors for the segments.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
public HlsMediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setMetadataType

@CanIgnoreReturnValue
public HlsMediaSource.Factory setMetadataType(@HlsMediaSource.MetadataType int metadataType)

Sets the type of metadata to extract from the HLS source (defaults to METADATA_TYPE_ID3).

HLS supports in-band ID3 in both TS and fMP4 streams, but in the fMP4 case the data is wrapped in an EMSG box [spec].

If this is set to METADATA_TYPE_ID3 then raw ID3 metadata of will be extracted from TS sources. From fMP4 streams EMSGs containing metadata of this type (in the variant stream only) will be unwrapped to expose the inner data. All other in-band metadata will be dropped.

If this is set to METADATA_TYPE_EMSG then all EMSG data from the fMP4 variant stream will be extracted. No metadata will be extracted from TS streams, since they don't support EMSG.

Parameters
@HlsMediaSource.MetadataType int metadataType

The type of metadata to extract.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setPlaylistParserFactory

@CanIgnoreReturnValue
public HlsMediaSource.Factory setPlaylistParserFactory(
    HlsPlaylistParserFactory playlistParserFactory
)

Sets the factory from which playlist parsers will be obtained.

Parameters
HlsPlaylistParserFactory playlistParserFactory

An HlsPlaylistParserFactory.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setPlaylistTrackerFactory

@CanIgnoreReturnValue
public HlsMediaSource.Factory setPlaylistTrackerFactory(
    HlsPlaylistTracker.Factory playlistTrackerFactory
)

Sets the HlsPlaylistTracker factory.

Parameters
HlsPlaylistTracker.Factory playlistTrackerFactory

A factory for HlsPlaylistTracker instances.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setSubtitleParserFactory

@CanIgnoreReturnValue
public HlsMediaSource.Factory setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)

Sets the SubtitleParser.Factory to be used for parsing subtitles during extraction if experimentalParseSubtitlesDuringExtraction is enabled.

Parameters
SubtitleParser.Factory subtitleParserFactory

The SubtitleParser.Factory for parsing subtitles during extraction.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setTimestampAdjusterInitializationTimeoutMs

@CanIgnoreReturnValue
public HlsMediaSource.Factory setTimestampAdjusterInitializationTimeoutMs(
    long timestampAdjusterInitializationTimeoutMs
)

Sets the timeout for the loading thread to wait for the timestamp adjuster to initialize, in milliseconds.The default value is zero, which is interpreted as an infinite timeout.

Parameters
long timestampAdjusterInitializationTimeoutMs

The timeout in milliseconds. A timeout of zero is interpreted as an infinite timeout.

Returns
HlsMediaSource.Factory

This factory, for convenience.

setUseSessionKeys

@CanIgnoreReturnValue
public HlsMediaSource.Factory setUseSessionKeys(boolean useSessionKeys)

Sets whether to use #EXT-X-SESSION-KEY tags provided in the multivariant playlist. If enabled, it's assumed that any single session key declared in the multivariant playlist can be used to obtain all of the keys required for playback. For media where this is not true, this option should not be enabled.

Parameters
boolean useSessionKeys

Whether to use #EXT-X-SESSION-KEY tags.

Returns
HlsMediaSource.Factory

This factory, for convenience.