Search in sources :

Example 1 with DefaultDrmSessionManager

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

the class DashWidevineOfflineTest method testWidevineOfflineLicenseExpiresOnPause.

public void testWidevineOfflineLicenseExpiresOnPause() throws Exception {
    if (Util.SDK_INT < 22) {
        // Pass.
        return;
    }
    downloadLicense();
    // During playback pause until the license expires then continue playback
    Pair<Long, Long> licenseDurationRemainingSec = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId);
    long licenseDuration = licenseDurationRemainingSec.first;
    assertTrue("License duration should be less than 30 sec. " + "Server settings might have changed.", licenseDuration < 30);
    ActionSchedule schedule = new ActionSchedule.Builder(TAG).delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build();
    // DefaultDrmSessionManager should renew the license and stream play fine
    testRunner.setActionSchedule(schedule).run();
}
Also used : ActionSchedule(com.google.android.exoplayer2.playbacktests.util.ActionSchedule)

Example 2 with DefaultDrmSessionManager

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

the class DashWidevineOfflineTest method widevineOfflineLicenseExpiresOnPauseV22.

@Test
@Ignore("Needs to be reconfigured/rewritten with an offline-compatible licence [internal" + " b/176960595].")
public void widevineOfflineLicenseExpiresOnPauseV22() throws Exception {
    assumeTrue(Util.SDK_INT >= 22);
    downloadLicense();
    // During playback pause until the license expires then continue playback
    Pair<Long, Long> licenseDurationRemainingSec = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId);
    long licenseDuration = licenseDurationRemainingSec.first;
    assertWithMessage("License duration should be less than 30 sec. Server settings might have changed.").that(licenseDuration).isLessThan(30);
    ActionSchedule schedule = new ActionSchedule.Builder(TAG).waitForPlaybackState(Player.STATE_READY).delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build();
    // DefaultDrmSessionManager should renew the license and stream play fine
    testRunner.setActionSchedule(schedule).run();
}
Also used : ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) Ignore(org.junit.Ignore) Test(org.junit.Test) GtsTestUtil.shouldSkipWidevineTest(com.google.android.exoplayer2.playbacktests.gts.GtsTestUtil.shouldSkipWidevineTest)

Example 3 with DefaultDrmSessionManager

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

the class DefaultDrmSessionManagerTest method provisioningUndoneWhileManagerIsActive_deviceReprovisioned.

@Test
public void provisioningUndoneWhileManagerIsActive_deviceReprovisioned() {
    FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
    FakeExoMediaDrm mediaDrm = new FakeExoMediaDrm.Builder().setProvisionsRequired(2).build();
    DefaultDrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, new AppManagedProvider(mediaDrm)).setSessionKeepaliveMs(C.TIME_UNSET).build(/* mediaDrmCallback= */
    licenseServer);
    drmSessionManager.prepare();
    drmSessionManager.setPlayer(/* playbackLooper= */
    Looper.myLooper(), PlayerId.UNSET);
    DrmSession drmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
    null, FORMAT_WITH_DRM_INIT_DATA));
    // Confirm that opening the session threw NotProvisionedException (otherwise state would be
    // OPENED)
    assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENING);
    waitForOpenedWithKeys(drmSession);
    drmSession.release(/* eventDispatcher= */
    null);
    mediaDrm.resetProvisioning();
    drmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
    null, FORMAT_WITH_DRM_INIT_DATA));
    // Confirm that opening the session threw NotProvisionedException (otherwise state would be
    // OPENED)
    assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENING);
    waitForOpenedWithKeys(drmSession);
    assertThat(licenseServer.getReceivedProvisionRequests()).hasSize(4);
}
Also used : AppManagedProvider(com.google.android.exoplayer2.drm.ExoMediaDrm.AppManagedProvider) FakeExoMediaDrm(com.google.android.exoplayer2.testutil.FakeExoMediaDrm) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 AppManagedProvider (com.google.android.exoplayer2.drm.ExoMediaDrm.AppManagedProvider)1 GtsTestUtil.shouldSkipWidevineTest (com.google.android.exoplayer2.playbacktests.gts.GtsTestUtil.shouldSkipWidevineTest)1 ActionSchedule (com.google.android.exoplayer2.playbacktests.util.ActionSchedule)1 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)1 FakeExoMediaDrm (com.google.android.exoplayer2.testutil.FakeExoMediaDrm)1 Ignore (org.junit.Ignore)1