use of com.google.android.exoplayer2.testutil.FakeExoMediaDrm in project ExoPlayer by google.
the class DefaultDrmSessionManagerTest method managerRelease_keepaliveDisabled_doesntReleaseAnySessions.
@Test(timeout = 10_000)
public void managerRelease_keepaliveDisabled_doesntReleaseAnySessions() throws Exception {
FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).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));
waitForOpenedWithKeys(drmSession);
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENED_WITH_KEYS);
// Release the manager, the session should still be open (though it's unusable because
// the underlying ExoMediaDrm is released).
drmSessionManager.release();
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENED_WITH_KEYS);
}
use of com.google.android.exoplayer2.testutil.FakeExoMediaDrm in project ExoPlayer by google.
the class DefaultDrmSessionManagerTest method keepaliveDisabled_sessionsReleasedImmediately.
@Test(timeout = 10_000)
public void keepaliveDisabled_sessionsReleasedImmediately() throws Exception {
FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).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));
waitForOpenedWithKeys(drmSession);
drmSession.release(/* eventDispatcher= */
null);
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_RELEASED);
}
use of com.google.android.exoplayer2.testutil.FakeExoMediaDrm in project ExoPlayer by google.
the class DefaultDrmSessionManagerTest method managerRelease_allKeepaliveSessionsImmediatelyReleased.
@Test(timeout = 10_000)
public void managerRelease_allKeepaliveSessionsImmediatelyReleased() throws Exception {
FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).setSessionKeepaliveMs(10_000).build(/* mediaDrmCallback= */
licenseServer);
drmSessionManager.prepare();
drmSessionManager.setPlayer(/* playbackLooper= */
Looper.myLooper(), PlayerId.UNSET);
DrmSession drmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
null, FORMAT_WITH_DRM_INIT_DATA));
waitForOpenedWithKeys(drmSession);
drmSession.release(/* eventDispatcher= */
null);
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENED_WITH_KEYS);
drmSessionManager.release();
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_RELEASED);
}
use of com.google.android.exoplayer2.testutil.FakeExoMediaDrm in project ExoPlayer by google.
the class DefaultDrmSessionManagerTest method sessionReacquired_keepaliveTimeOutCancelled.
@Test(timeout = 10_000)
public void sessionReacquired_keepaliveTimeOutCancelled() throws Exception {
FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).setSessionKeepaliveMs(10_000).build(/* mediaDrmCallback= */
licenseServer);
drmSessionManager.prepare();
drmSessionManager.setPlayer(/* playbackLooper= */
Looper.myLooper(), PlayerId.UNSET);
DrmSession firstDrmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
null, FORMAT_WITH_DRM_INIT_DATA));
waitForOpenedWithKeys(firstDrmSession);
firstDrmSession.release(/* eventDispatcher= */
null);
ShadowLooper.idleMainLooper(5, SECONDS);
// Acquire a session for the same init data 5s in to the 10s timeout (so expect the same
// instance).
DrmSession secondDrmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
null, FORMAT_WITH_DRM_INIT_DATA));
assertThat(secondDrmSession).isSameInstanceAs(firstDrmSession);
// Let the timeout definitely expire, and check the session didn't get released.
ShadowLooper.idleMainLooper(10, SECONDS);
assertThat(secondDrmSession.getState()).isEqualTo(DrmSession.STATE_OPENED_WITH_KEYS);
}
use of com.google.android.exoplayer2.testutil.FakeExoMediaDrm in project ExoPlayer by google.
the class DefaultDrmSessionManagerTest method preacquireSession_releaseBeforeUnderlyingAcquisitionCompletesReleasesSessionOnceAcquired.
@Test(timeout = 10_000)
public void preacquireSession_releaseBeforeUnderlyingAcquisitionCompletesReleasesSessionOnceAcquired() throws Exception {
FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).setSessionKeepaliveMs(C.TIME_UNSET).build(/* mediaDrmCallback= */
licenseServer);
drmSessionManager.prepare();
drmSessionManager.setPlayer(/* playbackLooper= */
Looper.myLooper(), PlayerId.UNSET);
DrmSessionReference sessionReference = drmSessionManager.preacquireSession(/* eventDispatcher= */
null, FORMAT_WITH_DRM_INIT_DATA);
// Release the pre-acquired reference before the underlying session has had a chance to be
// constructed.
sessionReference.release();
// Acquiring the same session triggers a second key load (because the pre-acquired session was
// fully released).
DrmSession drmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
null, FORMAT_WITH_DRM_INIT_DATA));
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENED);
waitForOpenedWithKeys(drmSession);
drmSession.release(/* eventDispatcher= */
null);
assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_RELEASED);
}
Aggregations