Only parse common-encryption sinf boxes

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172124807
This commit is contained in:
olly 2017-10-13 11:38:47 -07:00 committed by Oliver Woodman
parent feceabadeb
commit dbdae4ca25
2 changed files with 11 additions and 10 deletions

View File

@ -34,18 +34,18 @@ public final class AtomParsersTest extends TestCase {
+ SAMPLE_COUNT + "0001000200030004"); + SAMPLE_COUNT + "0001000200030004");
public void testStz2Parsing4BitFieldSize() { public void testStz2Parsing4BitFieldSize() {
verifyParsing(new Atom.LeafAtom(Atom.TYPE_stsz, new ParsableByteArray(FOUR_BIT_STZ2))); verifyStz2Parsing(new Atom.LeafAtom(Atom.TYPE_stsz, new ParsableByteArray(FOUR_BIT_STZ2)));
} }
public void testStz2Parsing8BitFieldSize() { public void testStz2Parsing8BitFieldSize() {
verifyParsing(new Atom.LeafAtom(Atom.TYPE_stsz, new ParsableByteArray(EIGHT_BIT_STZ2))); verifyStz2Parsing(new Atom.LeafAtom(Atom.TYPE_stsz, new ParsableByteArray(EIGHT_BIT_STZ2)));
} }
public void testStz2Parsing16BitFieldSize() { public void testStz2Parsing16BitFieldSize() {
verifyParsing(new Atom.LeafAtom(Atom.TYPE_stsz, new ParsableByteArray(SIXTEEN_BIT_STZ2))); verifyStz2Parsing(new Atom.LeafAtom(Atom.TYPE_stsz, new ParsableByteArray(SIXTEEN_BIT_STZ2)));
} }
private void verifyParsing(Atom.LeafAtom stz2Atom) { private static void verifyStz2Parsing(Atom.LeafAtom stz2Atom) {
AtomParsers.Stz2SampleSizeBox box = new AtomParsers.Stz2SampleSizeBox(stz2Atom); AtomParsers.Stz2SampleSizeBox box = new AtomParsers.Stz2SampleSizeBox(stz2Atom);
assertEquals(4, box.getSampleCount()); assertEquals(4, box.getSampleCount());
assertFalse(box.isFixedSampleSize()); assertFalse(box.isFixedSampleSize());

View File

@ -1060,8 +1060,8 @@ import java.util.List;
Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive"); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
int childAtomType = parent.readInt(); int childAtomType = parent.readInt();
if (childAtomType == Atom.TYPE_sinf) { if (childAtomType == Atom.TYPE_sinf) {
Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition, Pair<Integer, TrackEncryptionBox> result = parseCommonEncryptionSinfFromParent(parent,
childAtomSize); childPosition, childAtomSize);
if (result != null) { if (result != null) {
return result; return result;
} }
@ -1071,8 +1071,8 @@ import java.util.List;
return null; return null;
} }
private static Pair<Integer, TrackEncryptionBox> parseSinfFromParent(ParsableByteArray parent, /* package */ static Pair<Integer, TrackEncryptionBox> parseCommonEncryptionSinfFromParent(
int position, int size) { ParsableByteArray parent, int position, int size) {
int childPosition = position + Atom.HEADER_SIZE; int childPosition = position + Atom.HEADER_SIZE;
int schemeInformationBoxPosition = C.POSITION_UNSET; int schemeInformationBoxPosition = C.POSITION_UNSET;
int schemeInformationBoxSize = 0; int schemeInformationBoxSize = 0;
@ -1086,7 +1086,7 @@ import java.util.List;
dataFormat = parent.readInt(); dataFormat = parent.readInt();
} else if (childAtomType == Atom.TYPE_schm) { } else if (childAtomType == Atom.TYPE_schm) {
parent.skipBytes(4); parent.skipBytes(4);
// scheme_type field. Defined in ISO/IEC 23001-7:2016, section 4.1. // Common encryption scheme_type values are defined in ISO/IEC 23001-7:2016, section 4.1.
schemeType = parent.readString(4); schemeType = parent.readString(4);
} else if (childAtomType == Atom.TYPE_schi) { } else if (childAtomType == Atom.TYPE_schi) {
schemeInformationBoxPosition = childPosition; schemeInformationBoxPosition = childPosition;
@ -1095,7 +1095,8 @@ import java.util.List;
childPosition += childAtomSize; childPosition += childAtomSize;
} }
if (schemeType != null) { if (C.CENC_TYPE_cenc.equals(schemeType) || C.CENC_TYPE_cbc1.equals(schemeType)
|| C.CENC_TYPE_cens.equals(schemeType) || C.CENC_TYPE_cbcs.equals(schemeType)) {
Assertions.checkArgument(dataFormat != null, "frma atom is mandatory"); Assertions.checkArgument(dataFormat != null, "frma atom is mandatory");
Assertions.checkArgument(schemeInformationBoxPosition != C.POSITION_UNSET, Assertions.checkArgument(schemeInformationBoxPosition != C.POSITION_UNSET,
"schi atom is mandatory"); "schi atom is mandatory");