Commit 8e09cf45 by kimvde Committed by Oliver Woodman

Fix bug unseekable FMP4

The seek start position was set to the first mdat but this box was
always skipped because the moof box was not read.

PiperOrigin-RevId: 318762126
parent c9717f67
......@@ -374,16 +374,16 @@ public class FragmentedMp4Extractor implements Extractor {
fragment.auxiliaryDataPosition = atomPosition;
fragment.dataPosition = atomPosition;
}
if (!haveOutputSeekMap) {
// This must be the first moof in the stream.
extractorOutput.seekMap(new SeekMap.Unseekable(durationUs, atomPosition));
haveOutputSeekMap = true;
}
}
if (atomType == Atom.TYPE_mdat) {
currentTrackBundle = null;
endOfMdatPosition = atomPosition + atomSize;
if (!haveOutputSeekMap) {
// This must be the first mdat in the stream.
extractorOutput.seekMap(new SeekMap.Unseekable(durationUs, atomPosition));
haveOutputSeekMap = true;
}
parserState = STATE_READING_ENCRYPTION_DATA;
return true;
}
......
seekMap:
isSeekable = false
duration = UNSET TIME
getPosition(0) = [[timeUs=0, position=1828]]
getPosition(0) = [[timeUs=0, position=1244]]
numberOfTracks = 2
track 0:
total output bytes = 85933
......
seekMap:
isSeekable = false
duration = UNSET TIME
getPosition(0) = [[timeUs=0, position=1828]]
getPosition(0) = [[timeUs=0, position=1244]]
numberOfTracks = 2
track 0:
total output bytes = 85933
......
seekMap:
isSeekable = false
duration = UNSET TIME
getPosition(0) = [[timeUs=0, position=1828]]
getPosition(0) = [[timeUs=0, position=1244]]
numberOfTracks = 3
track 0:
total output bytes = 85933
......
seekMap:
isSeekable = false
duration = UNSET TIME
getPosition(0) = [[timeUs=0, position=1828]]
getPosition(0) = [[timeUs=0, position=1244]]
numberOfTracks = 3
track 0:
total output bytes = 85933
......
......@@ -341,21 +341,25 @@ public final class ExtractorAsserts {
extractorOutput.assertOutput(context, dumpFilesPrefix + ".0" + DUMP_EXTENSION);
}
// If the SeekMap is seekable, test seeking in the stream.
SeekMap seekMap = Assertions.checkNotNull(extractorOutput.seekMap);
if (seekMap.isSeekable()) {
long durationUs = seekMap.getDurationUs();
for (int j = 0; j < 4; j++) {
extractorOutput.clearTrackOutputs();
long timeUs = durationUs == C.TIME_UNSET ? 0 : (durationUs * j) / 3;
long position = seekMap.getSeekPoints(timeUs).first.position;
input.reset();
input.setPosition((int) position);
consumeTestData(extractor, input, timeUs, extractorOutput, false);
long durationUs = seekMap.getDurationUs();
// Only seek to the timeUs=0 if the SeekMap is unseekable or the duration is unknown.
int numberSeekTests = seekMap.isSeekable() && durationUs != C.TIME_UNSET ? 4 : 1;
for (int j = 0; j < numberSeekTests; j++) {
long timeUs = durationUs * j / 3;
long position = seekMap.getSeekPoints(timeUs).first.position;
if (timeUs == 0 && position == 0) {
// Already tested.
continue;
}
input.reset();
input.setPosition((int) position);
extractorOutput.clearTrackOutputs();
consumeTestData(extractor, input, timeUs, extractorOutput, false);
if (simulateUnknownLength && timeUs == 0) {
extractorOutput.assertOutput(context, dumpFilesPrefix + UNKNOWN_LENGTH_EXTENSION);
} else {
extractorOutput.assertOutput(context, dumpFilesPrefix + '.' + j + DUMP_EXTENSION);
if (durationUs == C.TIME_UNSET) {
break;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment