Rename AtomParsers to BoxParsers
This commit is contained in:
parent
0b5443c450
commit
6ba9c9ff9e
@ -62,7 +62,7 @@ import java.util.Objects;
|
||||
|
||||
/** Utility methods for parsing MP4 format atom payloads according to ISO/IEC 14496-12. */
|
||||
@SuppressWarnings("ConstantField")
|
||||
public final class AtomParsers {
|
||||
public final class BoxParsers {
|
||||
|
||||
private static final String TAG = "AtomParsers";
|
||||
|
||||
@ -2274,7 +2274,7 @@ public final class AtomParsers {
|
||||
&& editEndTime <= duration;
|
||||
}
|
||||
|
||||
private AtomParsers() {
|
||||
private BoxParsers() {
|
||||
// Prevent instantiation.
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||
import static androidx.media3.common.util.Assertions.checkState;
|
||||
import static androidx.media3.common.util.Util.castNonNull;
|
||||
import static androidx.media3.common.util.Util.nullSafeArrayCopy;
|
||||
import static androidx.media3.extractor.mp4.AtomParsers.parseTraks;
|
||||
import static androidx.media3.extractor.mp4.BoxParsers.parseTraks;
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||
|
||||
@ -778,7 +778,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
}
|
||||
atom.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = atom.readInt();
|
||||
int version = AtomParsers.parseFullAtomVersion(fullAtom);
|
||||
int version = BoxParsers.parseFullAtomVersion(fullAtom);
|
||||
String schemeIdUri;
|
||||
String value;
|
||||
long timescale;
|
||||
@ -884,7 +884,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
private static long parseMehd(ParsableByteArray mehd) {
|
||||
mehd.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = mehd.readInt();
|
||||
int version = AtomParsers.parseFullAtomVersion(fullAtom);
|
||||
int version = BoxParsers.parseFullAtomVersion(fullAtom);
|
||||
return version == 0 ? mehd.readUnsignedInt() : mehd.readUnsignedLongToLong();
|
||||
}
|
||||
|
||||
@ -1006,7 +1006,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
int vectorSize = encryptionBox.perSampleIvSize;
|
||||
saiz.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = saiz.readInt();
|
||||
int flags = AtomParsers.parseFullAtomFlags(fullAtom);
|
||||
int flags = BoxParsers.parseFullAtomFlags(fullAtom);
|
||||
if ((flags & 0x01) == 1) {
|
||||
saiz.skipBytes(8);
|
||||
}
|
||||
@ -1050,7 +1050,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
private static void parseSaio(ParsableByteArray saio, TrackFragment out) throws ParserException {
|
||||
saio.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = saio.readInt();
|
||||
int flags = AtomParsers.parseFullAtomFlags(fullAtom);
|
||||
int flags = BoxParsers.parseFullAtomFlags(fullAtom);
|
||||
if ((flags & 0x01) == 1) {
|
||||
saio.skipBytes(8);
|
||||
}
|
||||
@ -1062,7 +1062,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
"Unexpected saio entry count: " + entryCount, /* cause= */ null);
|
||||
}
|
||||
|
||||
int version = AtomParsers.parseFullAtomVersion(fullAtom);
|
||||
int version = BoxParsers.parseFullAtomVersion(fullAtom);
|
||||
out.auxiliaryDataPosition +=
|
||||
version == 0 ? saio.readUnsignedInt() : saio.readUnsignedLongToLong();
|
||||
}
|
||||
@ -1084,7 +1084,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
ParsableByteArray tfhd, SparseArray<TrackBundle> trackBundles, boolean haveSideloadedTrack) {
|
||||
tfhd.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = tfhd.readInt();
|
||||
int atomFlags = AtomParsers.parseFullAtomFlags(fullAtom);
|
||||
int atomFlags = BoxParsers.parseFullAtomFlags(fullAtom);
|
||||
int trackId = tfhd.readInt();
|
||||
@Nullable
|
||||
TrackBundle trackBundle =
|
||||
@ -1133,7 +1133,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
private static long parseTfdt(ParsableByteArray tfdt) {
|
||||
tfdt.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = tfdt.readInt();
|
||||
int version = AtomParsers.parseFullAtomVersion(fullAtom);
|
||||
int version = BoxParsers.parseFullAtomVersion(fullAtom);
|
||||
return version == 1 ? tfdt.readUnsignedLongToLong() : tfdt.readUnsignedInt();
|
||||
}
|
||||
|
||||
@ -1176,7 +1176,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
throws ParserException {
|
||||
trun.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = trun.readInt();
|
||||
int atomFlags = AtomParsers.parseFullAtomFlags(fullAtom);
|
||||
int atomFlags = BoxParsers.parseFullAtomFlags(fullAtom);
|
||||
|
||||
Track track = trackBundle.moovSampleTable.track;
|
||||
TrackFragment fragment = trackBundle.fragment;
|
||||
@ -1287,7 +1287,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
throws ParserException {
|
||||
senc.setPosition(Mp4Box.HEADER_SIZE + offset);
|
||||
int fullAtom = senc.readInt();
|
||||
int flags = AtomParsers.parseFullAtomFlags(fullAtom);
|
||||
int flags = BoxParsers.parseFullAtomFlags(fullAtom);
|
||||
|
||||
if ((flags & 0x01 /* override_track_encryption_box_parameters */) != 0) {
|
||||
// TODO: Implement this.
|
||||
@ -1340,7 +1340,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
}
|
||||
|
||||
sbgp.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int sbgpVersion = AtomParsers.parseFullAtomVersion(sbgp.readInt());
|
||||
int sbgpVersion = BoxParsers.parseFullAtomVersion(sbgp.readInt());
|
||||
sbgp.skipBytes(4); // grouping_type == seig.
|
||||
if (sbgpVersion == 1) {
|
||||
sbgp.skipBytes(4); // grouping_type_parameter.
|
||||
@ -1351,7 +1351,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
}
|
||||
|
||||
sgpd.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int sgpdVersion = AtomParsers.parseFullAtomVersion(sgpd.readInt());
|
||||
int sgpdVersion = BoxParsers.parseFullAtomVersion(sgpd.readInt());
|
||||
sgpd.skipBytes(4); // grouping_type == seig.
|
||||
if (sgpdVersion == 1) {
|
||||
if (sgpd.readUnsignedInt() == 0) {
|
||||
@ -1408,7 +1408,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
throws ParserException {
|
||||
atom.setPosition(Mp4Box.HEADER_SIZE);
|
||||
int fullAtom = atom.readInt();
|
||||
int version = AtomParsers.parseFullAtomVersion(fullAtom);
|
||||
int version = BoxParsers.parseFullAtomVersion(fullAtom);
|
||||
|
||||
atom.skipBytes(4);
|
||||
long timescale = atom.readUnsignedInt();
|
||||
|
@ -372,7 +372,7 @@ import com.google.common.collect.ImmutableList;
|
||||
int atomType = data.readInt();
|
||||
if (atomType == Mp4Box.TYPE_data) {
|
||||
int fullVersionInt = data.readInt();
|
||||
int flags = AtomParsers.parseFullAtomFlags(fullVersionInt);
|
||||
int flags = BoxParsers.parseFullAtomFlags(fullVersionInt);
|
||||
@Nullable String mimeType = flags == 13 ? "image/jpeg" : flags == 14 ? "image/png" : null;
|
||||
if (mimeType == null) {
|
||||
Log.w(TAG, "Unrecognized cover art flags: " + flags);
|
||||
|
@ -28,7 +28,7 @@ import static androidx.media3.container.Mp4Util.EDITABLE_TRACK_TYPE_DEPTH_INVERS
|
||||
import static androidx.media3.container.Mp4Util.EDITABLE_TRACK_TYPE_DEPTH_LINEAR;
|
||||
import static androidx.media3.container.Mp4Util.EDITABLE_TRACK_TYPE_DEPTH_METADATA;
|
||||
import static androidx.media3.container.Mp4Util.EDITABLE_TRACK_TYPE_SHARP;
|
||||
import static androidx.media3.extractor.mp4.AtomParsers.parseTraks;
|
||||
import static androidx.media3.extractor.mp4.BoxParsers.parseTraks;
|
||||
import static androidx.media3.extractor.mp4.MetadataUtil.findMdtaMetadataEntryWithKey;
|
||||
import static androidx.media3.extractor.mp4.Sniffer.BRAND_HEIC;
|
||||
import static androidx.media3.extractor.mp4.Sniffer.BRAND_QUICKTIME;
|
||||
@ -657,7 +657,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
||||
List<@C.AuxiliaryTrackType Integer> auxiliaryTrackTypesForEditableVideoTracks =
|
||||
new ArrayList<>();
|
||||
if (meta != null) {
|
||||
mdtaMetadata = AtomParsers.parseMdtaFromMeta(meta);
|
||||
mdtaMetadata = BoxParsers.parseMdtaFromMeta(meta);
|
||||
if (readingEditableVideoTracks) {
|
||||
checkStateNotNull(mdtaMetadata);
|
||||
maybeSetDefaultSampleOffsetForEditableVideoTracks(mdtaMetadata);
|
||||
@ -678,13 +678,13 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
||||
@Nullable Metadata udtaMetadata = null;
|
||||
@Nullable Mp4Box.LeafBox udta = moov.getLeafBoxOfType(Mp4Box.TYPE_udta);
|
||||
if (udta != null) {
|
||||
udtaMetadata = AtomParsers.parseUdta(udta);
|
||||
udtaMetadata = BoxParsers.parseUdta(udta);
|
||||
gaplessInfoHolder.setFromMetadata(udtaMetadata);
|
||||
}
|
||||
|
||||
Metadata mvhdMetadata =
|
||||
new Metadata(
|
||||
AtomParsers.parseMvhd(checkNotNull(moov.getLeafBoxOfType(Mp4Box.TYPE_mvhd)).data));
|
||||
BoxParsers.parseMvhd(checkNotNull(moov.getLeafBoxOfType(Mp4Box.TYPE_mvhd)).data));
|
||||
|
||||
boolean ignoreEditLists = (flags & FLAG_WORKAROUND_IGNORE_EDIT_LISTS) != 0;
|
||||
List<TrackSampleTable> trackSampleTables =
|
||||
@ -1056,7 +1056,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
|
||||
private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input) throws IOException {
|
||||
scratch.reset(8);
|
||||
input.peekFully(scratch.getData(), 0, 8);
|
||||
AtomParsers.maybeSkipRemainingMetaAtomHeaderBytes(scratch);
|
||||
BoxParsers.maybeSkipRemainingMetaAtomHeaderBytes(scratch);
|
||||
input.skipFully(scratch.getPosition());
|
||||
input.resetPeekPosition();
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public final class PsshAtomUtil {
|
||||
Log.w(TAG, "Atom type is not pssh: " + atomType);
|
||||
return null;
|
||||
}
|
||||
int atomVersion = AtomParsers.parseFullAtomVersion(atomData.readInt());
|
||||
int atomVersion = BoxParsers.parseFullAtomVersion(atomData.readInt());
|
||||
if (atomVersion > 1) {
|
||||
Log.w(TAG, "Unsupported pssh version: " + atomVersion);
|
||||
return null;
|
||||
|
@ -26,9 +26,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Tests for {@link AtomParsers}. */
|
||||
/** Tests for {@link BoxParsers}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class AtomParsersTest {
|
||||
public final class BoxParsersTest {
|
||||
|
||||
private static final String ATOM_HEADER = "000000000000000000000000";
|
||||
private static final String SAMPLE_COUNT = "00000004";
|
||||
@ -248,7 +248,7 @@ public final class AtomParsersTest {
|
||||
0, 0, 0, 0, 88, 88, 88, 88
|
||||
}; // version (1), flags (3), 'xxxx' (4)
|
||||
assertThat(
|
||||
AtomParsers.parseCommonEncryptionSinfFromParent(
|
||||
BoxParsers.parseCommonEncryptionSinfFromParent(
|
||||
new ParsableByteArray(cencSinf), 0, cencSinf.length))
|
||||
.isNull();
|
||||
}
|
||||
@ -271,17 +271,17 @@ public final class AtomParsersTest {
|
||||
|
||||
@Test
|
||||
public void vexuParsings() throws ParserException {
|
||||
AtomParsers.VexuData vexuData = null;
|
||||
BoxParsers.VexuData vexuData = null;
|
||||
assertThat(
|
||||
vexuData =
|
||||
AtomParsers.parseVideoExtendedUsageBox(
|
||||
BoxParsers.parseVideoExtendedUsageBox(
|
||||
new ParsableByteArray(VEXU_DATA0), 0, VEXU_DATA0.length))
|
||||
.isNotNull();
|
||||
assertThat(vexuData).isNotNull();
|
||||
assertThat(vexuData.hasBothEyeViews()).isTrue();
|
||||
assertThat(
|
||||
vexuData =
|
||||
AtomParsers.parseVideoExtendedUsageBox(
|
||||
BoxParsers.parseVideoExtendedUsageBox(
|
||||
new ParsableByteArray(VEXU_DATA1), 0, VEXU_DATA1.length))
|
||||
.isNotNull();
|
||||
assertThat(vexuData).isNotNull();
|
||||
@ -289,7 +289,7 @@ public final class AtomParsersTest {
|
||||
}
|
||||
|
||||
private static void verifyStz2Parsing(Mp4Box.LeafBox stz2Atom) {
|
||||
AtomParsers.Stz2SampleSizeBox box = new AtomParsers.Stz2SampleSizeBox(stz2Atom);
|
||||
BoxParsers.Stz2SampleSizeBox box = new BoxParsers.Stz2SampleSizeBox(stz2Atom);
|
||||
assertThat(box.getSampleCount()).isEqualTo(4);
|
||||
assertThat(box.getFixedSampleSize()).isEqualTo(C.LENGTH_UNSET);
|
||||
for (int i = 0; i < box.getSampleCount(); i++) {
|
@ -17,8 +17,8 @@ package androidx.media3.extractor.mp4;
|
||||
|
||||
import static androidx.media3.common.C.WIDEVINE_UUID;
|
||||
import static androidx.media3.container.Mp4Box.TYPE_pssh;
|
||||
import static androidx.media3.extractor.mp4.AtomParsers.parseFullAtomFlags;
|
||||
import static androidx.media3.extractor.mp4.AtomParsers.parseFullAtomVersion;
|
||||
import static androidx.media3.extractor.mp4.BoxParsers.parseFullAtomFlags;
|
||||
import static androidx.media3.extractor.mp4.BoxParsers.parseFullAtomVersion;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.media3.common.C;
|
||||
|
Loading…
x
Reference in New Issue
Block a user