Fix empty container box bug for fMP4 extractor

This fix derives from issue #1308, which came up in unfragmented mp4 files.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117236416
This commit is contained in:
olly 2016-03-15 07:14:12 -07:00 committed by Oliver Woodman
parent eeddd6d8df
commit 6fc8057146

View File

@ -243,7 +243,12 @@ public final class FragmentedMp4Extractor implements Extractor {
if (shouldParseContainerAtom(atomType)) {
long endPosition = input.getPosition() + atomSize - Atom.HEADER_SIZE;
containerAtoms.add(new ContainerAtom(atomType, endPosition));
enterReadingAtomHeaderState();
if (atomSize == atomHeaderBytesRead) {
processAtomEnded(endPosition);
} else {
// Start reading the first child atom.
enterReadingAtomHeaderState();
}
} else if (shouldParseLeafAtom(atomType)) {
if (atomHeaderBytesRead != Atom.HEADER_SIZE) {
throw new ParserException("Leaf atom defines extended atom size (unsupported).");
@ -273,8 +278,11 @@ public final class FragmentedMp4Extractor implements Extractor {
} else {
input.skipFully(atomPayloadSize);
}
long currentPosition = input.getPosition();
while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == currentPosition) {
processAtomEnded(input.getPosition());
}
private void processAtomEnded(long atomEndPosition) throws ParserException {
while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == atomEndPosition) {
onContainerAtomRead(containerAtoms.pop());
}
enterReadingAtomHeaderState();