From 715c948004eeabb6f7e2d45b8b8856ee4a015391 Mon Sep 17 00:00:00 2001 From: ibaker Date: Thu, 22 Sep 2022 15:59:44 +0000 Subject: [PATCH] Work around a bug in the Android 13 ClearKey implementation The ClearKey CDM will attach an 'invalid' URL in `KeyRequest` objects, when the documentation states this should be an empty string if a default URL is not known. #minor-release PiperOrigin-RevId: 476113513 --- RELEASENOTES.md | 3 +++ .../media3/exoplayer/drm/FrameworkMediaDrm.java | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ee3ebfbd8db..d497fab4186 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -29,6 +29,9 @@ `MetadataRenderer(MetadataOutput, Looper, MetadataDecoderFactory, boolean)` to specify whether the renderer will output metadata early or in sync with the player position. +* DRM: + * Work around a bug in the Android 13 ClearKey implementation that returns + a non-empty but invalid license URL. * DASH: * Parse `EventStream.presentationTimeOffset` from manifests ([#10460](https://github.com/google/ExoPlayer/issues/10460)). diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/FrameworkMediaDrm.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/FrameworkMediaDrm.java index 8059f10becd..9ed07382a96 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/FrameworkMediaDrm.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/FrameworkMediaDrm.java @@ -229,11 +229,7 @@ public KeyRequest getKeyRequest( mediaDrm.getKeyRequest(scope, initData, mimeType, keyType, optionalParameters); byte[] requestData = adjustRequestData(uuid, request.getData()); - - String licenseServerUrl = request.getDefaultUrl(); - if (MOCK_LA_URL_VALUE.equals(licenseServerUrl)) { - licenseServerUrl = ""; - } + String licenseServerUrl = adjustLicenseServerUrl(request.getDefaultUrl()); if (TextUtils.isEmpty(licenseServerUrl) && schemeData != null && !TextUtils.isEmpty(schemeData.licenseServerUrl)) { @@ -247,6 +243,17 @@ public KeyRequest getKeyRequest( return new KeyRequest(requestData, licenseServerUrl, requestType); } + private static String adjustLicenseServerUrl(String licenseServerUrl) { + if (MOCK_LA_URL.equals(licenseServerUrl)) { + return ""; + } else if (Util.SDK_INT == 33 && "https://default.url".equals(licenseServerUrl)) { + // Work around b/247808112 + return ""; + } else { + return licenseServerUrl; + } + } + @UnstableApi @Override @Nullable