mirror of
https://github.com/androidx/media.git
synced 2025-05-12 18:19:50 +08:00
Fix cenc mode support and add support for the .mp4a extension.
Also add encrypted HLS internal sample streams. Issue:#1661 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175577648
This commit is contained in:
parent
79a9155438
commit
25dd8aa1f8
@ -43,6 +43,7 @@ public final class DefaultHlsExtractorFactory implements HlsExtractorFactory {
|
|||||||
public static final String MP3_FILE_EXTENSION = ".mp3";
|
public static final String MP3_FILE_EXTENSION = ".mp3";
|
||||||
public static final String MP4_FILE_EXTENSION = ".mp4";
|
public static final String MP4_FILE_EXTENSION = ".mp4";
|
||||||
public static final String M4_FILE_EXTENSION_PREFIX = ".m4";
|
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 VTT_FILE_EXTENSION = ".vtt";
|
||||||
public static final String WEBVTT_FILE_EXTENSION = ".webvtt";
|
public static final String WEBVTT_FILE_EXTENSION = ".webvtt";
|
||||||
|
|
||||||
@ -71,7 +72,8 @@ public final class DefaultHlsExtractorFactory implements HlsExtractorFactory {
|
|||||||
// Only reuse TS and fMP4 extractors.
|
// Only reuse TS and fMP4 extractors.
|
||||||
extractor = previousExtractor;
|
extractor = previousExtractor;
|
||||||
} else if (lastPathSegment.endsWith(MP4_FILE_EXTENSION)
|
} 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,
|
extractor = new FragmentedMp4Extractor(0, timestampAdjuster, null, drmInitData,
|
||||||
muxedCaptionFormats != null ? muxedCaptionFormats : Collections.<Format>emptyList());
|
muxedCaptionFormats != null ? muxedCaptionFormats : Collections.<Format>emptyList());
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,7 +107,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
private static final Pattern REGEX_ATTR_BYTERANGE =
|
private static final Pattern REGEX_ATTR_BYTERANGE =
|
||||||
Pattern.compile("BYTERANGE=\"(\\d+(?:@\\d+)?)\\b\"");
|
Pattern.compile("BYTERANGE=\"(\\d+(?:@\\d+)?)\\b\"");
|
||||||
private static final Pattern REGEX_METHOD = Pattern.compile("METHOD=(" + METHOD_NONE + "|"
|
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_KEYFORMAT = Pattern.compile("KEYFORMAT=\"(.+?)\"");
|
||||||
private static final Pattern REGEX_URI = Pattern.compile("URI=\"(.+?)\"");
|
private static final Pattern REGEX_URI = Pattern.compile("URI=\"(.+?)\"");
|
||||||
private static final Pattern REGEX_IV = Pattern.compile("IV=([^,.*]+)");
|
private static final Pattern REGEX_IV = Pattern.compile("IV=([^,.*]+)");
|
||||||
@ -370,7 +370,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
segmentDurationUs =
|
segmentDurationUs =
|
||||||
(long) (parseDoubleAttr(line, REGEX_MEDIA_DURATION) * C.MICROS_PER_SECOND);
|
(long) (parseDoubleAttr(line, REGEX_MEDIA_DURATION) * C.MICROS_PER_SECOND);
|
||||||
} else if (line.startsWith(TAG_KEY)) {
|
} else if (line.startsWith(TAG_KEY)) {
|
||||||
String method = parseStringAttr(line, REGEX_METHOD);
|
String method = parseOptionalStringAttr(line, REGEX_METHOD);
|
||||||
String keyFormat = parseOptionalStringAttr(line, REGEX_KEYFORMAT);
|
String keyFormat = parseOptionalStringAttr(line, REGEX_KEYFORMAT);
|
||||||
encryptionKeyUri = null;
|
encryptionKeyUri = null;
|
||||||
encryptionIV = null;
|
encryptionIV = null;
|
||||||
@ -384,7 +384,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
// Do nothing. Samples are encrypted using an identity key, but this is not supported.
|
// Do nothing. Samples are encrypted using an identity key, but this is not supported.
|
||||||
// Hopefully, a traditional DRM alternative is also provided.
|
// Hopefully, a traditional DRM alternative is also provided.
|
||||||
}
|
}
|
||||||
} else {
|
} else if (method != null) {
|
||||||
SchemeData schemeData = parseWidevineSchemeData(line, keyFormat);
|
SchemeData schemeData = parseWidevineSchemeData(line, keyFormat);
|
||||||
if (schemeData != null) {
|
if (schemeData != null) {
|
||||||
drmInitData = new DrmInitData(METHOD_SAMPLE_AES_CENC.equals(method)
|
drmInitData = new DrmInitData(METHOD_SAMPLE_AES_CENC.equals(method)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user