Skip to content

Commit

Permalink
Clean up ClearKey UUIDs
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ojw28 committed Sep 6, 2017
1 parent f90f15b commit 4f44dfb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private UUID getDrmUuid(String typeString) throws ParserException {
return C.WIDEVINE_UUID;
case "playready":
return C.PLAYREADY_UUID;
case "cenc":
case "clearkey":
return C.CLEARKEY_UUID;
default:
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,19 @@ private C() {}
*/
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.
* <p>
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public static DefaultDrmSessionManager<FrameworkMediaCrypto> newFrameworkInstanc
public DefaultDrmSessionManager(UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback,
HashMap<String, String> optionalKeyRequestParameters, Handler eventHandler,
EventListener eventListener) {
Assertions.checkNotNull(uuid);
Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead");
this.uuid = uuid;
this.mediaDrm = mediaDrm;
this.callback = callback;
Expand Down Expand Up @@ -346,6 +348,10 @@ public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitDa

if (offlineLicenseKeySetId == null) {
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) {
onError(new IllegalStateException("Media does not support uuid: " + uuid));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public static FrameworkMediaDrm newInstance(UUID uuid) throws UnsupportedDrmExce
}

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
Expand Down

0 comments on commit 4f44dfb

Please sign in to comment.