Skip to content

Commit

Permalink
Fix cenc mode support and add support for the .mp4a extension.
Browse files Browse the repository at this point in the history
Also add encrypted HLS internal sample streams.

Issue:#1661

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175577648
  • Loading branch information
AquilesCanta authored and ojw28 committed Nov 17, 2017
1 parent afe6f66 commit b17ae80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class DefaultHlsExtractorFactory implements HlsExtractorFactory {
public static final String MP3_FILE_EXTENSION = ".mp3";
public static final String MP4_FILE_EXTENSION = ".mp4";
public static final String M4_FILE_EXTENSION_PREFIX = ".m4";
public static final String MP4_FILE_EXTENSION_PREFIX = ".mp4";
public static final String VTT_FILE_EXTENSION = ".vtt";
public static final String WEBVTT_FILE_EXTENSION = ".webvtt";

Expand Down Expand Up @@ -71,7 +72,8 @@ public Pair<Extractor, Boolean> createExtractor(Extractor previousExtractor, Uri
// Only reuse TS and fMP4 extractors.
extractor = previousExtractor;
} else if (lastPathSegment.endsWith(MP4_FILE_EXTENSION)
|| lastPathSegment.startsWith(M4_FILE_EXTENSION_PREFIX, lastPathSegment.length() - 4)) {
|| lastPathSegment.startsWith(M4_FILE_EXTENSION_PREFIX, lastPathSegment.length() - 4)
|| lastPathSegment.startsWith(MP4_FILE_EXTENSION_PREFIX, lastPathSegment.length() - 5)) {
extractor = new FragmentedMp4Extractor(0, timestampAdjuster, null, drmInitData,
muxedCaptionFormats != null ? muxedCaptionFormats : Collections.<Format>emptyList());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
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_AES_128 + "|" + METHOD_SAMPLE_AES + "|" + METHOD_SAMPLE_AES_CENC + ")");
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 @@ -391,7 +391,7 @@ private static HlsMediaPlaylist parseMediaPlaylist(LineIterator iterator, String
segmentDurationUs =
(long) (parseDoubleAttr(line, REGEX_MEDIA_DURATION) * C.MICROS_PER_SECOND);
} else if (line.startsWith(TAG_KEY)) {
String method = parseStringAttr(line, REGEX_METHOD);
String method = parseOptionalStringAttr(line, REGEX_METHOD);
String keyFormat = parseOptionalStringAttr(line, REGEX_KEYFORMAT);
encryptionKeyUri = null;
encryptionIV = null;
Expand All @@ -405,7 +405,7 @@ private static HlsMediaPlaylist parseMediaPlaylist(LineIterator iterator, String
// Do nothing. Samples are encrypted using an identity key, but this is not supported.
// Hopefully, a traditional DRM alternative is also provided.
}
} else {
} else if (method != null) {
SchemeData schemeData = parseWidevineSchemeData(line, keyFormat);
if (schemeData != null) {
drmInitData = new DrmInitData(METHOD_SAMPLE_AES_CENC.equals(method)
Expand Down

0 comments on commit b17ae80

Please sign in to comment.