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
This commit is contained in:
olly 2019-12-16 16:18:01 +00:00 committed by Oliver Woodman
parent 88be178e0f
commit 5e822e160e

View File

@ -93,6 +93,12 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
@Override
public void sampleMetadata(long timeUs, @C.BufferFlags int flags, int size, int offset,
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);
sampleFlags.add(flags);
sampleStartOffsets.add(sampleData.length - offset - size);