mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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.extractor.TrackOutput;
|
||||||
import com.google.android.exoplayer2.testutil.Dumper.Dumpable;
|
import com.google.android.exoplayer2.testutil.Dumper.Dumpable;
|
||||||
import com.google.android.exoplayer2.upstream.DataReader;
|
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.Function;
|
||||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
@ -44,6 +45,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
||||||
|
|
||||||
private byte[] sampleData;
|
private byte[] sampleData;
|
||||||
private int formatCount;
|
private int formatCount;
|
||||||
|
private boolean receivedSampleInFormat;
|
||||||
|
|
||||||
@Nullable public Format lastFormat;
|
@Nullable public Format lastFormat;
|
||||||
|
|
||||||
|
|
@ -52,6 +54,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
||||||
dumpables = new ArrayList<>();
|
dumpables = new ArrayList<>();
|
||||||
sampleData = Util.EMPTY_BYTE_ARRAY;
|
sampleData = Util.EMPTY_BYTE_ARRAY;
|
||||||
formatCount = 0;
|
formatCount = 0;
|
||||||
|
receivedSampleInFormat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
|
@ -59,10 +62,15 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
||||||
dumpables.clear();
|
dumpables.clear();
|
||||||
sampleData = Util.EMPTY_BYTE_ARRAY;
|
sampleData = Util.EMPTY_BYTE_ARRAY;
|
||||||
formatCount = 0;
|
formatCount = 0;
|
||||||
|
receivedSampleInFormat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void format(Format format) {
|
public void format(Format format) {
|
||||||
|
Assertions.checkState(
|
||||||
|
receivedSampleInFormat,
|
||||||
|
"TrackOutput must receive at least one sampleMetadata() call between format() calls.");
|
||||||
|
receivedSampleInFormat = false;
|
||||||
addFormat(format);
|
addFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,6 +103,7 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
|
||||||
int size,
|
int size,
|
||||||
int offset,
|
int offset,
|
||||||
@Nullable CryptoData cryptoData) {
|
@Nullable CryptoData cryptoData) {
|
||||||
|
receivedSampleInFormat = true;
|
||||||
if (lastFormat == null) {
|
if (lastFormat == null) {
|
||||||
throw new IllegalStateException("TrackOutput must receive format before sampleMetadata");
|
throw new IllegalStateException("TrackOutput must receive format before sampleMetadata");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue