DASH: Support mspr:pro element

Issue: #2386

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=147725616
This commit is contained in:
olly 2017-02-16 08:52:50 -08:00 committed by Oliver Woodman
parent 65d4b1cf5c
commit 0d468ca7bf

View File

@ -335,30 +335,35 @@ public class DashManifestParser extends DefaultHandler
*/
protected SchemeData parseContentProtection(XmlPullParser xpp) throws XmlPullParserException,
IOException {
String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
boolean isPlayReady = "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95".equals(schemeIdUri);
byte[] data = null;
UUID uuid = null;
boolean seenPsshElement = false;
boolean requiresSecureDecoder = false;
do {
xpp.next();
// The cenc:pssh element is defined in 23001-7:2015.
if (XmlPullParserUtil.isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
seenPsshElement = true;
data = Base64.decode(xpp.getText(), Base64.DEFAULT);
if (data == null && XmlPullParserUtil.isStartTag(xpp, "cenc:pssh")
&& xpp.next() == XmlPullParser.TEXT) {
// The cenc:pssh element is defined in 23001-7:2015.
uuid = PsshAtomUtil.parseUuid(data);
if (uuid == null) {
Log.w(TAG, "Skipping malformed cenc:pssh data");
} else {
data = Base64.decode(xpp.getText(), Base64.DEFAULT);
}
} else if (data == null && isPlayReady && XmlPullParserUtil.isStartTag(xpp, "mspr:pro")
&& xpp.next() == XmlPullParser.TEXT) {
// The mspr:pro element is defined in DASH Content Protection using Microsoft PlayReady.
uuid = C.PLAYREADY_UUID;
data = PsshAtomUtil.buildPsshAtom(C.PLAYREADY_UUID,
Base64.decode(xpp.getText(), Base64.DEFAULT));
} else if (XmlPullParserUtil.isStartTag(xpp, "widevine:license")) {
String robustnessLevel = xpp.getAttributeValue(null, "robustness_level");
requiresSecureDecoder = robustnessLevel != null && robustnessLevel.startsWith("HW");
}
} while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection"));
if (!seenPsshElement) {
return null;
} else if (uuid != null) {
return new SchemeData(uuid, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder);
} else {
Log.w(TAG, "Skipped unsupported ContentProtection element");
return null;
}
return data != null ? new SchemeData(uuid, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder)
: null;
}
/**