Deprecate C.POSITION_UNSET in favour of C.INDEX_UNSET

These have the same value (`-1`), and basically the same meaning (offset
in an array/list/file/byte stream/etc), but 'position' is an overloaded
term in a media playback library, and there's a risk people assume that
methods like `Player.getCurrentPosition()` may return
`C.POSITION_UNSET`, when in fact unset media times (whether duration or
position) are always represented by `C.TIME_UNSET` which is a) a `long`
(not `int`) and b) a different underlying value. (aside:
`getCurrentPosition()` never returns an unset value, but it's a good
example of the ambiguity of the word 'position' between 'byte offset'
and 'media timestamp'.)

PiperOrigin-RevId: 492493102
This commit is contained in:
ibaker 2022-12-02 17:52:16 +00:00 committed by Ian Baker
parent 634c6161f1
commit 3efc62b512
34 changed files with 109 additions and 108 deletions

View File

@ -60,11 +60,13 @@ public final class C {
*/ */
public static final long TIME_UNSET = Long.MIN_VALUE + 1; public static final long TIME_UNSET = Long.MIN_VALUE + 1;
/** Represents an unset or unknown index. */ /** Represents an unset or unknown index or byte position. */
public static final int INDEX_UNSET = -1; public static final int INDEX_UNSET = -1;
/** Represents an unset or unknown position. */ /**
@UnstableApi public static final int POSITION_UNSET = -1; * @deprecated Use {@link #INDEX_UNSET}.
*/
@Deprecated @UnstableApi public static final int POSITION_UNSET = INDEX_UNSET;
/** Represents an unset or unknown rate. */ /** Represents an unset or unknown rate. */
public static final float RATE_UNSET = -Float.MAX_VALUE; public static final float RATE_UNSET = -Float.MAX_VALUE;

View File

@ -116,16 +116,16 @@ public final class CacheWriter {
endPosition = dataSpec.position + dataSpec.length; endPosition = dataSpec.position + dataSpec.length;
} else { } else {
long contentLength = ContentMetadata.getContentLength(cache.getContentMetadata(cacheKey)); long contentLength = ContentMetadata.getContentLength(cache.getContentMetadata(cacheKey));
endPosition = contentLength == C.LENGTH_UNSET ? C.POSITION_UNSET : contentLength; endPosition = contentLength == C.LENGTH_UNSET ? C.INDEX_UNSET : contentLength;
} }
if (progressListener != null) { if (progressListener != null) {
progressListener.onProgress(getLength(), bytesCached, /* newBytesCached= */ 0); progressListener.onProgress(getLength(), bytesCached, /* newBytesCached= */ 0);
} }
while (endPosition == C.POSITION_UNSET || nextPosition < endPosition) { while (endPosition == C.INDEX_UNSET || nextPosition < endPosition) {
throwIfCanceled(); throwIfCanceled();
long maxRemainingLength = long maxRemainingLength =
endPosition == C.POSITION_UNSET ? Long.MAX_VALUE : endPosition - nextPosition; endPosition == C.INDEX_UNSET ? Long.MAX_VALUE : endPosition - nextPosition;
long blockLength = cache.getCachedLength(cacheKey, nextPosition, maxRemainingLength); long blockLength = cache.getCachedLength(cacheKey, nextPosition, maxRemainingLength);
if (blockLength > 0) { if (blockLength > 0) {
nextPosition += blockLength; nextPosition += blockLength;
@ -225,7 +225,7 @@ public final class CacheWriter {
} }
private long getLength() { private long getLength() {
return endPosition == C.POSITION_UNSET ? C.LENGTH_UNSET : endPosition - dataSpec.position; return endPosition == C.INDEX_UNSET ? C.LENGTH_UNSET : endPosition - dataSpec.position;
} }
private void throwIfCanceled() throws InterruptedIOException { private void throwIfCanceled() throws InterruptedIOException {

View File

@ -237,7 +237,7 @@ import java.lang.annotation.Target;
*/ */
@TargetApi(19) // audioTimestamp will be null if Util.SDK_INT < 19. @TargetApi(19) // audioTimestamp will be null if Util.SDK_INT < 19.
public long getTimestampPositionFrames() { public long getTimestampPositionFrames() {
return audioTimestamp != null ? audioTimestamp.getTimestampPositionFrames() : C.POSITION_UNSET; return audioTimestamp != null ? audioTimestamp.getTimestampPositionFrames() : C.INDEX_UNSET;
} }
private void updateState(@State int state) { private void updateState(@State int state) {
@ -246,7 +246,7 @@ import java.lang.annotation.Target;
case STATE_INITIALIZING: case STATE_INITIALIZING:
// Force polling a timestamp immediately, and poll quickly. // Force polling a timestamp immediately, and poll quickly.
lastTimestampSampleTimeUs = 0; lastTimestampSampleTimeUs = 0;
initialTimestampPositionFrames = C.POSITION_UNSET; initialTimestampPositionFrames = C.INDEX_UNSET;
initializeSystemTimeUs = System.nanoTime() / 1000; initializeSystemTimeUs = System.nanoTime() / 1000;
sampleIntervalUs = FAST_POLL_INTERVAL_US; sampleIntervalUs = FAST_POLL_INTERVAL_US;
break; break;

View File

@ -115,7 +115,7 @@ public final class BundledExtractorsAdapter implements ProgressiveMediaExtractor
@Override @Override
public long getCurrentInputPosition() { public long getCurrentInputPosition() {
return extractorInput != null ? extractorInput.getPosition() : C.POSITION_UNSET; return extractorInput != null ? extractorInput.getPosition() : C.INDEX_UNSET;
} }
@Override @Override

View File

@ -128,7 +128,7 @@ public final class MediaParserExtractorAdapter implements ProgressiveMediaExtrac
positionHolder.position = inputReaderAdapter.getAndResetSeekPosition(); positionHolder.position = inputReaderAdapter.getAndResetSeekPosition();
return !shouldContinue return !shouldContinue
? Extractor.RESULT_END_OF_INPUT ? Extractor.RESULT_END_OF_INPUT
: positionHolder.position != C.POSITION_UNSET : positionHolder.position != C.INDEX_UNSET
? Extractor.RESULT_SEEK ? Extractor.RESULT_SEEK
: Extractor.RESULT_CONTINUE; : Extractor.RESULT_CONTINUE;
} }

View File

@ -75,8 +75,8 @@ public interface ProgressiveMediaExtractor {
void disableSeekingOnMp3Streams(); void disableSeekingOnMp3Streams();
/** /**
* Returns the current read position in the input stream, or {@link C#POSITION_UNSET} if no input * Returns the current read position in the input stream, or {@link C#INDEX_UNSET} if no input is
* is available. * available.
*/ */
long getCurrentInputPosition(); long getCurrentInputPosition();

View File

@ -1048,7 +1048,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} finally { } finally {
if (result == Extractor.RESULT_SEEK) { if (result == Extractor.RESULT_SEEK) {
result = Extractor.RESULT_CONTINUE; result = Extractor.RESULT_CONTINUE;
} else if (progressiveMediaExtractor.getCurrentInputPosition() != C.POSITION_UNSET) { } else if (progressiveMediaExtractor.getCurrentInputPosition() != C.INDEX_UNSET) {
positionHolder.position = progressiveMediaExtractor.getCurrentInputPosition(); positionHolder.position = progressiveMediaExtractor.getCurrentInputPosition();
} }
DataSourceUtil.closeQuietly(dataSource); DataSourceUtil.closeQuietly(dataSource);

View File

@ -146,11 +146,11 @@ import java.util.Arrays;
/** /**
* Advances the read position to the specified absolute position. * Advances the read position to the specified absolute position.
* *
* @param absolutePosition The new absolute read position. May be {@link C#POSITION_UNSET}, in * @param absolutePosition The new absolute read position. May be {@link C#INDEX_UNSET}, in which
* which case calling this method is a no-op. * case calling this method is a no-op.
*/ */
public void discardDownstreamTo(long absolutePosition) { public void discardDownstreamTo(long absolutePosition) {
if (absolutePosition == C.POSITION_UNSET) { if (absolutePosition == C.INDEX_UNSET) {
return; return;
} }
while (absolutePosition >= firstAllocationNode.endPosition) { while (absolutePosition >= firstAllocationNode.endPosition) {

View File

@ -754,26 +754,26 @@ public class SampleQueue implements TrackOutput {
private synchronized long discardSampleMetadataTo( private synchronized long discardSampleMetadataTo(
long timeUs, boolean toKeyframe, boolean stopAtReadPosition) { long timeUs, boolean toKeyframe, boolean stopAtReadPosition) {
if (length == 0 || timeUs < timesUs[relativeFirstIndex]) { if (length == 0 || timeUs < timesUs[relativeFirstIndex]) {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
int searchLength = stopAtReadPosition && readPosition != length ? readPosition + 1 : length; int searchLength = stopAtReadPosition && readPosition != length ? readPosition + 1 : length;
int discardCount = findSampleBefore(relativeFirstIndex, searchLength, timeUs, toKeyframe); int discardCount = findSampleBefore(relativeFirstIndex, searchLength, timeUs, toKeyframe);
if (discardCount == -1) { if (discardCount == -1) {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
return discardSamples(discardCount); return discardSamples(discardCount);
} }
public synchronized long discardSampleMetadataToRead() { public synchronized long discardSampleMetadataToRead() {
if (readPosition == 0) { if (readPosition == 0) {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
return discardSamples(readPosition); return discardSamples(readPosition);
} }
private synchronized long discardSampleMetadataToEnd() { private synchronized long discardSampleMetadataToEnd() {
if (length == 0) { if (length == 0) {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
return discardSamples(length); return discardSamples(length);
} }

View File

@ -45,7 +45,7 @@ public final class InputReaderAdapterV30 implements MediaParser.SeekableInputRea
public void setDataReader(DataReader dataReader, long length) { public void setDataReader(DataReader dataReader, long length) {
this.dataReader = dataReader; this.dataReader = dataReader;
resourceLength = length; resourceLength = length;
lastSeekPosition = C.POSITION_UNSET; lastSeekPosition = C.INDEX_UNSET;
} }
/** Sets the absolute position in the resource from which the wrapped {@link DataReader} reads. */ /** Sets the absolute position in the resource from which the wrapped {@link DataReader} reads. */
@ -55,11 +55,11 @@ public final class InputReaderAdapterV30 implements MediaParser.SeekableInputRea
/** /**
* Returns the last value passed to {@link #seekToPosition(long)} and sets the stored value to * Returns the last value passed to {@link #seekToPosition(long)} and sets the stored value to
* {@link C#POSITION_UNSET}. * {@link C#INDEX_UNSET}.
*/ */
public long getAndResetSeekPosition() { public long getAndResetSeekPosition() {
long lastSeekPosition = this.lastSeekPosition; long lastSeekPosition = this.lastSeekPosition;
this.lastSeekPosition = C.POSITION_UNSET; this.lastSeekPosition = C.INDEX_UNSET;
return lastSeekPosition; return lastSeekPosition;
} }

View File

@ -420,7 +420,7 @@ public abstract class BinarySearchSeeker {
@interface Type {} @interface Type {}
public static final TimestampSearchResult NO_TIMESTAMP_IN_RANGE_RESULT = public static final TimestampSearchResult NO_TIMESTAMP_IN_RANGE_RESULT =
new TimestampSearchResult(TYPE_NO_TIMESTAMP, C.TIME_UNSET, C.POSITION_UNSET); new TimestampSearchResult(TYPE_NO_TIMESTAMP, C.TIME_UNSET, C.INDEX_UNSET);
/** The type of the result. */ /** The type of the result. */
private final @Type int type; private final @Type int type;

View File

@ -144,8 +144,8 @@ public final class AviExtractor implements Extractor {
chunkHeaderHolder = new ChunkHeaderHolder(); chunkHeaderHolder = new ChunkHeaderHolder();
extractorOutput = new DummyExtractorOutput(); extractorOutput = new DummyExtractorOutput();
chunkReaders = new ChunkReader[0]; chunkReaders = new ChunkReader[0];
moviStart = C.POSITION_UNSET; moviStart = C.INDEX_UNSET;
moviEnd = C.POSITION_UNSET; moviEnd = C.INDEX_UNSET;
hdrlSize = C.LENGTH_UNSET; hdrlSize = C.LENGTH_UNSET;
durationUs = C.TIME_UNSET; durationUs = C.TIME_UNSET;
} }
@ -156,7 +156,7 @@ public final class AviExtractor implements Extractor {
public void init(ExtractorOutput output) { public void init(ExtractorOutput output) {
this.state = STATE_SKIPPING_TO_HDRL; this.state = STATE_SKIPPING_TO_HDRL;
this.extractorOutput = output; this.extractorOutput = output;
pendingReposition = C.POSITION_UNSET; pendingReposition = C.INDEX_UNSET;
} }
@Override @Override
@ -208,7 +208,7 @@ public final class AviExtractor implements Extractor {
state = STATE_FINDING_MOVI_HEADER; state = STATE_FINDING_MOVI_HEADER;
return RESULT_CONTINUE; return RESULT_CONTINUE;
case STATE_FINDING_MOVI_HEADER: case STATE_FINDING_MOVI_HEADER:
if (moviStart != C.POSITION_UNSET && input.getPosition() != moviStart) { if (moviStart != C.INDEX_UNSET && input.getPosition() != moviStart) {
pendingReposition = moviStart; pendingReposition = moviStart;
return RESULT_CONTINUE; return RESULT_CONTINUE;
} }
@ -275,7 +275,7 @@ public final class AviExtractor implements Extractor {
@Override @Override
public void seek(long position, long timeUs) { public void seek(long position, long timeUs) {
pendingReposition = C.POSITION_UNSET; pendingReposition = C.INDEX_UNSET;
currentChunkReader = null; currentChunkReader = null;
for (ChunkReader chunkReader : chunkReaders) { for (ChunkReader chunkReader : chunkReaders) {
chunkReader.seekToPosition(position); chunkReader.seekToPosition(position);
@ -308,7 +308,7 @@ public final class AviExtractor implements Extractor {
private boolean resolvePendingReposition(ExtractorInput input, PositionHolder seekPosition) private boolean resolvePendingReposition(ExtractorInput input, PositionHolder seekPosition)
throws IOException { throws IOException {
boolean needSeek = false; boolean needSeek = false;
if (pendingReposition != C.POSITION_UNSET) { if (pendingReposition != C.INDEX_UNSET) {
long currentPosition = input.getPosition(); long currentPosition = input.getPosition();
if (pendingReposition < currentPosition if (pendingReposition < currentPosition
|| pendingReposition > currentPosition + RELOAD_MINIMUM_SEEK_DISTANCE) { || pendingReposition > currentPosition + RELOAD_MINIMUM_SEEK_DISTANCE) {
@ -320,7 +320,7 @@ public final class AviExtractor implements Extractor {
input.skipFully((int) (pendingReposition - currentPosition)); input.skipFully((int) (pendingReposition - currentPosition));
} }
} }
pendingReposition = C.POSITION_UNSET; pendingReposition = C.INDEX_UNSET;
return needSeek; return needSeek;
} }

View File

@ -96,7 +96,7 @@ public final class JpegExtractor implements Extractor {
public JpegExtractor() { public JpegExtractor() {
scratch = new ParsableByteArray(EXIF_ID_CODE_LENGTH); scratch = new ParsableByteArray(EXIF_ID_CODE_LENGTH);
mp4StartPosition = C.POSITION_UNSET; mp4StartPosition = C.INDEX_UNSET;
} }
@Override @Override
@ -202,7 +202,7 @@ public final class JpegExtractor implements Extractor {
input.readFully(scratch.getData(), /* offset= */ 0, /* length= */ 2); input.readFully(scratch.getData(), /* offset= */ 0, /* length= */ 2);
marker = scratch.readUnsignedShort(); marker = scratch.readUnsignedShort();
if (marker == MARKER_SOS) { // Start of scan. if (marker == MARKER_SOS) { // Start of scan.
if (mp4StartPosition != C.POSITION_UNSET) { if (mp4StartPosition != C.INDEX_UNSET) {
state = STATE_SNIFFING_MOTION_PHOTO_VIDEO; state = STATE_SNIFFING_MOTION_PHOTO_VIDEO;
} else { } else {
endReadingWithImageTrack(); endReadingWithImageTrack();

View File

@ -81,9 +81,9 @@ import java.util.List;
// Iterate backwards through the items to find the earlier video in the list. If we find a video // Iterate backwards through the items to find the earlier video in the list. If we find a video
// item with length zero, we need to keep scanning backwards to find the preceding item with // item with length zero, we need to keep scanning backwards to find the preceding item with
// non-zero length, which is the item that contains the video data. // non-zero length, which is the item that contains the video data.
long photoStartPosition = C.POSITION_UNSET; long photoStartPosition = C.INDEX_UNSET;
long photoLength = C.LENGTH_UNSET; long photoLength = C.LENGTH_UNSET;
long mp4StartPosition = C.POSITION_UNSET; long mp4StartPosition = C.INDEX_UNSET;
long mp4Length = C.LENGTH_UNSET; long mp4Length = C.LENGTH_UNSET;
boolean itemContainsMp4 = false; boolean itemContainsMp4 = false;
long itemStartPosition = motionPhotoLength; long itemStartPosition = motionPhotoLength;
@ -110,9 +110,9 @@ import java.util.List;
photoLength = itemEndPosition; photoLength = itemEndPosition;
} }
} }
if (mp4StartPosition == C.POSITION_UNSET if (mp4StartPosition == C.INDEX_UNSET
|| mp4Length == C.LENGTH_UNSET || mp4Length == C.LENGTH_UNSET
|| photoStartPosition == C.POSITION_UNSET || photoStartPosition == C.INDEX_UNSET
|| photoLength == C.LENGTH_UNSET) { || photoLength == C.LENGTH_UNSET) {
return null; return null;
} }

View File

@ -33,9 +33,9 @@ public final class ChapterFrame extends Id3Frame {
public final String chapterId; public final String chapterId;
public final int startTimeMs; public final int startTimeMs;
public final int endTimeMs; public final int endTimeMs;
/** The byte offset of the start of the chapter, or {@link C#POSITION_UNSET} if not set. */ /** The byte offset of the start of the chapter, or {@link C#INDEX_UNSET} if not set. */
public final long startOffset; public final long startOffset;
/** The byte offset of the end of the chapter, or {@link C#POSITION_UNSET} if not set. */ /** The byte offset of the end of the chapter, or {@link C#INDEX_UNSET} if not set. */
public final long endOffset; public final long endOffset;
private final Id3Frame[] subFrames; private final Id3Frame[] subFrames;

View File

@ -659,11 +659,11 @@ public final class Id3Decoder extends SimpleMetadataDecoder {
int endTime = id3Data.readInt(); int endTime = id3Data.readInt();
long startOffset = id3Data.readUnsignedInt(); long startOffset = id3Data.readUnsignedInt();
if (startOffset == 0xFFFFFFFFL) { if (startOffset == 0xFFFFFFFFL) {
startOffset = C.POSITION_UNSET; startOffset = C.INDEX_UNSET;
} }
long endOffset = id3Data.readUnsignedInt(); long endOffset = id3Data.readUnsignedInt();
if (endOffset == 0xFFFFFFFFL) { if (endOffset == 0xFFFFFFFFL) {
endOffset = C.POSITION_UNSET; endOffset = C.INDEX_UNSET;
} }
ArrayList<Id3Frame> subFrames = new ArrayList<>(); ArrayList<Id3Frame> subFrames = new ArrayList<>();

View File

@ -396,7 +396,7 @@ public class MatroskaExtractor implements Extractor {
private @MonotonicNonNull ByteBuffer encryptionSubsampleDataBuffer; private @MonotonicNonNull ByteBuffer encryptionSubsampleDataBuffer;
private long segmentContentSize; private long segmentContentSize;
private long segmentContentPosition = C.POSITION_UNSET; private long segmentContentPosition = C.INDEX_UNSET;
private long timecodeScale = C.TIME_UNSET; private long timecodeScale = C.TIME_UNSET;
private long durationTimecode = C.TIME_UNSET; private long durationTimecode = C.TIME_UNSET;
private long durationUs = C.TIME_UNSET; private long durationUs = C.TIME_UNSET;
@ -413,8 +413,8 @@ public class MatroskaExtractor implements Extractor {
// Cue related elements. // Cue related elements.
private boolean seekForCues; private boolean seekForCues;
private long cuesContentPosition = C.POSITION_UNSET; private long cuesContentPosition = C.INDEX_UNSET;
private long seekPositionAfterBuildingCues = C.POSITION_UNSET; private long seekPositionAfterBuildingCues = C.INDEX_UNSET;
private long clusterTimecodeUs = C.TIME_UNSET; private long clusterTimecodeUs = C.TIME_UNSET;
@Nullable private LongArray cueTimesUs; @Nullable private LongArray cueTimesUs;
@Nullable private LongArray cueClusterPositions; @Nullable private LongArray cueClusterPositions;
@ -658,8 +658,7 @@ public class MatroskaExtractor implements Extractor {
assertInitialized(); assertInitialized();
switch (id) { switch (id) {
case ID_SEGMENT: case ID_SEGMENT:
if (segmentContentPosition != C.POSITION_UNSET if (segmentContentPosition != C.INDEX_UNSET && segmentContentPosition != contentPosition) {
&& segmentContentPosition != contentPosition) {
throw ParserException.createForMalformedContainer( throw ParserException.createForMalformedContainer(
"Multiple Segment elements not supported", /* cause= */ null); "Multiple Segment elements not supported", /* cause= */ null);
} }
@ -668,7 +667,7 @@ public class MatroskaExtractor implements Extractor {
break; break;
case ID_SEEK: case ID_SEEK:
seekEntryId = UNSET_ENTRY_ID; seekEntryId = UNSET_ENTRY_ID;
seekEntryPosition = C.POSITION_UNSET; seekEntryPosition = C.INDEX_UNSET;
break; break;
case ID_CUES: case ID_CUES:
cueTimesUs = new LongArray(); cueTimesUs = new LongArray();
@ -680,7 +679,7 @@ public class MatroskaExtractor implements Extractor {
case ID_CLUSTER: case ID_CLUSTER:
if (!sentSeekMap) { if (!sentSeekMap) {
// We need to build cues before parsing the cluster. // We need to build cues before parsing the cluster.
if (seekForCuesEnabled && cuesContentPosition != C.POSITION_UNSET) { if (seekForCuesEnabled && cuesContentPosition != C.INDEX_UNSET) {
// We know where the Cues element is located. Seek to request it. // We know where the Cues element is located. Seek to request it.
seekForCues = true; seekForCues = true;
} else { } else {
@ -731,7 +730,7 @@ public class MatroskaExtractor implements Extractor {
} }
break; break;
case ID_SEEK: case ID_SEEK:
if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.POSITION_UNSET) { if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.INDEX_UNSET) {
throw ParserException.createForMalformedContainer( throw ParserException.createForMalformedContainer(
"Mandatory element SeekID or SeekPosition not found", /* cause= */ null); "Mandatory element SeekID or SeekPosition not found", /* cause= */ null);
} }
@ -1792,7 +1791,7 @@ public class MatroskaExtractor implements Extractor {
*/ */
private SeekMap buildSeekMap( private SeekMap buildSeekMap(
@Nullable LongArray cueTimesUs, @Nullable LongArray cueClusterPositions) { @Nullable LongArray cueTimesUs, @Nullable LongArray cueClusterPositions) {
if (segmentContentPosition == C.POSITION_UNSET if (segmentContentPosition == C.INDEX_UNSET
|| durationUs == C.TIME_UNSET || durationUs == C.TIME_UNSET
|| cueTimesUs == null || cueTimesUs == null
|| cueTimesUs.size() == 0 || cueTimesUs.size() == 0
@ -1848,9 +1847,9 @@ public class MatroskaExtractor implements Extractor {
} }
// After parsing Cues, seek back to original position if available. We will not do this unless // After parsing Cues, seek back to original position if available. We will not do this unless
// we seeked to get to the Cues in the first place. // we seeked to get to the Cues in the first place.
if (sentSeekMap && seekPositionAfterBuildingCues != C.POSITION_UNSET) { if (sentSeekMap && seekPositionAfterBuildingCues != C.INDEX_UNSET) {
seekPosition.position = seekPositionAfterBuildingCues; seekPosition.position = seekPositionAfterBuildingCues;
seekPositionAfterBuildingCues = C.POSITION_UNSET; seekPositionAfterBuildingCues = C.INDEX_UNSET;
return true; return true;
} }
return false; return false;

View File

@ -54,6 +54,6 @@ import androidx.media3.extractor.MpegAudioUtil;
@Override @Override
public long getDataEndPosition() { public long getDataEndPosition() {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
} }

View File

@ -125,6 +125,6 @@ import androidx.media3.extractor.metadata.id3.MlltFrame;
@Override @Override
public long getDataEndPosition() { public long getDataEndPosition() {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
} }

View File

@ -428,7 +428,7 @@ public final class Mp3Extractor implements Extractor {
private boolean peekEndOfStreamOrHeader(ExtractorInput extractorInput) throws IOException { private boolean peekEndOfStreamOrHeader(ExtractorInput extractorInput) throws IOException {
if (seeker != null) { if (seeker != null) {
long dataEndPosition = seeker.getDataEndPosition(); long dataEndPosition = seeker.getDataEndPosition();
if (dataEndPosition != C.POSITION_UNSET if (dataEndPosition != C.INDEX_UNSET
&& extractorInput.getPeekPosition() > dataEndPosition - 4) { && extractorInput.getPeekPosition() > dataEndPosition - 4) {
return true; return true;
} }
@ -454,7 +454,7 @@ public final class Mp3Extractor implements Extractor {
@Nullable Seeker resultSeeker = null; @Nullable Seeker resultSeeker = null;
if ((flags & FLAG_ENABLE_INDEX_SEEKING) != 0) { if ((flags & FLAG_ENABLE_INDEX_SEEKING) != 0) {
long durationUs; long durationUs;
long dataEndPosition = C.POSITION_UNSET; long dataEndPosition = C.INDEX_UNSET;
if (metadataSeeker != null) { if (metadataSeeker != null) {
durationUs = metadataSeeker.getDurationUs(); durationUs = metadataSeeker.getDurationUs();
dataEndPosition = metadataSeeker.getDataEndPosition(); dataEndPosition = metadataSeeker.getDataEndPosition();

View File

@ -35,7 +35,7 @@ import androidx.media3.extractor.SeekMap;
/** /**
* Returns the position (byte offset) in the stream that is immediately after audio data, or * Returns the position (byte offset) in the stream that is immediately after audio data, or
* {@link C#POSITION_UNSET} if not known. * {@link C#INDEX_UNSET} if not known.
*/ */
long getDataEndPosition(); long getDataEndPosition();
@ -54,7 +54,7 @@ import androidx.media3.extractor.SeekMap;
@Override @Override
public long getDataEndPosition() { public long getDataEndPosition() {
// Position unset as we do not know the data end position. Note that returning 0 doesn't work. // Position unset as we do not know the data end position. Note that returning 0 doesn't work.
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
} }
} }

View File

@ -114,7 +114,7 @@ import androidx.media3.extractor.SeekPoint;
this.durationUs = durationUs; this.durationUs = durationUs;
this.tableOfContents = tableOfContents; this.tableOfContents = tableOfContents;
this.dataSize = dataSize; this.dataSize = dataSize;
dataEndPosition = dataSize == C.LENGTH_UNSET ? C.POSITION_UNSET : dataStartPosition + dataSize; dataEndPosition = dataSize == C.LENGTH_UNSET ? C.INDEX_UNSET : dataStartPosition + dataSize;
} }
@Override @Override

View File

@ -1515,7 +1515,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
childAtomType == Atom.TYPE_esds childAtomType == Atom.TYPE_esds
? childPosition ? childPosition
: findBoxPosition(parent, Atom.TYPE_esds, childPosition, childAtomSize); : findBoxPosition(parent, Atom.TYPE_esds, childPosition, childAtomSize);
if (esdsAtomPosition != C.POSITION_UNSET) { if (esdsAtomPosition != C.INDEX_UNSET) {
esdsData = parseEsdsFromParent(parent, esdsAtomPosition); esdsData = parseEsdsFromParent(parent, esdsAtomPosition);
mimeType = esdsData.mimeType; mimeType = esdsData.mimeType;
@Nullable byte[] initializationDataBytes = esdsData.initializationData; @Nullable byte[] initializationDataBytes = esdsData.initializationData;
@ -1623,7 +1623,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/** /**
* Returns the position of the first box with the given {@code boxType} within {@code parent}, or * Returns the position of the first box with the given {@code boxType} within {@code parent}, or
* {@link C#POSITION_UNSET} if no such box is found. * {@link C#INDEX_UNSET} if no such box is found.
* *
* @param parent The {@link ParsableByteArray} to search. The search will start from the {@link * @param parent The {@link ParsableByteArray} to search. The search will start from the {@link
* ParsableByteArray#getPosition() current position}. * ParsableByteArray#getPosition() current position}.
@ -1631,7 +1631,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
* @param parentBoxPosition The position in {@code parent} of the box we are searching. * @param parentBoxPosition The position in {@code parent} of the box we are searching.
* @param parentBoxSize The size of the parent box we are searching in bytes. * @param parentBoxSize The size of the parent box we are searching in bytes.
* @return The position of the first box with the given {@code boxType} within {@code parent}, or * @return The position of the first box with the given {@code boxType} within {@code parent}, or
* {@link C#POSITION_UNSET} if no such box is found. * {@link C#INDEX_UNSET} if no such box is found.
*/ */
private static int findBoxPosition( private static int findBoxPosition(
ParsableByteArray parent, int boxType, int parentBoxPosition, int parentBoxSize) ParsableByteArray parent, int boxType, int parentBoxPosition, int parentBoxSize)
@ -1648,7 +1648,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
} }
childAtomPosition += childAtomSize; childAtomPosition += childAtomSize;
} }
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
/** Returns codec-specific initialization data contained in an esds box. */ /** Returns codec-specific initialization data contained in an esds box. */
@ -1736,7 +1736,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/* package */ static Pair<Integer, TrackEncryptionBox> parseCommonEncryptionSinfFromParent( /* package */ static Pair<Integer, TrackEncryptionBox> parseCommonEncryptionSinfFromParent(
ParsableByteArray parent, int position, int size) throws ParserException { ParsableByteArray parent, int position, int size) throws ParserException {
int childPosition = position + Atom.HEADER_SIZE; int childPosition = position + Atom.HEADER_SIZE;
int schemeInformationBoxPosition = C.POSITION_UNSET; int schemeInformationBoxPosition = C.INDEX_UNSET;
int schemeInformationBoxSize = 0; int schemeInformationBoxSize = 0;
@Nullable String schemeType = null; @Nullable String schemeType = null;
@Nullable Integer dataFormat = null; @Nullable Integer dataFormat = null;
@ -1763,7 +1763,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|| C.CENC_TYPE_cbcs.equals(schemeType)) { || C.CENC_TYPE_cbcs.equals(schemeType)) {
ExtractorUtil.checkContainerInput(dataFormat != null, "frma atom is mandatory"); ExtractorUtil.checkContainerInput(dataFormat != null, "frma atom is mandatory");
ExtractorUtil.checkContainerInput( ExtractorUtil.checkContainerInput(
schemeInformationBoxPosition != C.POSITION_UNSET, "schi atom is mandatory"); schemeInformationBoxPosition != C.INDEX_UNSET, "schi atom is mandatory");
@Nullable @Nullable
TrackEncryptionBox encryptionBox = TrackEncryptionBox encryptionBox =
parseSchiFromParent( parseSchiFromParent(

View File

@ -304,7 +304,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
long firstTimeUs; long firstTimeUs;
long firstOffset; long firstOffset;
long secondTimeUs = C.TIME_UNSET; long secondTimeUs = C.TIME_UNSET;
long secondOffset = C.POSITION_UNSET; long secondOffset = C.INDEX_UNSET;
// Note that the id matches the index in tracks. // Note that the id matches the index in tracks.
int mainTrackIndex = trackId != C.INDEX_UNSET ? trackId : firstVideoTrackIndex; int mainTrackIndex = trackId != C.INDEX_UNSET ? trackId : firstVideoTrackIndex;

View File

@ -109,7 +109,7 @@ import java.io.IOException;
return positionBeforeSeekToEnd; return positionBeforeSeekToEnd;
case STATE_SEEK: case STATE_SEEK:
long position = getNextSeekPosition(input); long position = getNextSeekPosition(input);
if (position != C.POSITION_UNSET) { if (position != C.INDEX_UNSET) {
return position; return position;
} }
state = STATE_SKIP; state = STATE_SKIP;
@ -142,18 +142,18 @@ import java.io.IOException;
/** /**
* Performs a single step of a seeking binary search, returning the byte position from which data * Performs a single step of a seeking binary search, returning the byte position from which data
* should be provided for the next step, or {@link C#POSITION_UNSET} if the search has converged. * should be provided for the next step, or {@link C#INDEX_UNSET} if the search has converged. If
* If the search has converged then {@link #skipToPageOfTargetGranule(ExtractorInput)} should be * the search has converged then {@link #skipToPageOfTargetGranule(ExtractorInput)} should be
* called to skip to the target page. * called to skip to the target page.
* *
* @param input The {@link ExtractorInput} to read from. * @param input The {@link ExtractorInput} to read from.
* @return The byte position from which data should be provided for the next step, or {@link * @return The byte position from which data should be provided for the next step, or {@link
* C#POSITION_UNSET} if the search has converged. * C#INDEX_UNSET} if the search has converged.
* @throws IOException If reading from the input fails. * @throws IOException If reading from the input fails.
*/ */
private long getNextSeekPosition(ExtractorInput input) throws IOException { private long getNextSeekPosition(ExtractorInput input) throws IOException {
if (start == end) { if (start == end) {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
long currentPosition = input.getPosition(); long currentPosition = input.getPosition();
@ -170,7 +170,7 @@ import java.io.IOException;
long granuleDistance = targetGranule - pageHeader.granulePosition; long granuleDistance = targetGranule - pageHeader.granulePosition;
int pageSize = pageHeader.headerSize + pageHeader.bodySize; int pageSize = pageHeader.headerSize + pageHeader.bodySize;
if (0 <= granuleDistance && granuleDistance < MATCH_RANGE) { if (0 <= granuleDistance && granuleDistance < MATCH_RANGE) {
return C.POSITION_UNSET; return C.INDEX_UNSET;
} }
if (granuleDistance < 0) { if (granuleDistance < 0) {

View File

@ -79,7 +79,7 @@ import java.io.IOException;
* *\/ C.POSITION_UNSET)}. * *\/ C.POSITION_UNSET)}.
*/ */
public boolean skipToNextPage(ExtractorInput input) throws IOException { public boolean skipToNextPage(ExtractorInput input) throws IOException {
return skipToNextPage(input, /* limit= */ C.POSITION_UNSET); return skipToNextPage(input, /* limit= */ C.INDEX_UNSET);
} }
/** /**
@ -94,7 +94,7 @@ import java.io.IOException;
* *
* @param input The {@link ExtractorInput} to read from (must have {@code readPosition == * @param input The {@link ExtractorInput} to read from (must have {@code readPosition ==
* peekPosition}). * peekPosition}).
* @param limit The max position in {@code input} to peek to, or {@link C#POSITION_UNSET} to allow * @param limit The max position in {@code input} to peek to, or {@link C#INDEX_UNSET} to allow
* peeking to the end. * peeking to the end.
* @return True if a capture_pattern was found. * @return True if a capture_pattern was found.
* @throws IOException If reading data fails. * @throws IOException If reading data fails.
@ -102,7 +102,7 @@ import java.io.IOException;
public boolean skipToNextPage(ExtractorInput input, long limit) throws IOException { public boolean skipToNextPage(ExtractorInput input, long limit) throws IOException {
Assertions.checkArgument(input.getPosition() == input.getPeekPosition()); Assertions.checkArgument(input.getPosition() == input.getPeekPosition());
scratch.reset(/* limit= */ CAPTURE_PATTERN_SIZE); scratch.reset(/* limit= */ CAPTURE_PATTERN_SIZE);
while ((limit == C.POSITION_UNSET || input.getPosition() + CAPTURE_PATTERN_SIZE < limit) while ((limit == C.INDEX_UNSET || input.getPosition() + CAPTURE_PATTERN_SIZE < limit)
&& peekFullyQuietly( && peekFullyQuietly(
input, scratch.getData(), 0, CAPTURE_PATTERN_SIZE, /* allowEndOfInput= */ true)) { input, scratch.getData(), 0, CAPTURE_PATTERN_SIZE, /* allowEndOfInput= */ true)) {
scratch.setPosition(0); scratch.setPosition(0);
@ -114,7 +114,7 @@ import java.io.IOException;
input.skipFully(1); input.skipFully(1);
} }
// Move the read & peek positions to limit or end-of-input, whichever is closer. // Move the read & peek positions to limit or end-of-input, whichever is closer.
while ((limit == C.POSITION_UNSET || input.getPosition() < limit) while ((limit == C.INDEX_UNSET || input.getPosition() < limit)
&& input.skip(1) != C.RESULT_END_OF_INPUT) {} && input.skip(1) != C.RESULT_END_OF_INPUT) {}
return false; return false;
} }

View File

@ -1007,10 +1007,10 @@ public final class Cea708Decoder extends CeaDecoder {
public void clear() { public void clear() {
rolledUpCaptions.clear(); rolledUpCaptions.clear();
captionStringBuilder.clear(); captionStringBuilder.clear();
italicsStartPosition = C.POSITION_UNSET; italicsStartPosition = C.INDEX_UNSET;
underlineStartPosition = C.POSITION_UNSET; underlineStartPosition = C.INDEX_UNSET;
foregroundColorStartPosition = C.POSITION_UNSET; foregroundColorStartPosition = C.INDEX_UNSET;
backgroundColorStartPosition = C.POSITION_UNSET; backgroundColorStartPosition = C.INDEX_UNSET;
row = 0; row = 0;
} }
@ -1122,27 +1122,27 @@ public final class Cea708Decoder extends CeaDecoder {
// TODO: Add support for other offsets. // TODO: Add support for other offsets.
// TODO: Add support for other pen sizes. // TODO: Add support for other pen sizes.
if (italicsStartPosition != C.POSITION_UNSET) { if (italicsStartPosition != C.INDEX_UNSET) {
if (!italicsToggle) { if (!italicsToggle) {
captionStringBuilder.setSpan( captionStringBuilder.setSpan(
new StyleSpan(Typeface.ITALIC), new StyleSpan(Typeface.ITALIC),
italicsStartPosition, italicsStartPosition,
captionStringBuilder.length(), captionStringBuilder.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
italicsStartPosition = C.POSITION_UNSET; italicsStartPosition = C.INDEX_UNSET;
} }
} else if (italicsToggle) { } else if (italicsToggle) {
italicsStartPosition = captionStringBuilder.length(); italicsStartPosition = captionStringBuilder.length();
} }
if (underlineStartPosition != C.POSITION_UNSET) { if (underlineStartPosition != C.INDEX_UNSET) {
if (!underlineToggle) { if (!underlineToggle) {
captionStringBuilder.setSpan( captionStringBuilder.setSpan(
new UnderlineSpan(), new UnderlineSpan(),
underlineStartPosition, underlineStartPosition,
captionStringBuilder.length(), captionStringBuilder.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
underlineStartPosition = C.POSITION_UNSET; underlineStartPosition = C.INDEX_UNSET;
} }
} else if (underlineToggle) { } else if (underlineToggle) {
underlineStartPosition = captionStringBuilder.length(); underlineStartPosition = captionStringBuilder.length();
@ -1153,7 +1153,7 @@ public final class Cea708Decoder extends CeaDecoder {
} }
public void setPenColor(int foregroundColor, int backgroundColor, int edgeColor) { public void setPenColor(int foregroundColor, int backgroundColor, int edgeColor) {
if (foregroundColorStartPosition != C.POSITION_UNSET) { if (foregroundColorStartPosition != C.INDEX_UNSET) {
if (this.foregroundColor != foregroundColor) { if (this.foregroundColor != foregroundColor) {
captionStringBuilder.setSpan( captionStringBuilder.setSpan(
new ForegroundColorSpan(this.foregroundColor), new ForegroundColorSpan(this.foregroundColor),
@ -1167,7 +1167,7 @@ public final class Cea708Decoder extends CeaDecoder {
this.foregroundColor = foregroundColor; this.foregroundColor = foregroundColor;
} }
if (backgroundColorStartPosition != C.POSITION_UNSET) { if (backgroundColorStartPosition != C.INDEX_UNSET) {
if (this.backgroundColor != backgroundColor) { if (this.backgroundColor != backgroundColor) {
captionStringBuilder.setSpan( captionStringBuilder.setSpan(
new BackgroundColorSpan(this.backgroundColor), new BackgroundColorSpan(this.backgroundColor),
@ -1209,16 +1209,16 @@ public final class Cea708Decoder extends CeaDecoder {
rolledUpCaptions.add(buildSpannableString()); rolledUpCaptions.add(buildSpannableString());
captionStringBuilder.clear(); captionStringBuilder.clear();
if (italicsStartPosition != C.POSITION_UNSET) { if (italicsStartPosition != C.INDEX_UNSET) {
italicsStartPosition = 0; italicsStartPosition = 0;
} }
if (underlineStartPosition != C.POSITION_UNSET) { if (underlineStartPosition != C.INDEX_UNSET) {
underlineStartPosition = 0; underlineStartPosition = 0;
} }
if (foregroundColorStartPosition != C.POSITION_UNSET) { if (foregroundColorStartPosition != C.INDEX_UNSET) {
foregroundColorStartPosition = 0; foregroundColorStartPosition = 0;
} }
if (backgroundColorStartPosition != C.POSITION_UNSET) { if (backgroundColorStartPosition != C.INDEX_UNSET) {
backgroundColorStartPosition = 0; backgroundColorStartPosition = 0;
} }
@ -1237,7 +1237,7 @@ public final class Cea708Decoder extends CeaDecoder {
int length = spannableStringBuilder.length(); int length = spannableStringBuilder.length();
if (length > 0) { if (length > 0) {
if (italicsStartPosition != C.POSITION_UNSET) { if (italicsStartPosition != C.INDEX_UNSET) {
spannableStringBuilder.setSpan( spannableStringBuilder.setSpan(
new StyleSpan(Typeface.ITALIC), new StyleSpan(Typeface.ITALIC),
italicsStartPosition, italicsStartPosition,
@ -1245,7 +1245,7 @@ public final class Cea708Decoder extends CeaDecoder {
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
if (underlineStartPosition != C.POSITION_UNSET) { if (underlineStartPosition != C.INDEX_UNSET) {
spannableStringBuilder.setSpan( spannableStringBuilder.setSpan(
new UnderlineSpan(), new UnderlineSpan(),
underlineStartPosition, underlineStartPosition,
@ -1253,7 +1253,7 @@ public final class Cea708Decoder extends CeaDecoder {
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
if (foregroundColorStartPosition != C.POSITION_UNSET) { if (foregroundColorStartPosition != C.INDEX_UNSET) {
spannableStringBuilder.setSpan( spannableStringBuilder.setSpan(
new ForegroundColorSpan(foregroundColor), new ForegroundColorSpan(foregroundColor),
foregroundColorStartPosition, foregroundColorStartPosition,
@ -1261,7 +1261,7 @@ public final class Cea708Decoder extends CeaDecoder {
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
if (backgroundColorStartPosition != C.POSITION_UNSET) { if (backgroundColorStartPosition != C.INDEX_UNSET) {
spannableStringBuilder.setSpan( spannableStringBuilder.setSpan(
new BackgroundColorSpan(backgroundColor), new BackgroundColorSpan(backgroundColor),
backgroundColorStartPosition, backgroundColorStartPosition,

View File

@ -132,7 +132,7 @@ public final class AdtsExtractor implements Extractor {
reader = new AdtsReader(true); reader = new AdtsReader(true);
packetBuffer = new ParsableByteArray(MAX_PACKET_SIZE); packetBuffer = new ParsableByteArray(MAX_PACKET_SIZE);
averageFrameSize = C.LENGTH_UNSET; averageFrameSize = C.LENGTH_UNSET;
firstFramePosition = C.POSITION_UNSET; firstFramePosition = C.INDEX_UNSET;
// Allocate scratch space for an ID3 header. The same buffer is also used to read 4 byte values. // Allocate scratch space for an ID3 header. The same buffer is also used to read 4 byte values.
scratch = new ParsableByteArray(ID3_HEADER_LENGTH); scratch = new ParsableByteArray(ID3_HEADER_LENGTH);
scratchBits = new ParsableBitArray(scratch.getData()); scratchBits = new ParsableBitArray(scratch.getData());
@ -258,7 +258,7 @@ public final class AdtsExtractor implements Extractor {
} }
input.resetPeekPosition(); input.resetPeekPosition();
input.advancePeekPosition(firstFramePosition); input.advancePeekPosition(firstFramePosition);
if (this.firstFramePosition == C.POSITION_UNSET) { if (this.firstFramePosition == C.INDEX_UNSET) {
this.firstFramePosition = firstFramePosition; this.firstFramePosition = firstFramePosition;
} }
return firstFramePosition; return firstFramePosition;

View File

@ -89,8 +89,8 @@ import java.io.IOException;
private TimestampSearchResult searchForScrValueInBuffer( private TimestampSearchResult searchForScrValueInBuffer(
ParsableByteArray packetBuffer, long targetScrTimeUs, long bufferStartOffset) { ParsableByteArray packetBuffer, long targetScrTimeUs, long bufferStartOffset) {
int startOfLastPacketPosition = C.POSITION_UNSET; int startOfLastPacketPosition = C.INDEX_UNSET;
int endOfLastPacketPosition = C.POSITION_UNSET; int endOfLastPacketPosition = C.INDEX_UNSET;
long lastScrTimeUsInRange = C.TIME_UNSET; long lastScrTimeUsInRange = C.TIME_UNSET;
while (packetBuffer.bytesLeft() >= 4) { while (packetBuffer.bytesLeft() >= 4) {

View File

@ -66,7 +66,7 @@ public final class SectionReader implements TsPayloadReader {
@Override @Override
public void consume(ParsableByteArray data, @Flags int flags) { public void consume(ParsableByteArray data, @Flags int flags) {
boolean payloadUnitStartIndicator = (flags & FLAG_PAYLOAD_UNIT_START_INDICATOR) != 0; boolean payloadUnitStartIndicator = (flags & FLAG_PAYLOAD_UNIT_START_INDICATOR) != 0;
int payloadStartPosition = C.POSITION_UNSET; int payloadStartPosition = C.INDEX_UNSET;
if (payloadUnitStartIndicator) { if (payloadUnitStartIndicator) {
int payloadStartOffset = data.readUnsignedByte(); int payloadStartOffset = data.readUnsignedByte();
payloadStartPosition = data.getPosition() + payloadStartOffset; payloadStartPosition = data.getPosition() + payloadStartOffset;

View File

@ -96,8 +96,8 @@ import java.io.IOException;
ParsableByteArray packetBuffer, long targetPcrTimeUs, long bufferStartOffset) { ParsableByteArray packetBuffer, long targetPcrTimeUs, long bufferStartOffset) {
int limit = packetBuffer.limit(); int limit = packetBuffer.limit();
long startOfLastPacketPosition = C.POSITION_UNSET; long startOfLastPacketPosition = C.INDEX_UNSET;
long endOfLastPacketPosition = C.POSITION_UNSET; long endOfLastPacketPosition = C.INDEX_UNSET;
long lastPcrTimeUsInRange = C.TIME_UNSET; long lastPcrTimeUsInRange = C.TIME_UNSET;
while (packetBuffer.bytesLeft() >= TsExtractor.TS_PACKET_SIZE) { while (packetBuffer.bytesLeft() >= TsExtractor.TS_PACKET_SIZE) {

View File

@ -92,8 +92,8 @@ public final class WavExtractor implements Extractor {
public WavExtractor() { public WavExtractor() {
state = STATE_READING_FILE_TYPE; state = STATE_READING_FILE_TYPE;
rf64SampleDataSize = C.LENGTH_UNSET; rf64SampleDataSize = C.LENGTH_UNSET;
dataStartPosition = C.POSITION_UNSET; dataStartPosition = C.INDEX_UNSET;
dataEndPosition = C.POSITION_UNSET; dataEndPosition = C.INDEX_UNSET;
} }
@Override @Override
@ -153,7 +153,7 @@ public final class WavExtractor implements Extractor {
private void readFileType(ExtractorInput input) throws IOException { private void readFileType(ExtractorInput input) throws IOException {
Assertions.checkState(input.getPosition() == 0); Assertions.checkState(input.getPosition() == 0);
if (dataStartPosition != C.POSITION_UNSET) { if (dataStartPosition != C.INDEX_UNSET) {
input.skipFully(dataStartPosition); input.skipFully(dataStartPosition);
state = STATE_READING_SAMPLE_DATA; state = STATE_READING_SAMPLE_DATA;
return; return;
@ -228,7 +228,7 @@ public final class WavExtractor implements Extractor {
} }
private @ReadResult int readSampleData(ExtractorInput input) throws IOException { private @ReadResult int readSampleData(ExtractorInput input) throws IOException {
Assertions.checkState(dataEndPosition != C.POSITION_UNSET); Assertions.checkState(dataEndPosition != C.INDEX_UNSET);
long bytesLeft = dataEndPosition - input.getPosition(); long bytesLeft = dataEndPosition - input.getPosition();
return Assertions.checkNotNull(outputWriter).sampleData(input, bytesLeft) return Assertions.checkNotNull(outputWriter).sampleData(input, bytesLeft)
? RESULT_END_OF_INPUT ? RESULT_END_OF_INPUT

View File

@ -218,7 +218,7 @@ public final class PsExtractorSeekTest {
long initialSeekLoadPosition = seekPoints.first.position; long initialSeekLoadPosition = seekPoints.first.position;
psExtractor.seek(initialSeekLoadPosition, seekTimeUs); psExtractor.seek(initialSeekLoadPosition, seekTimeUs);
positionHolder.position = C.POSITION_UNSET; positionHolder.position = C.INDEX_UNSET;
ExtractorInput extractorInput = getExtractorInputFromPosition(initialSeekLoadPosition); ExtractorInput extractorInput = getExtractorInputFromPosition(initialSeekLoadPosition);
int extractorReadResult = Extractor.RESULT_CONTINUE; int extractorReadResult = Extractor.RESULT_CONTINUE;
while (true) { while (true) {

View File

@ -428,7 +428,7 @@ public class TestUtil {
extractor.seek(initialSeekLoadPosition, seekTimeUs); extractor.seek(initialSeekLoadPosition, seekTimeUs);
PositionHolder positionHolder = new PositionHolder(); PositionHolder positionHolder = new PositionHolder();
positionHolder.position = C.POSITION_UNSET; positionHolder.position = C.INDEX_UNSET;
ExtractorInput extractorInput = ExtractorInput extractorInput =
TestUtil.getExtractorInputFromPosition(dataSource, initialSeekLoadPosition, uri); TestUtil.getExtractorInputFromPosition(dataSource, initialSeekLoadPosition, uri);
int extractorReadResult = Extractor.RESULT_CONTINUE; int extractorReadResult = Extractor.RESULT_CONTINUE;