Add missing call to adjustUuid in FrameworkMediaDrm

Before API 27, the platform DRM components incorrectly expected
`C.COMMON_PSSH_UUID` instead of `C.CLEARKEY_UUID` in order to perform
ClearKey decryption. `FrameworkMediaDrm` is responsible for doing this
adjustment on these API levels, but this call was missed when
refactoring some DRM code in
c872af4bc0.

This led to `MediaCodec$CryptoException: Operation not supported in this
configuration` errors when doing ClearKey playback on devices with
API < 27. This was because the earlier, clearer error from the
`MediaCrypto` constructor was being swallowed and transformed to
`requiresSecureDecoder = true` by the `catch` logic in
`FrameworkMediaDrm.requiresSecureDecoder`.

This change also makes the error handling in
`FrameworkMediaDrm.requiresSecureDecoder` more robust by assuming
`requiresSecure = false` for ClearKey (and true for all other DRM
schemes), since we know that ClearKey never supports secure decoding.
This will help avoid more ClearKey playback failures if we see other,
unrelated, errors at this point.

Issue: androidx/media#1732

#cherrypick

PiperOrigin-RevId: 730882278
This commit is contained in:
ibaker 2025-02-25 07:41:28 -08:00 committed by Copybara-Service
parent d58740367b
commit ecb83f3b73
2 changed files with 9 additions and 3 deletions

View File

@ -25,6 +25,9 @@
* Image: * Image:
* DataSource: * DataSource:
* DRM: * DRM:
* Fix `MediaCodec$CryptoException: Operation not supported in this
configuration` error when playing ClearKey content on API < 27 devices
([#1732](https://github.com/androidx/media/issues/1732)).
* Effect: * Effect:
* Muxers: * Muxers:
* `writeSampleData()` API now uses muxer specific `BufferInfo` class * `writeSampleData()` API now uses muxer specific `BufferInfo` class

View File

@ -298,11 +298,14 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
} else { } else {
MediaCrypto mediaCrypto = null; MediaCrypto mediaCrypto = null;
try { try {
mediaCrypto = new MediaCrypto(uuid, sessionId); mediaCrypto = new MediaCrypto(adjustUuid(uuid), sessionId);
result = mediaCrypto.requiresSecureDecoderComponent(mimeType); result = mediaCrypto.requiresSecureDecoderComponent(mimeType);
} catch (MediaCryptoException e) { } catch (MediaCryptoException e) {
// This shouldn't happen, but if it does then assume that a secure decoder may be required. // This shouldn't happen, but if it does then assume that most DRM schemes need a secure
result = true; // decoder but ClearKey doesn't (because ClearKey never uses secure decryption). Requesting
// a secure decoder when it's not supported leads to playback failures:
// https://github.com/androidx/media/issues/1732
result = !uuid.equals(C.CLEARKEY_UUID);
} finally { } finally {
if (mediaCrypto != null) { if (mediaCrypto != null) {
mediaCrypto.release(); mediaCrypto.release();