Add nullness annotations to TsExtractors
#exofixit PiperOrigin-RevId: 396658717
This commit is contained in:
parent
4d668f1b7b
commit
92bf5d80c7
@ -48,6 +48,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||||
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
/** Extracts data from the MPEG-2 TS container format. */
|
/** Extracts data from the MPEG-2 TS container format. */
|
||||||
public final class TsExtractor implements Extractor {
|
public final class TsExtractor implements Extractor {
|
||||||
@ -110,7 +112,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
private static final int BUFFER_SIZE = TS_PACKET_SIZE * 50;
|
private static final int BUFFER_SIZE = TS_PACKET_SIZE * 50;
|
||||||
private static final int SNIFF_TS_PACKET_COUNT = 5;
|
private static final int SNIFF_TS_PACKET_COUNT = 5;
|
||||||
|
|
||||||
private final @Mode int mode;
|
@Mode private final int mode;
|
||||||
private final int timestampSearchBytes;
|
private final int timestampSearchBytes;
|
||||||
private final List<TimestampAdjuster> timestampAdjusters;
|
private final List<TimestampAdjuster> timestampAdjusters;
|
||||||
private final ParsableByteArray tsPacketBuffer;
|
private final ParsableByteArray tsPacketBuffer;
|
||||||
@ -122,13 +124,13 @@ public final class TsExtractor implements Extractor {
|
|||||||
private final TsDurationReader durationReader;
|
private final TsDurationReader durationReader;
|
||||||
|
|
||||||
// Accessed only by the loading thread.
|
// Accessed only by the loading thread.
|
||||||
private TsBinarySearchSeeker tsBinarySearchSeeker;
|
private @MonotonicNonNull TsBinarySearchSeeker tsBinarySearchSeeker;
|
||||||
private ExtractorOutput output;
|
private ExtractorOutput output;
|
||||||
private int remainingPmts;
|
private int remainingPmts;
|
||||||
private boolean tracksEnded;
|
private boolean tracksEnded;
|
||||||
private boolean hasOutputSeekMap;
|
private boolean hasOutputSeekMap;
|
||||||
private boolean pendingSeekToStart;
|
private boolean pendingSeekToStart;
|
||||||
private TsPayloadReader id3Reader;
|
@Nullable private TsPayloadReader id3Reader;
|
||||||
private int bytesSinceLastSync;
|
private int bytesSinceLastSync;
|
||||||
private int pcrPid;
|
private int pcrPid;
|
||||||
|
|
||||||
@ -214,6 +216,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
tsPayloadReaders = new SparseArray<>();
|
tsPayloadReaders = new SparseArray<>();
|
||||||
continuityCounters = new SparseIntArray();
|
continuityCounters = new SparseIntArray();
|
||||||
durationReader = new TsDurationReader(timestampSearchBytes);
|
durationReader = new TsDurationReader(timestampSearchBytes);
|
||||||
|
output = ExtractorOutput.PLACEHOLDER;
|
||||||
pcrPid = -1;
|
pcrPid = -1;
|
||||||
resetPayloadReaders();
|
resetPayloadReaders();
|
||||||
}
|
}
|
||||||
@ -289,8 +292,8 @@ public final class TsExtractor implements Extractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @ReadResult int read(ExtractorInput input, PositionHolder seekPosition)
|
@ReadResult
|
||||||
throws IOException {
|
public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
|
||||||
long inputLength = input.getLength();
|
long inputLength = input.getLength();
|
||||||
if (tracksEnded) {
|
if (tracksEnded) {
|
||||||
boolean canReadDuration = inputLength != C.LENGTH_UNSET && mode != MODE_HLS;
|
boolean canReadDuration = inputLength != C.LENGTH_UNSET && mode != MODE_HLS;
|
||||||
@ -549,7 +552,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
private static final int TS_PMT_DESC_DVB_EXT_AC4 = 0x15;
|
private static final int TS_PMT_DESC_DVB_EXT_AC4 = 0x15;
|
||||||
|
|
||||||
private final ParsableBitArray pmtScratch;
|
private final ParsableBitArray pmtScratch;
|
||||||
private final SparseArray<TsPayloadReader> trackIdToReaderScratch;
|
private final SparseArray<@NullableType TsPayloadReader> trackIdToReaderScratch;
|
||||||
private final SparseIntArray trackIdToPidScratch;
|
private final SparseIntArray trackIdToPidScratch;
|
||||||
private final int pid;
|
private final int pid;
|
||||||
|
|
||||||
@ -618,11 +621,13 @@ public final class TsExtractor implements Extractor {
|
|||||||
// appears intermittently during playback. See [Internal: b/20261500].
|
// appears intermittently during playback. See [Internal: b/20261500].
|
||||||
EsInfo id3EsInfo = new EsInfo(TS_STREAM_TYPE_ID3, null, null, Util.EMPTY_BYTE_ARRAY);
|
EsInfo id3EsInfo = new EsInfo(TS_STREAM_TYPE_ID3, null, null, Util.EMPTY_BYTE_ARRAY);
|
||||||
id3Reader = payloadReaderFactory.createPayloadReader(TS_STREAM_TYPE_ID3, id3EsInfo);
|
id3Reader = payloadReaderFactory.createPayloadReader(TS_STREAM_TYPE_ID3, id3EsInfo);
|
||||||
|
if (id3Reader != null) {
|
||||||
id3Reader.init(
|
id3Reader.init(
|
||||||
timestampAdjuster,
|
timestampAdjuster,
|
||||||
output,
|
output,
|
||||||
new TrackIdGenerator(programNumber, TS_STREAM_TYPE_ID3, MAX_PID_PLUS_ONE));
|
new TrackIdGenerator(programNumber, TS_STREAM_TYPE_ID3, MAX_PID_PLUS_ONE));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
trackIdToReaderScratch.clear();
|
trackIdToReaderScratch.clear();
|
||||||
trackIdToPidScratch.clear();
|
trackIdToPidScratch.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user