Search in sources :

Example 56 with DrmSessionManager

use of com.google.android.exoplayer2.drm.DrmSessionManager in project ExoPlayer by google.

the class ExoPlayerTest method internalDiscontinuityAtInitialPosition.

@Test
public void internalDiscontinuityAtInitialPosition() throws Exception {
    FakeTimeline timeline = new FakeTimeline();
    FakeMediaSource mediaSource = new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {

        @Override
        protected MediaPeriod createMediaPeriod(MediaPeriodId id, TrackGroupArray trackGroupArray, Allocator allocator, MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher, DrmSessionManager drmSessionManager, DrmSessionEventListener.EventDispatcher drmEventDispatcher, @Nullable TransferListener transferListener) {
            FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, allocator, TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US, mediaSourceEventDispatcher);
            // Set a discontinuity at the position this period is supposed to start at anyway.
            mediaPeriod.setDiscontinuityPositionUs(timeline.getWindow(/* windowIndex= */
            0, new Window()).positionInFirstPeriodUs);
            return mediaPeriod;
        }
    };
    ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder(context).setMediaSources(mediaSource).build().start().blockUntilEnded(TIMEOUT_MS);
    // If the position is unchanged we do not expect the discontinuity to be reported externally.
    testRunner.assertNoPositionDiscontinuities();
}
Also used : TransferListener(com.google.android.exoplayer2.upstream.TransferListener) Window(com.google.android.exoplayer2.Timeline.Window) Allocator(com.google.android.exoplayer2.upstream.Allocator) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) FakeMediaPeriod(com.google.android.exoplayer2.testutil.FakeMediaPeriod) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) ExoPlayerTestRunner(com.google.android.exoplayer2.testutil.ExoPlayerTestRunner) Nullable(androidx.annotation.Nullable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)33 DrmSessionManager (com.google.android.exoplayer2.drm.DrmSessionManager)20 FakeExoMediaDrm (com.google.android.exoplayer2.testutil.FakeExoMediaDrm)17 Nullable (androidx.annotation.Nullable)16 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)16 MediaSource (com.google.android.exoplayer2.source.MediaSource)15 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)14 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)12 FakeMediaPeriod (com.google.android.exoplayer2.testutil.FakeMediaPeriod)12 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)12 Allocator (com.google.android.exoplayer2.upstream.Allocator)12 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)12 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)11 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)10 Format (com.google.android.exoplayer2.Format)9 AppManagedProvider (com.google.android.exoplayer2.drm.ExoMediaDrm.AppManagedProvider)7 Util (com.google.android.exoplayer2.util.Util)7 Intent (android.content.Intent)6 Uri (android.net.Uri)6 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)6