Skip to content

Commit

Permalink
Merge pull request #2372 from wasabeef/dev-v2-cenc-clearkey
Browse files Browse the repository at this point in the history
Added support for CENC ClearKey
  • Loading branch information
ojw28 authored Feb 23, 2017
2 parents 3fc3349 + e0f7a12 commit 7e02e58
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions demo/src/main/assets/media.exolist.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@
}
]
},
{
"name": "ClearKey DASH",
"samples": [
{
"name": "Big Buck Bunny (CENC ClearKey)",
"uri": "http://html5.cablelabs.com:8100/cenc/ck/dash.mpd",
"extension": "mpd",
"drm_scheme": "cenc",
"drm_license_url": "https://wasabeef.jp/demos/cenc-ck-dash.json"
}
]
},
{
"name": "SmoothStreaming",
"samples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ private UUID getDrmUuid(String typeString) throws ParserException {
return C.WIDEVINE_UUID;
case "playready":
return C.PLAYREADY_UUID;
case "cenc":
return C.CENC_UUID;
default:
try {
return UUID.fromString(typeString);
Expand Down
6 changes: 6 additions & 0 deletions library/src/main/java/com/google/android/exoplayer2/C.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,12 @@ private C() {}
*/
public static final UUID UUID_NIL = new UUID(0L, 0L);

/**
* UUID for the PSSH box and MPEG-DASH Content Protection.
* <a href="https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html">W3C</a>.
*/
public static final UUID CENC_UUID = new UUID(0x1077EFECC0B24D02L, 0xACE33C1E52E2FB4BL);

/**
* UUID for the Widevine DRM scheme.
* <p></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest;
import com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -102,6 +103,11 @@ public interface EventListener {
/** Releases an existing offline license. */
public static final int MODE_RELEASE = 3;

/**
* The format to use when ClearKey encryption.
*/
private static final String CENC_INIT_DATA_FORMAT = "cenc";

private static final String TAG = "OfflineDrmSessionMngr";

private static final int MSG_PROVISION = 0;
Expand Down Expand Up @@ -339,6 +345,21 @@ public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitDa
schemeInitData = psshData;
}
}
if (C.CENC_UUID.equals(uuid)) {
// If "video/mp4" and "audio/mp4" are not supported as CENC schema, change it to "cenc".
// Before 7.1.x in API 25, "video/mp4" and "audio/mp4" are not supported.
if (MimeTypes.VIDEO_MP4.equals(schemeMimeType) || MimeTypes.AUDIO_MP4.equals(
schemeMimeType)) {
if (Util.SDK_INT >= 26) {
// Nothing to do.
} else if (Util.SDK_INT == 25 && !MediaDrm.isCryptoSchemeSupported(uuid,
schemeMimeType)) {
schemeMimeType = CENC_INIT_DATA_FORMAT;
} else if (Util.SDK_INT <= 24) {
schemeMimeType = CENC_INIT_DATA_FORMAT;
}
}
}
}
state = STATE_OPENING;
openInternal(true);
Expand Down

0 comments on commit 7e02e58

Please sign in to comment.