Search in sources :

Example 6 with DrmSessionException

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

the class DecoderVideoRenderer method maybeInitDecoder.

private void maybeInitDecoder() throws ExoPlaybackException {
    if (decoder != null) {
        return;
    }
    setDecoderDrmSession(sourceDrmSession);
    CryptoConfig cryptoConfig = null;
    if (decoderDrmSession != null) {
        cryptoConfig = decoderDrmSession.getCryptoConfig();
        if (cryptoConfig == null) {
            DrmSessionException drmError = decoderDrmSession.getError();
            if (drmError != null) {
            // Continue for now. We may be able to avoid failure if a new input format causes the
            // session to be replaced without it having been used.
            } else {
                // The drm session isn't open yet.
                return;
            }
        }
    }
    try {
        long decoderInitializingTimestamp = SystemClock.elapsedRealtime();
        decoder = createDecoder(inputFormat, cryptoConfig);
        setDecoderOutputMode(outputMode);
        long decoderInitializedTimestamp = SystemClock.elapsedRealtime();
        eventDispatcher.decoderInitialized(decoder.getName(), decoderInitializedTimestamp, decoderInitializedTimestamp - decoderInitializingTimestamp);
        decoderCounters.decoderInitCount++;
    } catch (DecoderException e) {
        Log.e(TAG, "Video codec error", e);
        eventDispatcher.videoCodecError(e);
        throw createRendererException(e, inputFormat, PlaybackException.ERROR_CODE_DECODER_INIT_FAILED);
    } catch (OutOfMemoryError e) {
        throw createRendererException(e, inputFormat, PlaybackException.ERROR_CODE_DECODER_INIT_FAILED);
    }
}
Also used : DecoderException(com.google.android.exoplayer2.decoder.DecoderException) DrmSessionException(com.google.android.exoplayer2.drm.DrmSession.DrmSessionException) CryptoConfig(com.google.android.exoplayer2.decoder.CryptoConfig)

Example 7 with DrmSessionException

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

the class OfflineLicenseHelper method blockingKeyRequest.

private void blockingKeyRequest(@Mode int licenseMode, byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException {
    DrmSession<T> session = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData);
    DrmSessionException error = session.getError();
    if (error != null) {
        throw error;
    }
    drmSessionManager.releaseSession(session);
}
Also used : DrmSessionException(com.google.android.exoplayer2.drm.DrmSession.DrmSessionException)

Example 8 with DrmSessionException

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

the class MediaCodecRenderer method maybeInitCodecOrBypass.

protected final void maybeInitCodecOrBypass() throws ExoPlaybackException {
    if (codec != null || bypassEnabled || inputFormat == null) {
        // We have a codec, are bypassing it, or don't have a format to decide how to render.
        return;
    }
    if (sourceDrmSession == null && shouldUseBypass(inputFormat)) {
        initBypass(inputFormat);
        return;
    }
    setCodecDrmSession(sourceDrmSession);
    String mimeType = inputFormat.sampleMimeType;
    if (codecDrmSession != null) {
        if (mediaCrypto == null) {
            @Nullable FrameworkCryptoConfig sessionCryptoConfig = getFrameworkCryptoConfig(codecDrmSession);
            if (sessionCryptoConfig == null) {
                @Nullable DrmSessionException drmError = codecDrmSession.getError();
                if (drmError != null) {
                // Continue for now. We may be able to avoid failure if a new input format causes the
                // session to be replaced without it having been used.
                } else {
                    // The drm session isn't open yet.
                    return;
                }
            } else {
                try {
                    mediaCrypto = new MediaCrypto(sessionCryptoConfig.uuid, sessionCryptoConfig.sessionId);
                } catch (MediaCryptoException e) {
                    throw createRendererException(e, inputFormat, PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR);
                }
                mediaCryptoRequiresSecureDecoder = !sessionCryptoConfig.forceAllowInsecureDecoderComponents && mediaCrypto.requiresSecureDecoderComponent(mimeType);
            }
        }
        if (FrameworkCryptoConfig.WORKAROUND_DEVICE_NEEDS_KEYS_TO_CONFIGURE_CODEC) {
            @DrmSession.State int drmSessionState = codecDrmSession.getState();
            if (drmSessionState == DrmSession.STATE_ERROR) {
                DrmSessionException drmSessionException = Assertions.checkNotNull(codecDrmSession.getError());
                throw createRendererException(drmSessionException, inputFormat, drmSessionException.errorCode);
            } else if (drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS) {
                // Wait for keys.
                return;
            }
        }
    }
    try {
        maybeInitCodecWithFallback(mediaCrypto, mediaCryptoRequiresSecureDecoder);
    } catch (DecoderInitializationException e) {
        throw createRendererException(e, inputFormat, PlaybackException.ERROR_CODE_DECODER_INIT_FAILED);
    }
}
Also used : DrmSessionException(com.google.android.exoplayer2.drm.DrmSession.DrmSessionException) FrameworkCryptoConfig(com.google.android.exoplayer2.drm.FrameworkCryptoConfig) Nullable(androidx.annotation.Nullable) MediaCrypto(android.media.MediaCrypto) MediaCryptoException(android.media.MediaCryptoException)

Example 9 with DrmSessionException

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

the class OfflineLicenseHelper method blockingKeyRequest.

private byte[] blockingKeyRequest(@Mode int licenseMode, @Nullable byte[] offlineLicenseKeySetId, Format format) throws DrmSessionException {
    drmSessionManager.setPlayer(handlerThread.getLooper(), PlayerId.UNSET);
    drmSessionManager.prepare();
    DrmSession drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, format);
    DrmSessionException error = drmSession.getError();
    byte[] keySetId = drmSession.getOfflineLicenseKeySetId();
    drmSession.release(eventDispatcher);
    drmSessionManager.release();
    if (error != null) {
        throw error;
    }
    return Assertions.checkNotNull(keySetId);
}
Also used : DrmSessionException(com.google.android.exoplayer2.drm.DrmSession.DrmSessionException)

Aggregations

DrmSessionException (com.google.android.exoplayer2.drm.DrmSession.DrmSessionException)7 Nullable (androidx.annotation.Nullable)3 CryptoConfig (com.google.android.exoplayer2.decoder.CryptoConfig)2 DecoderException (com.google.android.exoplayer2.decoder.DecoderException)2 SuppressLint (android.annotation.SuppressLint)1 DeniedByServerException (android.media.DeniedByServerException)1 MediaCodec (android.media.MediaCodec)1 MediaCrypto (android.media.MediaCrypto)1 MediaCryptoException (android.media.MediaCryptoException)1 MediaDrm (android.media.MediaDrm)1 MediaDrmResetException (android.media.MediaDrmResetException)1 NotProvisionedException (android.media.NotProvisionedException)1 ErrnoException (android.system.ErrnoException)1 ExoPlaybackException (com.google.android.exoplayer2.ExoPlaybackException)1 Format (com.google.android.exoplayer2.Format)1 ParserException (com.google.android.exoplayer2.ParserException)1 AudioSink (com.google.android.exoplayer2.audio.AudioSink)1 DefaultDrmSessionManager (com.google.android.exoplayer2.drm.DefaultDrmSessionManager)1 SchemeData (com.google.android.exoplayer2.drm.DrmInitData.SchemeData)1 FrameworkCryptoConfig (com.google.android.exoplayer2.drm.FrameworkCryptoConfig)1