Search in sources :

Example 1 with HlsPlaylistTracker

use of androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker in project media by androidx.

the class DefaultHlsPlaylistTracker method start.

// HlsPlaylistTracker implementation.
@Override
public void start(Uri initialPlaylistUri, EventDispatcher eventDispatcher, PrimaryPlaylistListener primaryPlaylistListener) {
    this.playlistRefreshHandler = Util.createHandlerForCurrentLooper();
    this.eventDispatcher = eventDispatcher;
    this.primaryPlaylistListener = primaryPlaylistListener;
    ParsingLoadable<HlsPlaylist> multivariantPlaylistLoadable = new ParsingLoadable<>(dataSourceFactory.createDataSource(C.DATA_TYPE_MANIFEST), initialPlaylistUri, C.DATA_TYPE_MANIFEST, playlistParserFactory.createPlaylistParser());
    Assertions.checkState(initialPlaylistLoader == null);
    initialPlaylistLoader = new Loader("DefaultHlsPlaylistTracker:MultivariantPlaylist");
    long elapsedRealtime = initialPlaylistLoader.startLoading(multivariantPlaylistLoadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(multivariantPlaylistLoadable.type));
    eventDispatcher.loadStarted(new LoadEventInfo(multivariantPlaylistLoadable.loadTaskId, multivariantPlaylistLoadable.dataSpec, elapsedRealtime), multivariantPlaylistLoadable.type);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo) ParsingLoadable(androidx.media3.exoplayer.upstream.ParsingLoadable) Loader(androidx.media3.exoplayer.upstream.Loader)

Example 2 with HlsPlaylistTracker

use of androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker in project media by androidx.

the class HlsMediaPeriodTest method getSteamKeys_isCompatibleWithHlsMultivariantPlaylistFilter.

@Test
public void getSteamKeys_isCompatibleWithHlsMultivariantPlaylistFilter() {
    HlsMultivariantPlaylist testMultivariantPlaylist = createMultivariantPlaylist(/* variants= */
    Arrays.asList(createAudioOnlyVariant(/* peakBitrate= */
    10000), createMuxedVideoAudioVariant(/* peakBitrate= */
    200000), createAudioOnlyVariant(/* peakBitrate= */
    300000), createMuxedVideoAudioVariant(/* peakBitrate= */
    400000), createMuxedVideoAudioVariant(/* peakBitrate= */
    600000)), /* audios= */
    Arrays.asList(createAudioRendition(/* language= */
    "spa"), createAudioRendition(/* language= */
    "ger"), createAudioRendition(/* language= */
    "tur")), /* subtitles= */
    Arrays.asList(createSubtitleRendition(/* language= */
    "spa"), createSubtitleRendition(/* language= */
    "ger"), createSubtitleRendition(/* language= */
    "tur")), /* muxedAudioFormat= */
    createAudioFormat("eng"), /* muxedCaptionFormats= */
    Arrays.asList(createSubtitleFormat("eng"), createSubtitleFormat("gsw")));
    FilterableManifestMediaPeriodFactory<HlsPlaylist> mediaPeriodFactory = (playlist, periodIndex) -> {
        HlsDataSourceFactory mockDataSourceFactory = mock(HlsDataSourceFactory.class);
        when(mockDataSourceFactory.createDataSource(anyInt())).thenReturn(mock(DataSource.class));
        HlsPlaylistTracker mockPlaylistTracker = mock(HlsPlaylistTracker.class);
        when(mockPlaylistTracker.getMultivariantPlaylist()).thenReturn((HlsMultivariantPlaylist) playlist);
        MediaPeriodId mediaPeriodId = new MediaPeriodId(/* periodUid= */
        new Object());
        return new HlsMediaPeriod(mock(HlsExtractorFactory.class), mockPlaylistTracker, mockDataSourceFactory, mock(TransferListener.class), mock(DrmSessionManager.class), new DrmSessionEventListener.EventDispatcher().withParameters(/* windowIndex= */
        0, mediaPeriodId), mock(LoadErrorHandlingPolicy.class), new MediaSourceEventListener.EventDispatcher().withParameters(/* windowIndex= */
        0, mediaPeriodId, /* mediaTimeOffsetMs= */
        0), mock(Allocator.class), mock(CompositeSequenceableLoaderFactory.class), /* allowChunklessPreparation= */
        true, HlsMediaSource.METADATA_TYPE_ID3, /* useSessionKeys= */
        false, PlayerId.UNSET);
    };
    MediaPeriodAsserts.assertGetStreamKeysAndManifestFilterIntegration(mediaPeriodFactory, testMultivariantPlaylist);
}
Also used : Arrays(java.util.Arrays) Variant(androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist.Variant) Uri(android.net.Uri) LoadErrorHandlingPolicy(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy) RunWith(org.junit.runner.RunWith) Allocator(androidx.media3.exoplayer.upstream.Allocator) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) DrmSessionManager(androidx.media3.exoplayer.drm.DrmSessionManager) HlsMultivariantPlaylist(androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist) HlsPlaylist(androidx.media3.exoplayer.hls.playlist.HlsPlaylist) DrmSessionEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) FilterableManifestMediaPeriodFactory(androidx.media3.test.utils.MediaPeriodAsserts.FilterableManifestMediaPeriodFactory) TransferListener(androidx.media3.datasource.TransferListener) MediaSourceEventListener(androidx.media3.exoplayer.source.MediaSourceEventListener) MimeTypes(androidx.media3.common.MimeTypes) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DataSource(androidx.media3.datasource.DataSource) Format(androidx.media3.common.Format) HlsPlaylistTracker(androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker) List(java.util.List) Rendition(androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist.Rendition) PlayerId(androidx.media3.exoplayer.analytics.PlayerId) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) CompositeSequenceableLoaderFactory(androidx.media3.exoplayer.source.CompositeSequenceableLoaderFactory) MediaPeriodAsserts(androidx.media3.test.utils.MediaPeriodAsserts) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) HlsPlaylistTracker(androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker) DrmSessionEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener) HlsPlaylist(androidx.media3.exoplayer.hls.playlist.HlsPlaylist) MediaSourceEventListener(androidx.media3.exoplayer.source.MediaSourceEventListener) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) HlsMultivariantPlaylist(androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist) Test(org.junit.Test)

Aggregations

Uri (android.net.Uri)1 Format (androidx.media3.common.Format)1 MimeTypes (androidx.media3.common.MimeTypes)1 DataSource (androidx.media3.datasource.DataSource)1 TransferListener (androidx.media3.datasource.TransferListener)1 PlayerId (androidx.media3.exoplayer.analytics.PlayerId)1 DrmSessionEventListener (androidx.media3.exoplayer.drm.DrmSessionEventListener)1 DrmSessionManager (androidx.media3.exoplayer.drm.DrmSessionManager)1 HlsMultivariantPlaylist (androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist)1 Rendition (androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist.Rendition)1 Variant (androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist.Variant)1 HlsPlaylist (androidx.media3.exoplayer.hls.playlist.HlsPlaylist)1 HlsPlaylistTracker (androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker)1 CompositeSequenceableLoaderFactory (androidx.media3.exoplayer.source.CompositeSequenceableLoaderFactory)1 LoadEventInfo (androidx.media3.exoplayer.source.LoadEventInfo)1 MediaPeriodId (androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)1 MediaSourceEventListener (androidx.media3.exoplayer.source.MediaSourceEventListener)1 Allocator (androidx.media3.exoplayer.upstream.Allocator)1 LoadErrorHandlingPolicy (androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy)1 Loader (androidx.media3.exoplayer.upstream.Loader)1