Skip to content

Commit

Permalink
Reset requiresSecureDecoder boolean on codec release
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 229253065
  • Loading branch information
ojw28 committed Jan 14, 2019
1 parent 1b62277 commit 0bfbcea
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private static String buildCustomDiagnosticInfo(int errorCode) {
@Nullable private DrmSession<FrameworkMediaCrypto> codecDrmSession;
@Nullable private DrmSession<FrameworkMediaCrypto> sourceDrmSession;
@Nullable private MediaCrypto mediaCrypto;
private boolean drmSessionRequiresSecureDecoder;
private boolean mediaCryptoRequiresSecureDecoder;
private long renderTimeLimitMs;
private float rendererOperatingRate;
@Nullable private MediaCodec codec;
Expand Down Expand Up @@ -481,7 +481,7 @@ protected final void maybeInitCodec() throws ExoPlaybackException {
} catch (MediaCryptoException e) {
throw ExoPlaybackException.createForRenderer(e, getIndex());
}
drmSessionRequiresSecureDecoder =
mediaCryptoRequiresSecureDecoder =
!sessionMediaCrypto.forceAllowInsecureDecoderComponents
&& mediaCrypto.requiresSecureDecoderComponent(mimeType);
}
Expand All @@ -498,7 +498,7 @@ protected final void maybeInitCodec() throws ExoPlaybackException {
}

try {
maybeInitCodecWithFallback(mediaCrypto, drmSessionRequiresSecureDecoder);
maybeInitCodecWithFallback(mediaCrypto, mediaCryptoRequiresSecureDecoder);
} catch (DecoderInitializationException e) {
throw ExoPlaybackException.createForRenderer(e, getIndex());
}
Expand Down Expand Up @@ -606,6 +606,7 @@ protected void releaseCodec() {
}
} finally {
mediaCrypto = null;
mediaCryptoRequiresSecureDecoder = false;
setCodecDrmSession(null);
}
}
Expand Down Expand Up @@ -727,18 +728,18 @@ protected boolean flushOrReleaseCodec() {
}

private void maybeInitCodecWithFallback(
MediaCrypto crypto, boolean drmSessionRequiresSecureDecoder)
MediaCrypto crypto, boolean mediaCryptoRequiresSecureDecoder)
throws DecoderInitializationException {
if (availableCodecInfos == null) {
try {
availableCodecInfos =
new ArrayDeque<>(getAvailableCodecInfos(drmSessionRequiresSecureDecoder));
new ArrayDeque<>(getAvailableCodecInfos(mediaCryptoRequiresSecureDecoder));
preferredDecoderInitializationException = null;
} catch (DecoderQueryException e) {
throw new DecoderInitializationException(
inputFormat,
e,
drmSessionRequiresSecureDecoder,
mediaCryptoRequiresSecureDecoder,
DecoderInitializationException.DECODER_QUERY_ERROR);
}
}
Expand All @@ -747,7 +748,7 @@ private void maybeInitCodecWithFallback(
throw new DecoderInitializationException(
inputFormat,
/* cause= */ null,
drmSessionRequiresSecureDecoder,
mediaCryptoRequiresSecureDecoder,
DecoderInitializationException.NO_SUITABLE_DECODER_ERROR);
}

Expand All @@ -766,7 +767,7 @@ private void maybeInitCodecWithFallback(
availableCodecInfos.removeFirst();
DecoderInitializationException exception =
new DecoderInitializationException(
inputFormat, e, drmSessionRequiresSecureDecoder, codecInfo.name);
inputFormat, e, mediaCryptoRequiresSecureDecoder, codecInfo.name);
if (preferredDecoderInitializationException == null) {
preferredDecoderInitializationException = exception;
} else {
Expand All @@ -782,11 +783,11 @@ private void maybeInitCodecWithFallback(
availableCodecInfos = null;
}

private List<MediaCodecInfo> getAvailableCodecInfos(boolean drmSessionRequiresSecureDecoder)
private List<MediaCodecInfo> getAvailableCodecInfos(boolean mediaCryptoRequiresSecureDecoder)
throws DecoderQueryException {
List<MediaCodecInfo> codecInfos =
getDecoderInfos(mediaCodecSelector, inputFormat, drmSessionRequiresSecureDecoder);
if (codecInfos.isEmpty() && drmSessionRequiresSecureDecoder) {
getDecoderInfos(mediaCodecSelector, inputFormat, mediaCryptoRequiresSecureDecoder);
if (codecInfos.isEmpty() && mediaCryptoRequiresSecureDecoder) {
// The drm session indicates that a secure decoder is required, but the device does not
// have one. Assuming that supportsFormat indicated support for the media being played, we
// know that it does not require a secure output path. Most CDM implementations allow
Expand Down

0 comments on commit 0bfbcea

Please sign in to comment.