Search in sources :

Example 1 with HlsMultivariantPlaylist

use of com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist in project ExoPlayer by google.

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 : HlsPlaylistTracker(com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Arrays(java.util.Arrays) Uri(android.net.Uri) RunWith(org.junit.runner.RunWith) CompositeSequenceableLoaderFactory(com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Rendition(com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist.Rendition) Format(com.google.android.exoplayer2.Format) PlayerId(com.google.android.exoplayer2.analytics.PlayerId) DrmSessionEventListener(com.google.android.exoplayer2.drm.DrmSessionEventListener) MimeTypes(com.google.android.exoplayer2.util.MimeTypes) HlsPlaylist(com.google.android.exoplayer2.source.hls.playlist.HlsPlaylist) Variant(com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist.Variant) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) MediaSourceEventListener(com.google.android.exoplayer2.source.MediaSourceEventListener) Allocator(com.google.android.exoplayer2.upstream.Allocator) TransferListener(com.google.android.exoplayer2.upstream.TransferListener) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DataSource(com.google.android.exoplayer2.upstream.DataSource) MediaPeriodAsserts(com.google.android.exoplayer2.testutil.MediaPeriodAsserts) List(java.util.List) HlsMultivariantPlaylist(com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist) LoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy) FilterableManifestMediaPeriodFactory(com.google.android.exoplayer2.testutil.MediaPeriodAsserts.FilterableManifestMediaPeriodFactory) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) HlsPlaylistTracker(com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker) DrmSessionEventListener(com.google.android.exoplayer2.drm.DrmSessionEventListener) HlsPlaylist(com.google.android.exoplayer2.source.hls.playlist.HlsPlaylist) MediaSourceEventListener(com.google.android.exoplayer2.source.MediaSourceEventListener) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) HlsMultivariantPlaylist(com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist) Test(org.junit.Test)

Example 2 with HlsMultivariantPlaylist

use of com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist in project ExoPlayer by google.

the class HlsMultivariantPlaylistParserTest method parseMultivariantPlaylist_withCc_cCIdPropagated.

@Test
public void parseMultivariantPlaylist_withCc_cCIdPropagated() throws IOException {
    HlsMultivariantPlaylist playlist = parseMultivariantPlaylist(PLAYLIST_URI, PLAYLIST_WITH_CC);
    Format firstTextFormat = playlist.muxedCaptionFormats.get(0);
    assertThat(firstTextFormat.id).isEqualTo("cc1:Eng");
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Example 3 with HlsMultivariantPlaylist

use of com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist in project ExoPlayer by google.

the class HlsMultivariantPlaylistParserTest method parseMultivariantPlaylist_withVariableSubstitution_success.

@Test
public void parseMultivariantPlaylist_withVariableSubstitution_success() throws IOException {
    HlsMultivariantPlaylist playlistWithSubstitutions = parseMultivariantPlaylist(PLAYLIST_URI, PLAYLIST_WITH_VARIABLE_SUBSTITUTION);
    HlsMultivariantPlaylist.Variant variant = playlistWithSubstitutions.variants.get(0);
    assertThat(variant.format.codecs).isEqualTo("mp4a.40.5");
    assertThat(variant.url).isEqualTo(Uri.parse("http://example.com/This/{$nested}/reference/shouldnt/work"));
}
Also used : Variant(com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist.Variant) Test(org.junit.Test)

Example 4 with HlsMultivariantPlaylist

use of com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist in project ExoPlayer by google.

the class HlsMultivariantPlaylistParserTest method parseMultivariantPlaylist_withAudio_audioIdPropagated.

@Test
public void parseMultivariantPlaylist_withAudio_audioIdPropagated() throws IOException {
    HlsMultivariantPlaylist playlist = parseMultivariantPlaylist(PLAYLIST_URI, PLAYLIST_WITH_AUDIO_MEDIA_TAG);
    Format firstAudioFormat = playlist.audios.get(0).format;
    assertThat(firstAudioFormat.id).isEqualTo("aud1:English");
    Format secondAudioFormat = playlist.audios.get(1).format;
    assertThat(secondAudioFormat.id).isEqualTo("aud2:English");
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Example 5 with HlsMultivariantPlaylist

use of com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist in project ExoPlayer by google.

the class HlsMultivariantPlaylistParserTest method parseMultivariantPlaylist_withAudio_codecPropagated.

@Test
public void parseMultivariantPlaylist_withAudio_codecPropagated() throws IOException {
    HlsMultivariantPlaylist playlist = parseMultivariantPlaylist(PLAYLIST_URI, PLAYLIST_WITH_AUDIO_MEDIA_TAG);
    Format firstAudioFormat = playlist.audios.get(0).format;
    assertThat(firstAudioFormat.codecs).isEqualTo("mp4a.40.2");
    assertThat(firstAudioFormat.sampleMimeType).isEqualTo(MimeTypes.AUDIO_AAC);
    Format secondAudioFormat = playlist.audios.get(1).format;
    assertThat(secondAudioFormat.codecs).isEqualTo("ac-3");
    assertThat(secondAudioFormat.sampleMimeType).isEqualTo(MimeTypes.AUDIO_AC3);
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Aggregations

Format (com.google.android.exoplayer2.Format)9 Test (org.junit.Test)9 Variant (com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist.Variant)6 ArrayList (java.util.ArrayList)6 Uri (android.net.Uri)5 HlsMultivariantPlaylist (com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist)4 Nullable (androidx.annotation.Nullable)3 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)3 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)3 Rendition (com.google.android.exoplayer2.source.hls.playlist.HlsMultivariantPlaylist.Rendition)3 SchemeData (com.google.android.exoplayer2.drm.DrmInitData.SchemeData)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)1 PlayerId (com.google.android.exoplayer2.analytics.PlayerId)1 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)1 DrmSessionManager (com.google.android.exoplayer2.drm.DrmSessionManager)1 Metadata (com.google.android.exoplayer2.metadata.Metadata)1 StreamKey (com.google.android.exoplayer2.offline.StreamKey)1 CompositeSequenceableLoaderFactory (com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory)1