mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Clean up MP4/FMP4 shouldParse methods.
This commit is contained in:
parent
3cbb1fa1b9
commit
269757cb3e
3 changed files with 23 additions and 33 deletions
|
|
@ -100,7 +100,6 @@ import java.util.List;
|
||||||
public static final int TYPE_pasp = Util.getIntegerCodeForString("pasp");
|
public static final int TYPE_pasp = Util.getIntegerCodeForString("pasp");
|
||||||
public static final int TYPE_TTML = Util.getIntegerCodeForString("TTML");
|
public static final int TYPE_TTML = Util.getIntegerCodeForString("TTML");
|
||||||
public static final int TYPE_vmhd = Util.getIntegerCodeForString("vmhd");
|
public static final int TYPE_vmhd = Util.getIntegerCodeForString("vmhd");
|
||||||
public static final int TYPE_smhd = Util.getIntegerCodeForString("smhd");
|
|
||||||
public static final int TYPE_mp4v = Util.getIntegerCodeForString("mp4v");
|
public static final int TYPE_mp4v = Util.getIntegerCodeForString("mp4v");
|
||||||
public static final int TYPE_stts = Util.getIntegerCodeForString("stts");
|
public static final int TYPE_stts = Util.getIntegerCodeForString("stts");
|
||||||
public static final int TYPE_stss = Util.getIntegerCodeForString("stss");
|
public static final int TYPE_stss = Util.getIntegerCodeForString("stss");
|
||||||
|
|
|
||||||
|
|
@ -226,20 +226,18 @@ public final class FragmentedMp4Extractor implements Extractor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldParseAtom(atomType)) {
|
if (shouldParseContainerAtom(atomType)) {
|
||||||
if (shouldParseContainerAtom(atomType)) {
|
long endPosition = input.getPosition() + atomSize - Atom.HEADER_SIZE;
|
||||||
long endPosition = input.getPosition() + atomSize - Atom.HEADER_SIZE;
|
containerAtoms.add(new ContainerAtom(atomType, endPosition));
|
||||||
containerAtoms.add(new ContainerAtom(atomType, endPosition));
|
enterReadingAtomHeaderState();
|
||||||
enterReadingAtomHeaderState();
|
} else if (shouldParseLeafAtom(atomType)) {
|
||||||
} else {
|
// We don't support parsing of leaf atoms that define extended atom sizes, or that have
|
||||||
// We don't support parsing of leaf atoms that define extended atom sizes, or that have
|
// lengths greater than Integer.MAX_VALUE.
|
||||||
// lengths greater than Integer.MAX_VALUE.
|
checkState(atomHeaderBytesRead == Atom.HEADER_SIZE);
|
||||||
checkState(atomHeaderBytesRead == Atom.HEADER_SIZE);
|
checkState(atomSize <= Integer.MAX_VALUE);
|
||||||
checkState(atomSize <= Integer.MAX_VALUE);
|
atomData = new ParsableByteArray((int) atomSize);
|
||||||
atomData = new ParsableByteArray((int) atomSize);
|
System.arraycopy(atomHeader.data, 0, atomData.data, 0, Atom.HEADER_SIZE);
|
||||||
System.arraycopy(atomHeader.data, 0, atomData.data, 0, Atom.HEADER_SIZE);
|
parserState = STATE_READING_ATOM_PAYLOAD;
|
||||||
parserState = STATE_READING_ATOM_PAYLOAD;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// We don't support skipping of atoms that have lengths greater than Integer.MAX_VALUE.
|
// We don't support skipping of atoms that have lengths greater than Integer.MAX_VALUE.
|
||||||
checkState(atomSize <= Integer.MAX_VALUE);
|
checkState(atomSize <= Integer.MAX_VALUE);
|
||||||
|
|
@ -795,25 +793,20 @@ public final class FragmentedMp4Extractor implements Extractor {
|
||||||
return 1 + vectorSize + subsampleDataLength;
|
return 1 + vectorSize + subsampleDataLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether the extractor should parse an atom with type {@code atom}. */
|
/** Returns whether the extractor should parse a leaf atom with type {@code atom}. */
|
||||||
private static boolean shouldParseAtom(int atom) {
|
private static boolean shouldParseLeafAtom(int atom) {
|
||||||
return atom == Atom.TYPE_avc1 || atom == Atom.TYPE_avc3 || atom == Atom.TYPE_esds
|
return atom == Atom.TYPE_hdlr || atom == Atom.TYPE_mdhd || atom == Atom.TYPE_mvhd
|
||||||
|| atom == Atom.TYPE_hdlr || atom == Atom.TYPE_mdat || atom == Atom.TYPE_mdhd
|
|| atom == Atom.TYPE_sidx || atom == Atom.TYPE_stsd || atom == Atom.TYPE_tfdt
|
||||||
|| atom == Atom.TYPE_moof || atom == Atom.TYPE_moov || atom == Atom.TYPE_mp4a
|
|| atom == Atom.TYPE_tfhd || atom == Atom.TYPE_tkhd || atom == Atom.TYPE_trex
|
||||||
|| atom == Atom.TYPE_mvhd || atom == Atom.TYPE_sidx || atom == Atom.TYPE_stsd
|
|| atom == Atom.TYPE_trun || atom == Atom.TYPE_pssh || atom == Atom.TYPE_saiz
|
||||||
|| atom == Atom.TYPE_tfdt || atom == Atom.TYPE_tfhd || atom == Atom.TYPE_tkhd
|
|| atom == Atom.TYPE_saio || atom == Atom.TYPE_senc || atom == Atom.TYPE_uuid;
|
||||||
|| atom == Atom.TYPE_traf || atom == Atom.TYPE_trak || atom == Atom.TYPE_trex
|
|
||||||
|| atom == Atom.TYPE_trun || atom == Atom.TYPE_mvex || atom == Atom.TYPE_mdia
|
|
||||||
|| atom == Atom.TYPE_minf || atom == Atom.TYPE_stbl || atom == Atom.TYPE_pssh
|
|
||||||
|| atom == Atom.TYPE_saiz || atom == Atom.TYPE_saio || atom == Atom.TYPE_uuid
|
|
||||||
|| atom == Atom.TYPE_senc || atom == Atom.TYPE_pasp || atom == Atom.TYPE_s263;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether the extractor should parse a container atom with type {@code atom}. */
|
/** Returns whether the extractor should parse a container atom with type {@code atom}. */
|
||||||
private static boolean shouldParseContainerAtom(int atom) {
|
private static boolean shouldParseContainerAtom(int atom) {
|
||||||
return atom == Atom.TYPE_moov || atom == Atom.TYPE_trak || atom == Atom.TYPE_mdia
|
return atom == Atom.TYPE_moov || atom == Atom.TYPE_trak || atom == Atom.TYPE_mdia
|
||||||
|| atom == Atom.TYPE_minf || atom == Atom.TYPE_stbl || atom == Atom.TYPE_avcC
|
|| atom == Atom.TYPE_minf || atom == Atom.TYPE_stbl || atom == Atom.TYPE_moof
|
||||||
|| atom == Atom.TYPE_moof || atom == Atom.TYPE_traf || atom == Atom.TYPE_mvex;
|
|| atom == Atom.TYPE_traf || atom == Atom.TYPE_mvex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -384,12 +384,10 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
||||||
/** Returns whether the extractor should parse a leaf atom with type {@code atom}. */
|
/** Returns whether the extractor should parse a leaf atom with type {@code atom}. */
|
||||||
private static boolean shouldParseLeafAtom(int atom) {
|
private static boolean shouldParseLeafAtom(int atom) {
|
||||||
return atom == Atom.TYPE_mdhd || atom == Atom.TYPE_mvhd || atom == Atom.TYPE_hdlr
|
return atom == Atom.TYPE_mdhd || atom == Atom.TYPE_mvhd || atom == Atom.TYPE_hdlr
|
||||||
|| atom == Atom.TYPE_vmhd || atom == Atom.TYPE_smhd || atom == Atom.TYPE_stsd
|
|| atom == Atom.TYPE_stsd || atom == Atom.TYPE_stts || atom == Atom.TYPE_stss
|
||||||
|| atom == Atom.TYPE_avc1 || atom == Atom.TYPE_avcC || atom == Atom.TYPE_mp4a
|
|
||||||
|| atom == Atom.TYPE_esds || atom == Atom.TYPE_stts || atom == Atom.TYPE_stss
|
|
||||||
|| atom == Atom.TYPE_ctts || atom == Atom.TYPE_elst || atom == Atom.TYPE_stsc
|
|| atom == Atom.TYPE_ctts || atom == Atom.TYPE_elst || atom == Atom.TYPE_stsc
|
||||||
|| atom == Atom.TYPE_stsz || atom == Atom.TYPE_stco || atom == Atom.TYPE_co64
|
|| atom == Atom.TYPE_stsz || atom == Atom.TYPE_stco || atom == Atom.TYPE_co64
|
||||||
|| atom == Atom.TYPE_tkhd || atom == Atom.TYPE_s263;
|
|| atom == Atom.TYPE_tkhd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether the extractor should parse a container atom with type {@code atom}. */
|
/** Returns whether the extractor should parse a container atom with type {@code atom}. */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue