Commit 2fe3e188 by olly Committed by Oliver Woodman

FakeTrackOutput: Throw if sample size exceeds maxInputSize

This indicates the extractor has output a Format with a specified
maxInputSize that's too small. Failing in FakeTrackOutput ensures
this doesn't happen during Extractor tests.

PiperOrigin-RevId: 285776069
parent 4eb06373
...@@ -93,6 +93,12 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable { ...@@ -93,6 +93,12 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
@Override @Override
public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset, public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset,
CryptoData cryptoData) { CryptoData cryptoData) {
if (format == null) {
throw new IllegalStateException("TrackOutput must receive format before sampleMetadata");
}
if (format.maxInputSize != Format.NO_VALUE && size > format.maxInputSize) {
throw new IllegalStateException("Sample size exceeds Format.maxInputSize");
}
sampleTimesUs.add(timeUs); sampleTimesUs.add(timeUs);
sampleFlags.add(flags); sampleFlags.add(flags);
sampleStartOffsets.add(sampleData.length - offset - size); sampleStartOffsets.add(sampleData.length - offset - size);
......
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