mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Disallow FakeTrackOutput.format() without sampleMetadata() in between
In general an extractor shouldn't be outputting multiple formats with no samples in between. PiperOrigin-RevId: 305674393
This commit is contained in:
parent
dfd5c512f6
commit
2dafb8fd69
1 changed files with 9 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import com.google.android.exoplayer2.Format;
|
|||
import com.google.android.exoplayer2.extractor.TrackOutput;
|
||||
import com.google.android.exoplayer2.testutil.Dumper.Dumpable;
|
||||
import com.google.android.exoplayer2.upstream.DataReader;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Function;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
|
@ -44,6 +45,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||
|
||||
private byte[] sampleData;
|
||||
private int formatCount;
|
||||
private boolean receivedSampleInFormat;
|
||||
|
||||
@Nullable public Format lastFormat;
|
||||
|
||||
|
|
@ -52,6 +54,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||
dumpables = new ArrayList<>();
|
||||
sampleData = Util.EMPTY_BYTE_ARRAY;
|
||||
formatCount = 0;
|
||||
receivedSampleInFormat = true;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
@ -59,10 +62,15 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||
dumpables.clear();
|
||||
sampleData = Util.EMPTY_BYTE_ARRAY;
|
||||
formatCount = 0;
|
||||
receivedSampleInFormat = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void format(Format format) {
|
||||
Assertions.checkState(
|
||||
receivedSampleInFormat,
|
||||
"TrackOutput must receive at least one sampleMetadata() call between format() calls.");
|
||||
receivedSampleInFormat = false;
|
||||
addFormat(format);
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +103,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
|||
int size,
|
||||
int offset,
|
||||
@Nullable CryptoData cryptoData) {
|
||||
receivedSampleInFormat = true;
|
||||
if (lastFormat == null) {
|
||||
throw new IllegalStateException("TrackOutput must receive format before sampleMetadata");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue