Skip to content

Commit b16b80f

Browse files
committed
Fix bug for failing tests
1 parent b82db42 commit b16b80f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ private boolean readAtomHeader(ExtractorInput input) throws IOException {
645645

646646
if (shouldParseContainerAtom(atomType)) {
647647
long endPosition = input.getPosition() + atomSize - Mp4Box.HEADER_SIZE;
648+
if (atomSize != atomHeaderBytesRead && atomType == Mp4Box.TYPE_meta) {
649+
maybeSkipRemainingMetaAtomHeaderBytes(input);
650+
}
648651
containerAtoms.push(new ContainerBox(atomType, endPosition));
649652
if (atomSize == atomHeaderBytesRead) {
650653
processAtomEnded(endPosition);
@@ -677,6 +680,14 @@ private boolean readAtomHeader(ExtractorInput input) throws IOException {
677680
return true;
678681
}
679682

683+
private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input) throws IOException {
684+
scratch.reset(Mp4Box.HEADER_SIZE);
685+
input.peekFully(scratch.getData(), 0, Mp4Box.HEADER_SIZE);
686+
BoxParser.maybeSkipRemainingMetaBoxHeaderBytes(scratch);
687+
input.skipFully(scratch.getPosition());
688+
input.resetPeekPosition();
689+
}
690+
680691
private void readAtomPayload(ExtractorInput input) throws IOException {
681692
int atomPayloadSize = (int) (atomSize - atomHeaderBytesRead);
682693
@Nullable ParsableByteArray atomData = this.atomData;
@@ -1931,6 +1942,7 @@ private static boolean shouldParseLeafAtom(int atom) {
19311942
|| atom == Mp4Box.TYPE_mehd
19321943
|| atom == Mp4Box.TYPE_emsg
19331944
|| atom == Mp4Box.TYPE_udta
1945+
|| atom == Mp4Box.TYPE_keys
19341946
|| atom == Mp4Box.TYPE_ilst;
19351947
}
19361948

libraries/extractor/src/main/java/androidx/media3/extractor/mp4/Mp4Extractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,8 @@ private void processEndOfStreamReadingAtomHeader() {
10851085
}
10861086

10871087
private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input) throws IOException {
1088-
scratch.reset(8);
1089-
input.peekFully(scratch.getData(), 0, 8);
1088+
scratch.reset(Mp4Box.HEADER_SIZE);
1089+
input.peekFully(scratch.getData(), 0, Mp4Box.HEADER_SIZE);
10901090
BoxParser.maybeSkipRemainingMetaBoxHeaderBytes(scratch);
10911091
input.skipFully(scratch.getPosition());
10921092
input.resetPeekPosition();

0 commit comments

Comments
 (0)