Skip to content

Commit

Permalink
Add SAMPLE-AES-CTR, which replaces SAMPLE-AES-CENC per latest spefica…
Browse files Browse the repository at this point in the history
…tion: https://storage.googleapis.com/wvdocs/Widevine_DRM_HLS.pdf.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182407790
  • Loading branch information
kqyang authored and ojw28 committed Jan 23, 2018
1 parent 68387f9 commit 06be0fd
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
private static final String METHOD_NONE = "NONE";
private static final String METHOD_AES_128 = "AES-128";
private static final String METHOD_SAMPLE_AES = "SAMPLE-AES";
// Replaced by METHOD_SAMPLE_AES_CTR. Keep for backward compatibility.
private static final String METHOD_SAMPLE_AES_CENC = "SAMPLE-AES-CENC";
private static final String METHOD_SAMPLE_AES_CTR = "SAMPLE-AES-CTR";
private static final String KEYFORMAT_IDENTITY = "identity";
private static final String KEYFORMAT_WIDEVINE_PSSH_BINARY =
"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";
Expand Down Expand Up @@ -108,8 +110,19 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
+ ":(\\d+(?:@\\d+)?)\\b");
private static final Pattern REGEX_ATTR_BYTERANGE =
Pattern.compile("BYTERANGE=\"(\\d+(?:@\\d+)?)\\b\"");
private static final Pattern REGEX_METHOD = Pattern.compile("METHOD=(" + METHOD_NONE + "|"
+ METHOD_AES_128 + "|" + METHOD_SAMPLE_AES + "|" + METHOD_SAMPLE_AES_CENC + ")");
private static final Pattern REGEX_METHOD =
Pattern.compile(
"METHOD=("
+ METHOD_NONE
+ "|"
+ METHOD_AES_128
+ "|"
+ METHOD_SAMPLE_AES
+ "|"
+ METHOD_SAMPLE_AES_CENC
+ "|"
+ METHOD_SAMPLE_AES_CTR
+ ")");
private static final Pattern REGEX_KEYFORMAT = Pattern.compile("KEYFORMAT=\"(.+?)\"");
private static final Pattern REGEX_URI = Pattern.compile("URI=\"(.+?)\"");
private static final Pattern REGEX_IV = Pattern.compile("IV=([^,.*]+)");
Expand Down Expand Up @@ -408,8 +421,13 @@ private static HlsMediaPlaylist parseMediaPlaylist(LineIterator iterator, String
} else if (method != null) {
SchemeData schemeData = parseWidevineSchemeData(line, keyFormat);
if (schemeData != null) {
drmInitData = new DrmInitData(METHOD_SAMPLE_AES_CENC.equals(method)
? C.CENC_TYPE_cenc : C.CENC_TYPE_cbcs, schemeData);
drmInitData =
new DrmInitData(
(METHOD_SAMPLE_AES_CENC.equals(method)
|| METHOD_SAMPLE_AES_CTR.equals(method))
? C.CENC_TYPE_cenc
: C.CENC_TYPE_cbcs,
schemeData);
}
}
}
Expand Down

0 comments on commit 06be0fd

Please sign in to comment.