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
(cherry picked from commit 715c948004eeabb6f7e2d45b8b8856ee4a015391)
This commit is contained in:
ibaker 2022-09-22 15:59:44 +00:00 committed by microkatz
parent 873b806389
commit 395d89a7b7
2 changed files with 15 additions and 5 deletions

View File

@ -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)).

View File

@ -229,11 +229,7 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
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 final class FrameworkMediaDrm implements ExoMediaDrm {
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