Commit 4527539e by Oliver Woodman

Handle cenc:pssh elements in DASH manifests.

Issue: #407
parent 3360f5ed
......@@ -419,7 +419,9 @@ public class DashChunkSource implements ChunkSource {
(ChunkIndex) initializationChunk.getSeekMap(),
initializationChunk.dataSpec.uri.toString());
}
if (initializationChunk.hasDrmInitData()) {
// The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
// obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
if (drmInitData == null && initializationChunk.hasDrmInitData()) {
drmInitData = initializationChunk.getDrmInitData();
}
}
......
......@@ -24,10 +24,12 @@ import com.google.android.exoplayer.dash.mpd.SegmentBase.SingleSegmentBase;
import com.google.android.exoplayer.upstream.UriLoadable;
import com.google.android.exoplayer.util.Assertions;
import com.google.android.exoplayer.util.MimeTypes;
import com.google.android.exoplayer.util.ParsableByteArray;
import com.google.android.exoplayer.util.UriUtil;
import com.google.android.exoplayer.util.Util;
import android.text.TextUtils;
import android.util.Base64;
import org.xml.sax.helpers.DefaultHandler;
import org.xmlpull.v1.XmlPullParser;
......@@ -41,6 +43,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -270,11 +273,27 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
protected ContentProtection parseContentProtection(XmlPullParser xpp)
throws XmlPullParserException, IOException {
String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
return buildContentProtection(schemeIdUri);
UUID uuid = null;
byte[] data = null;
do {
xpp.next();
// The cenc:pssh element is defined in 23001-7:2015
if (isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
byte[] decodedData = Base64.decode(xpp.getText(), Base64.DEFAULT);
ParsableByteArray psshAtom = new ParsableByteArray(decodedData);
psshAtom.skipBytes(12);
uuid = new UUID(psshAtom.readLong(), psshAtom.readLong());
int dataSize = psshAtom.readInt();
data = new byte[dataSize];
psshAtom.readBytes(data, 0, dataSize);
}
} while (!isEndTag(xpp, "ContentProtection"));
return buildContentProtection(schemeIdUri, uuid, data);
}
protected ContentProtection buildContentProtection(String schemeIdUri) {
return new ContentProtection(schemeIdUri, null, null);
protected ContentProtection buildContentProtection(String schemeIdUri, UUID uuid, byte[] data) {
return new ContentProtection(schemeIdUri, uuid, data);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment