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);
}
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);
}
Aggregations