Commit 5ab0c620 by olly Committed by Oliver Woodman

Clean up ClearKey UUIDs

- There is a proper ClearKey UUID now. This change requires
  it to be used instead of the Common PSSH UUID when instantiating
  DRM components.
- Internally, we'll map the ClearKey UUID onto the Common PSSH
  UUID where necessary to (a) access the ClearKey CDM on older
  devices, and (b) access drm init data stored under the Common
  PSSH UUID in the stream.

Issue: #3138

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164839213
parent 2d0044fe
...@@ -271,7 +271,7 @@ public class SampleChooserActivity extends Activity { ...@@ -271,7 +271,7 @@ public class SampleChooserActivity extends Activity {
return C.WIDEVINE_UUID; return C.WIDEVINE_UUID;
case "playready": case "playready":
return C.PLAYREADY_UUID; return C.PLAYREADY_UUID;
case "cenc": case "clearkey":
return C.CLEARKEY_UUID; return C.CLEARKEY_UUID;
default: default:
try { try {
......
...@@ -605,11 +605,18 @@ public final class C { ...@@ -605,11 +605,18 @@ public final class C {
public static final UUID UUID_NIL = new UUID(0L, 0L); public static final UUID UUID_NIL = new UUID(0L, 0L);
/** /**
* UUID for the W3C
* <a href="https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html">Common PSSH
* box</a>.
*/
public static final UUID COMMON_PSSH_UUID = new UUID(0x1077EFECC0B24D02L, 0xACE33C1E52E2FB4BL);
/**
* UUID for the ClearKey DRM scheme. * UUID for the ClearKey DRM scheme.
* <p> * <p>
* ClearKey is supported on Android devices running Android 5.0 (API Level 21) and up. * ClearKey is supported on Android devices running Android 5.0 (API Level 21) and up.
*/ */
public static final UUID CLEARKEY_UUID = new UUID(0x1077EFECC0B24D02L, 0xACE33C1E52E2FB4BL); public static final UUID CLEARKEY_UUID = new UUID(0xE2719D58A985B3C9L, 0x781AB030AF78D30EL);
/** /**
* UUID for the Widevine DRM scheme. * UUID for the Widevine DRM scheme.
......
...@@ -216,6 +216,8 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe ...@@ -216,6 +216,8 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
public DefaultDrmSessionManager(UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback, public DefaultDrmSessionManager(UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback,
HashMap<String, String> optionalKeyRequestParameters, Handler eventHandler, HashMap<String, String> optionalKeyRequestParameters, Handler eventHandler,
EventListener eventListener) { EventListener eventListener) {
Assertions.checkNotNull(uuid);
Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead");
this.uuid = uuid; this.uuid = uuid;
this.mediaDrm = mediaDrm; this.mediaDrm = mediaDrm;
this.callback = callback; this.callback = callback;
...@@ -346,6 +348,10 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe ...@@ -346,6 +348,10 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
if (offlineLicenseKeySetId == null) { if (offlineLicenseKeySetId == null) {
SchemeData schemeData = drmInitData.get(uuid); SchemeData schemeData = drmInitData.get(uuid);
if (schemeData == null && C.CLEARKEY_UUID.equals(uuid)) {
// If present, the Common PSSH box should be used for ClearKey.
schemeData = drmInitData.get(C.COMMON_PSSH_UUID);
}
if (schemeData == null) { if (schemeData == null) {
onError(new IllegalStateException("Media does not support uuid: " + uuid)); onError(new IllegalStateException("Media does not support uuid: " + uuid));
return this; return this;
......
...@@ -57,7 +57,13 @@ public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto ...@@ -57,7 +57,13 @@ public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto
} }
private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException { private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException {
this.mediaDrm = new MediaDrm(Assertions.checkNotNull(uuid)); Assertions.checkNotNull(uuid);
Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead");
if (Util.SDK_INT < 27 && C.CLEARKEY_UUID.equals(uuid)) {
// ClearKey had to be accessed using the Common PSSH UUID prior to API level 27.
uuid = C.COMMON_PSSH_UUID;
}
this.mediaDrm = new MediaDrm(uuid);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment