private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
private byte[] blockingKeyRequest(@Mode int licenseMode, byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { DrmSession<T> drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = drmSession.getError(); byte[] keySetId = drmSession.getOfflineLicenseKeySetId(); drmSessionManager.releaseSession(drmSession); if (error != null) { throw error; } return keySetId; }
/** * Returns license and playback durations remaining in seconds. * * @param drmSession The drm session to query. * @return A {@link Pair} consisting of the remaining license and playback durations in seconds, * or null if called before the session has been opened or after it's been released. */ public static Pair<Long, Long> getLicenseDurationRemainingSec(DrmSession<?> drmSession) { Map<String, String> keyStatus = drmSession.queryKeyStatus(); if (keyStatus == null) { return null; } return new Pair<>(getDurationRemainingSec(keyStatus, PROPERTY_LICENSE_DURATION_REMAINING), getDurationRemainingSec(keyStatus, PROPERTY_PLAYBACK_DURATION_REMAINING)); }
boolean drmSessionRequiresSecureDecoder = false; if (drmSession != null) { FrameworkMediaCrypto mediaCrypto = drmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = drmSession.getError(); if (drmError != null) { @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } else if (drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS) {
ExoMediaCrypto mediaCrypto = null; if (drmSession != null) { mediaCrypto = drmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = drmSession.getError(); if (drmError != null) {
/** * Returns the remaining license and playback durations in seconds, for an offline license. * * @param offlineLicenseKeySetId The key set id of the license. * @return The remaining license and playback durations, in seconds. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest(DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, null); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return licenseDurationRemainingSec; }
ExoMediaCrypto mediaCrypto = null; if (drmSession != null) { mediaCrypto = drmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = drmSession.getError(); if (drmError != null) {
private void notifyErrorListener(DrmSession<FrameworkMediaCrypto> drmSession) { final DrmSession.DrmSessionException error = drmSession.getError(); handler.post(new Runnable() { @Override public void run() { eventListener.onDrmSessionManagerError(error); } }); }
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @Test public void givenOpeningSessionError_whenAcquiringSession_thenReturnsInvalidDrmSession() throws MediaDrmException { ResourceBusyException resourceBusyException = new ResourceBusyException("resource is busy"); given(mediaDrm.openSession()).willThrow(resourceBusyException); DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA); assertThat(drmSession).isInstanceOf(InvalidDrmSession.class); assertThat(drmSession.getError().getCause()).isEqualTo(resourceBusyException); }
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }