From d6c872494be87058fc719af2bf3dbcf2879c7e9a Mon Sep 17 00:00:00 2001 From: ibaker Date: Fri, 2 Dec 2022 17:52:16 +0000 Subject: [PATCH] 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 --- .../java/com/google/android/exoplayer2/C.java | 8 +++-- .../audio/AudioTimestampPoller.java | 4 +-- .../source/BundledExtractorsAdapter.java | 2 +- .../source/MediaParserExtractorAdapter.java | 2 +- .../source/ProgressiveMediaExtractor.java | 4 +-- .../source/ProgressiveMediaPeriod.java | 2 +- .../exoplayer2/source/SampleDataQueue.java | 6 ++-- .../exoplayer2/source/SampleQueue.java | 8 ++--- .../mediaparser/InputReaderAdapterV30.java | 6 ++-- .../upstream/cache/CacheWriter.java | 8 ++--- .../extractor/BinarySearchSeeker.java | 2 +- .../extractor/avi/AviExtractor.java | 14 ++++---- .../extractor/jpeg/JpegExtractor.java | 4 +-- .../jpeg/MotionPhotoDescription.java | 8 ++--- .../extractor/mkv/MatroskaExtractor.java | 21 ++++++----- .../extractor/mp3/ConstantBitrateSeeker.java | 2 +- .../exoplayer2/extractor/mp3/MlltSeeker.java | 2 +- .../extractor/mp3/Mp3Extractor.java | 4 +-- .../exoplayer2/extractor/mp3/Seeker.java | 4 +-- .../exoplayer2/extractor/mp3/XingSeeker.java | 2 +- .../exoplayer2/extractor/mp4/AtomParsers.java | 12 +++---- .../extractor/mp4/Mp4Extractor.java | 2 +- .../extractor/ogg/DefaultOggSeeker.java | 12 +++---- .../extractor/ogg/OggPageHeader.java | 8 ++--- .../extractor/ts/AdtsExtractor.java | 4 +-- .../extractor/ts/PsBinarySearchSeeker.java | 4 +-- .../extractor/ts/SectionReader.java | 2 +- .../extractor/ts/TsBinarySearchSeeker.java | 4 +-- .../extractor/wav/WavExtractor.java | 8 ++--- .../exoplayer2/metadata/id3/ChapterFrame.java | 4 +-- .../exoplayer2/metadata/id3/Id3Decoder.java | 4 +-- .../exoplayer2/text/cea/Cea708Decoder.java | 36 +++++++++---------- .../extractor/ts/PsExtractorSeekTest.java | 2 +- .../android/exoplayer2/testutil/TestUtil.java | 2 +- 34 files changed, 109 insertions(+), 108 deletions(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/C.java b/library/common/src/main/java/com/google/android/exoplayer2/C.java index ce6d067805..e4ad83bac7 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/C.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/C.java @@ -60,11 +60,13 @@ public final class C { */ 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; - /** Represents an unset or unknown position. */ - public static final int POSITION_UNSET = -1; + /** + * @deprecated Use {@link #INDEX_UNSET}. + */ + @Deprecated public static final int POSITION_UNSET = INDEX_UNSET; /** Represents an unset or unknown rate. */ public static final float RATE_UNSET = -Float.MAX_VALUE; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java index 537cd0791c..380c2fc1f3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTimestampPoller.java @@ -237,7 +237,7 @@ import java.lang.annotation.Target; */ @TargetApi(19) // audioTimestamp will be null if Util.SDK_INT < 19. 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) { @@ -246,7 +246,7 @@ import java.lang.annotation.Target; case STATE_INITIALIZING: // Force polling a timestamp immediately, and poll quickly. lastTimestampSampleTimeUs = 0; - initialTimestampPositionFrames = C.POSITION_UNSET; + initialTimestampPositionFrames = C.INDEX_UNSET; initializeSystemTimeUs = System.nanoTime() / 1000; sampleIntervalUs = FAST_POLL_INTERVAL_US; break; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java b/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java index edb16e53d6..7c9a579adc 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java @@ -113,7 +113,7 @@ public final class BundledExtractorsAdapter implements ProgressiveMediaExtractor @Override public long getCurrentInputPosition() { - return extractorInput != null ? extractorInput.getPosition() : C.POSITION_UNSET; + return extractorInput != null ? extractorInput.getPosition() : C.INDEX_UNSET; } @Override diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaParserExtractorAdapter.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaParserExtractorAdapter.java index 51926cdf43..944eaa8c87 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaParserExtractorAdapter.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaParserExtractorAdapter.java @@ -126,7 +126,7 @@ public final class MediaParserExtractorAdapter implements ProgressiveMediaExtrac positionHolder.position = inputReaderAdapter.getAndResetSeekPosition(); return !shouldContinue ? Extractor.RESULT_END_OF_INPUT - : positionHolder.position != C.POSITION_UNSET + : positionHolder.position != C.INDEX_UNSET ? Extractor.RESULT_SEEK : Extractor.RESULT_CONTINUE; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java index 7de4d5d291..69729b954c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java @@ -73,8 +73,8 @@ public interface ProgressiveMediaExtractor { void disableSeekingOnMp3Streams(); /** - * Returns the current read position in the input stream, or {@link C#POSITION_UNSET} if no input - * is available. + * Returns the current read position in the input stream, or {@link C#INDEX_UNSET} if no input is + * available. */ long getCurrentInputPosition(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java index b29338f86e..c3ccc069bb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java @@ -1047,7 +1047,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } finally { if (result == Extractor.RESULT_SEEK) { result = Extractor.RESULT_CONTINUE; - } else if (progressiveMediaExtractor.getCurrentInputPosition() != C.POSITION_UNSET) { + } else if (progressiveMediaExtractor.getCurrentInputPosition() != C.INDEX_UNSET) { positionHolder.position = progressiveMediaExtractor.getCurrentInputPosition(); } DataSourceUtil.closeQuietly(dataSource); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java index 00b1943533..ef28bff90e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java @@ -146,11 +146,11 @@ import java.util.Arrays; /** * Advances the read position to the specified absolute position. * - * @param absolutePosition The new absolute read position. May be {@link C#POSITION_UNSET}, in - * which case calling this method is a no-op. + * @param absolutePosition The new absolute read position. May be {@link C#INDEX_UNSET}, in which + * case calling this method is a no-op. */ public void discardDownstreamTo(long absolutePosition) { - if (absolutePosition == C.POSITION_UNSET) { + if (absolutePosition == C.INDEX_UNSET) { return; } while (absolutePosition >= firstAllocationNode.endPosition) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java index c6112c67f8..0b90c3965c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java @@ -752,26 +752,26 @@ public class SampleQueue implements TrackOutput { private synchronized long discardSampleMetadataTo( long timeUs, boolean toKeyframe, boolean stopAtReadPosition) { if (length == 0 || timeUs < timesUs[relativeFirstIndex]) { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } int searchLength = stopAtReadPosition && readPosition != length ? readPosition + 1 : length; int discardCount = findSampleBefore(relativeFirstIndex, searchLength, timeUs, toKeyframe); if (discardCount == -1) { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } return discardSamples(discardCount); } public synchronized long discardSampleMetadataToRead() { if (readPosition == 0) { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } return discardSamples(readPosition); } private synchronized long discardSampleMetadataToEnd() { if (length == 0) { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } return discardSamples(length); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/InputReaderAdapterV30.java b/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/InputReaderAdapterV30.java index 3a55645e96..aec49478fb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/InputReaderAdapterV30.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/InputReaderAdapterV30.java @@ -43,7 +43,7 @@ public final class InputReaderAdapterV30 implements MediaParser.SeekableInputRea public void setDataReader(DataReader dataReader, long length) { this.dataReader = dataReader; resourceLength = length; - lastSeekPosition = C.POSITION_UNSET; + lastSeekPosition = C.INDEX_UNSET; } /** Sets the absolute position in the resource from which the wrapped {@link DataReader} reads. */ @@ -53,11 +53,11 @@ public final class InputReaderAdapterV30 implements MediaParser.SeekableInputRea /** * 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() { long lastSeekPosition = this.lastSeekPosition; - this.lastSeekPosition = C.POSITION_UNSET; + this.lastSeekPosition = C.INDEX_UNSET; return lastSeekPosition; } diff --git a/library/datasource/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java b/library/datasource/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java index 5fa6638981..a0f898bf6b 100644 --- a/library/datasource/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java +++ b/library/datasource/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java @@ -114,16 +114,16 @@ public final class CacheWriter { endPosition = dataSpec.position + dataSpec.length; } else { 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) { progressListener.onProgress(getLength(), bytesCached, /* newBytesCached= */ 0); } - while (endPosition == C.POSITION_UNSET || nextPosition < endPosition) { + while (endPosition == C.INDEX_UNSET || nextPosition < endPosition) { throwIfCanceled(); 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); if (blockLength > 0) { nextPosition += blockLength; @@ -223,7 +223,7 @@ public final class CacheWriter { } 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 { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java index 80ab98a6d1..2e578b2538 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java @@ -418,7 +418,7 @@ public abstract class BinarySearchSeeker { @interface Type {} 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. */ private final @Type int type; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java index e59ba61f7e..c482ffce62 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java @@ -142,8 +142,8 @@ public final class AviExtractor implements Extractor { chunkHeaderHolder = new ChunkHeaderHolder(); extractorOutput = new DummyExtractorOutput(); chunkReaders = new ChunkReader[0]; - moviStart = C.POSITION_UNSET; - moviEnd = C.POSITION_UNSET; + moviStart = C.INDEX_UNSET; + moviEnd = C.INDEX_UNSET; hdrlSize = C.LENGTH_UNSET; durationUs = C.TIME_UNSET; } @@ -154,7 +154,7 @@ public final class AviExtractor implements Extractor { public void init(ExtractorOutput output) { this.state = STATE_SKIPPING_TO_HDRL; this.extractorOutput = output; - pendingReposition = C.POSITION_UNSET; + pendingReposition = C.INDEX_UNSET; } @Override @@ -206,7 +206,7 @@ public final class AviExtractor implements Extractor { state = STATE_FINDING_MOVI_HEADER; return RESULT_CONTINUE; case STATE_FINDING_MOVI_HEADER: - if (moviStart != C.POSITION_UNSET && input.getPosition() != moviStart) { + if (moviStart != C.INDEX_UNSET && input.getPosition() != moviStart) { pendingReposition = moviStart; return RESULT_CONTINUE; } @@ -273,7 +273,7 @@ public final class AviExtractor implements Extractor { @Override public void seek(long position, long timeUs) { - pendingReposition = C.POSITION_UNSET; + pendingReposition = C.INDEX_UNSET; currentChunkReader = null; for (ChunkReader chunkReader : chunkReaders) { chunkReader.seekToPosition(position); @@ -306,7 +306,7 @@ public final class AviExtractor implements Extractor { private boolean resolvePendingReposition(ExtractorInput input, PositionHolder seekPosition) throws IOException { boolean needSeek = false; - if (pendingReposition != C.POSITION_UNSET) { + if (pendingReposition != C.INDEX_UNSET) { long currentPosition = input.getPosition(); if (pendingReposition < currentPosition || pendingReposition > currentPosition + RELOAD_MINIMUM_SEEK_DISTANCE) { @@ -318,7 +318,7 @@ public final class AviExtractor implements Extractor { input.skipFully((int) (pendingReposition - currentPosition)); } } - pendingReposition = C.POSITION_UNSET; + pendingReposition = C.INDEX_UNSET; return needSeek; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/JpegExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/JpegExtractor.java index e4a5e8a863..b3de2d2975 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/JpegExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/JpegExtractor.java @@ -94,7 +94,7 @@ public final class JpegExtractor implements Extractor { public JpegExtractor() { scratch = new ParsableByteArray(EXIF_ID_CODE_LENGTH); - mp4StartPosition = C.POSITION_UNSET; + mp4StartPosition = C.INDEX_UNSET; } @Override @@ -200,7 +200,7 @@ public final class JpegExtractor implements Extractor { input.readFully(scratch.getData(), /* offset= */ 0, /* length= */ 2); marker = scratch.readUnsignedShort(); if (marker == MARKER_SOS) { // Start of scan. - if (mp4StartPosition != C.POSITION_UNSET) { + if (mp4StartPosition != C.INDEX_UNSET) { state = STATE_SNIFFING_MOTION_PHOTO_VIDEO; } else { endReadingWithImageTrack(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/MotionPhotoDescription.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/MotionPhotoDescription.java index 3117dfa5f4..395e632302 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/MotionPhotoDescription.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/jpeg/MotionPhotoDescription.java @@ -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 // 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. - long photoStartPosition = C.POSITION_UNSET; + long photoStartPosition = C.INDEX_UNSET; long photoLength = C.LENGTH_UNSET; - long mp4StartPosition = C.POSITION_UNSET; + long mp4StartPosition = C.INDEX_UNSET; long mp4Length = C.LENGTH_UNSET; boolean itemContainsMp4 = false; long itemStartPosition = motionPhotoLength; @@ -110,9 +110,9 @@ import java.util.List; photoLength = itemEndPosition; } } - if (mp4StartPosition == C.POSITION_UNSET + if (mp4StartPosition == C.INDEX_UNSET || mp4Length == C.LENGTH_UNSET - || photoStartPosition == C.POSITION_UNSET + || photoStartPosition == C.INDEX_UNSET || photoLength == C.LENGTH_UNSET) { return null; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java index eb60880cda..c62e70815c 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java @@ -394,7 +394,7 @@ public class MatroskaExtractor implements Extractor { private @MonotonicNonNull ByteBuffer encryptionSubsampleDataBuffer; private long segmentContentSize; - private long segmentContentPosition = C.POSITION_UNSET; + private long segmentContentPosition = C.INDEX_UNSET; private long timecodeScale = C.TIME_UNSET; private long durationTimecode = C.TIME_UNSET; private long durationUs = C.TIME_UNSET; @@ -411,8 +411,8 @@ public class MatroskaExtractor implements Extractor { // Cue related elements. private boolean seekForCues; - private long cuesContentPosition = C.POSITION_UNSET; - private long seekPositionAfterBuildingCues = C.POSITION_UNSET; + private long cuesContentPosition = C.INDEX_UNSET; + private long seekPositionAfterBuildingCues = C.INDEX_UNSET; private long clusterTimecodeUs = C.TIME_UNSET; @Nullable private LongArray cueTimesUs; @Nullable private LongArray cueClusterPositions; @@ -656,8 +656,7 @@ public class MatroskaExtractor implements Extractor { assertInitialized(); switch (id) { case ID_SEGMENT: - if (segmentContentPosition != C.POSITION_UNSET - && segmentContentPosition != contentPosition) { + if (segmentContentPosition != C.INDEX_UNSET && segmentContentPosition != contentPosition) { throw ParserException.createForMalformedContainer( "Multiple Segment elements not supported", /* cause= */ null); } @@ -666,7 +665,7 @@ public class MatroskaExtractor implements Extractor { break; case ID_SEEK: seekEntryId = UNSET_ENTRY_ID; - seekEntryPosition = C.POSITION_UNSET; + seekEntryPosition = C.INDEX_UNSET; break; case ID_CUES: cueTimesUs = new LongArray(); @@ -678,7 +677,7 @@ public class MatroskaExtractor implements Extractor { case ID_CLUSTER: if (!sentSeekMap) { // 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. seekForCues = true; } else { @@ -729,7 +728,7 @@ public class MatroskaExtractor implements Extractor { } break; case ID_SEEK: - if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.POSITION_UNSET) { + if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.INDEX_UNSET) { throw ParserException.createForMalformedContainer( "Mandatory element SeekID or SeekPosition not found", /* cause= */ null); } @@ -1790,7 +1789,7 @@ public class MatroskaExtractor implements Extractor { */ private SeekMap buildSeekMap( @Nullable LongArray cueTimesUs, @Nullable LongArray cueClusterPositions) { - if (segmentContentPosition == C.POSITION_UNSET + if (segmentContentPosition == C.INDEX_UNSET || durationUs == C.TIME_UNSET || cueTimesUs == null || cueTimesUs.size() == 0 @@ -1846,9 +1845,9 @@ public class MatroskaExtractor implements Extractor { } // 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. - if (sentSeekMap && seekPositionAfterBuildingCues != C.POSITION_UNSET) { + if (sentSeekMap && seekPositionAfterBuildingCues != C.INDEX_UNSET) { seekPosition.position = seekPositionAfterBuildingCues; - seekPositionAfterBuildingCues = C.POSITION_UNSET; + seekPositionAfterBuildingCues = C.INDEX_UNSET; return true; } return false; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/ConstantBitrateSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/ConstantBitrateSeeker.java index 9762f2d0e5..f40a0fec64 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/ConstantBitrateSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/ConstantBitrateSeeker.java @@ -54,6 +54,6 @@ import com.google.android.exoplayer2.extractor.ConstantBitrateSeekMap; @Override public long getDataEndPosition() { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java index 2204cfccd7..da4a413790 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java @@ -125,6 +125,6 @@ import com.google.android.exoplayer2.util.Util; @Override public long getDataEndPosition() { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java index 40bf68e152..d80427256f 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java @@ -426,7 +426,7 @@ public final class Mp3Extractor implements Extractor { private boolean peekEndOfStreamOrHeader(ExtractorInput extractorInput) throws IOException { if (seeker != null) { long dataEndPosition = seeker.getDataEndPosition(); - if (dataEndPosition != C.POSITION_UNSET + if (dataEndPosition != C.INDEX_UNSET && extractorInput.getPeekPosition() > dataEndPosition - 4) { return true; } @@ -452,7 +452,7 @@ public final class Mp3Extractor implements Extractor { @Nullable Seeker resultSeeker = null; if ((flags & FLAG_ENABLE_INDEX_SEEKING) != 0) { long durationUs; - long dataEndPosition = C.POSITION_UNSET; + long dataEndPosition = C.INDEX_UNSET; if (metadataSeeker != null) { durationUs = metadataSeeker.getDurationUs(); dataEndPosition = metadataSeeker.getDataEndPosition(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Seeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Seeker.java index c5b7550f2d..c959109a3d 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Seeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Seeker.java @@ -35,7 +35,7 @@ import com.google.android.exoplayer2.extractor.SeekMap; /** * 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(); @@ -54,7 +54,7 @@ import com.google.android.exoplayer2.extractor.SeekMap; @Override public long getDataEndPosition() { // 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; } } } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java index 51950e6282..94b5dc4233 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java @@ -114,7 +114,7 @@ import com.google.android.exoplayer2.util.Util; this.durationUs = durationUs; this.tableOfContents = tableOfContents; this.dataSize = dataSize; - dataEndPosition = dataSize == C.LENGTH_UNSET ? C.POSITION_UNSET : dataStartPosition + dataSize; + dataEndPosition = dataSize == C.LENGTH_UNSET ? C.INDEX_UNSET : dataStartPosition + dataSize; } @Override diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java index ec5c6fdd92..c5a128ea4b 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java @@ -1515,7 +1515,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; childAtomType == Atom.TYPE_esds ? childPosition : findBoxPosition(parent, Atom.TYPE_esds, childPosition, childAtomSize); - if (esdsAtomPosition != C.POSITION_UNSET) { + if (esdsAtomPosition != C.INDEX_UNSET) { esdsData = parseEsdsFromParent(parent, esdsAtomPosition); mimeType = esdsData.mimeType; @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 - * {@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 * 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 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 - * {@link C#POSITION_UNSET} if no such box is found. + * {@link C#INDEX_UNSET} if no such box is found. */ private static int findBoxPosition( ParsableByteArray parent, int boxType, int parentBoxPosition, int parentBoxSize) @@ -1648,7 +1648,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } childAtomPosition += childAtomSize; } - return C.POSITION_UNSET; + return C.INDEX_UNSET; } /** Returns codec-specific initialization data contained in an esds box. */ @@ -1736,7 +1736,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; /* package */ static Pair parseCommonEncryptionSinfFromParent( ParsableByteArray parent, int position, int size) throws ParserException { int childPosition = position + Atom.HEADER_SIZE; - int schemeInformationBoxPosition = C.POSITION_UNSET; + int schemeInformationBoxPosition = C.INDEX_UNSET; int schemeInformationBoxSize = 0; @Nullable String schemeType = null; @Nullable Integer dataFormat = null; @@ -1763,7 +1763,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; || C.CENC_TYPE_cbcs.equals(schemeType)) { ExtractorUtil.checkContainerInput(dataFormat != null, "frma atom is mandatory"); ExtractorUtil.checkContainerInput( - schemeInformationBoxPosition != C.POSITION_UNSET, "schi atom is mandatory"); + schemeInformationBoxPosition != C.INDEX_UNSET, "schi atom is mandatory"); @Nullable TrackEncryptionBox encryptionBox = parseSchiFromParent( diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java index 5197f2da08..7816d06640 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java @@ -302,7 +302,7 @@ public final class Mp4Extractor implements Extractor, SeekMap { long firstTimeUs; long firstOffset; long secondTimeUs = C.TIME_UNSET; - long secondOffset = C.POSITION_UNSET; + long secondOffset = C.INDEX_UNSET; // Note that the id matches the index in tracks. int mainTrackIndex = trackId != C.INDEX_UNSET ? trackId : firstVideoTrackIndex; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java index 29a0f5932a..db11708ff5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java @@ -109,7 +109,7 @@ import java.io.IOException; return positionBeforeSeekToEnd; case STATE_SEEK: long position = getNextSeekPosition(input); - if (position != C.POSITION_UNSET) { + if (position != C.INDEX_UNSET) { return position; } 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 - * should be provided for the next step, or {@link C#POSITION_UNSET} if the search has converged. - * If the search has converged then {@link #skipToPageOfTargetGranule(ExtractorInput)} should be + * should be provided for the next step, or {@link C#INDEX_UNSET} if the search has converged. If + * the search has converged then {@link #skipToPageOfTargetGranule(ExtractorInput)} should be * called to skip to the target page. * * @param input The {@link ExtractorInput} to read from. * @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. */ private long getNextSeekPosition(ExtractorInput input) throws IOException { if (start == end) { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } long currentPosition = input.getPosition(); @@ -170,7 +170,7 @@ import java.io.IOException; long granuleDistance = targetGranule - pageHeader.granulePosition; int pageSize = pageHeader.headerSize + pageHeader.bodySize; if (0 <= granuleDistance && granuleDistance < MATCH_RANGE) { - return C.POSITION_UNSET; + return C.INDEX_UNSET; } if (granuleDistance < 0) { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java index 306e64f559..a0ed53ebae 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java @@ -79,7 +79,7 @@ import java.io.IOException; * *\/ C.POSITION_UNSET)}. */ 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 == * 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. * @return True if a capture_pattern was found. * @throws IOException If reading data fails. @@ -102,7 +102,7 @@ import java.io.IOException; public boolean skipToNextPage(ExtractorInput input, long limit) throws IOException { Assertions.checkArgument(input.getPosition() == input.getPeekPosition()); 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( input, scratch.getData(), 0, CAPTURE_PATTERN_SIZE, /* allowEndOfInput= */ true)) { scratch.setPosition(0); @@ -114,7 +114,7 @@ import java.io.IOException; input.skipFully(1); } // 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) {} return false; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java index e704f2ff89..0dbf52d236 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java @@ -130,7 +130,7 @@ public final class AdtsExtractor implements Extractor { reader = new AdtsReader(true); packetBuffer = new ParsableByteArray(MAX_PACKET_SIZE); 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. scratch = new ParsableByteArray(ID3_HEADER_LENGTH); scratchBits = new ParsableBitArray(scratch.getData()); @@ -256,7 +256,7 @@ public final class AdtsExtractor implements Extractor { } input.resetPeekPosition(); input.advancePeekPosition(firstFramePosition); - if (this.firstFramePosition == C.POSITION_UNSET) { + if (this.firstFramePosition == C.INDEX_UNSET) { this.firstFramePosition = firstFramePosition; } return firstFramePosition; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java index 3616a0c354..16f5223dc4 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java @@ -89,8 +89,8 @@ import java.io.IOException; private TimestampSearchResult searchForScrValueInBuffer( ParsableByteArray packetBuffer, long targetScrTimeUs, long bufferStartOffset) { - int startOfLastPacketPosition = C.POSITION_UNSET; - int endOfLastPacketPosition = C.POSITION_UNSET; + int startOfLastPacketPosition = C.INDEX_UNSET; + int endOfLastPacketPosition = C.INDEX_UNSET; long lastScrTimeUsInRange = C.TIME_UNSET; while (packetBuffer.bytesLeft() >= 4) { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java index 4a73799c07..d39296836c 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java @@ -64,7 +64,7 @@ public final class SectionReader implements TsPayloadReader { @Override public void consume(ParsableByteArray data, @Flags int flags) { boolean payloadUnitStartIndicator = (flags & FLAG_PAYLOAD_UNIT_START_INDICATOR) != 0; - int payloadStartPosition = C.POSITION_UNSET; + int payloadStartPosition = C.INDEX_UNSET; if (payloadUnitStartIndicator) { int payloadStartOffset = data.readUnsignedByte(); payloadStartPosition = data.getPosition() + payloadStartOffset; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java index fa9792079c..ec633efa9c 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java @@ -96,8 +96,8 @@ import java.io.IOException; ParsableByteArray packetBuffer, long targetPcrTimeUs, long bufferStartOffset) { int limit = packetBuffer.limit(); - long startOfLastPacketPosition = C.POSITION_UNSET; - long endOfLastPacketPosition = C.POSITION_UNSET; + long startOfLastPacketPosition = C.INDEX_UNSET; + long endOfLastPacketPosition = C.INDEX_UNSET; long lastPcrTimeUsInRange = C.TIME_UNSET; while (packetBuffer.bytesLeft() >= TsExtractor.TS_PACKET_SIZE) { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java index 8d64cb0255..a5ca847087 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java @@ -90,8 +90,8 @@ public final class WavExtractor implements Extractor { public WavExtractor() { state = STATE_READING_FILE_TYPE; rf64SampleDataSize = C.LENGTH_UNSET; - dataStartPosition = C.POSITION_UNSET; - dataEndPosition = C.POSITION_UNSET; + dataStartPosition = C.INDEX_UNSET; + dataEndPosition = C.INDEX_UNSET; } @Override @@ -151,7 +151,7 @@ public final class WavExtractor implements Extractor { private void readFileType(ExtractorInput input) throws IOException { Assertions.checkState(input.getPosition() == 0); - if (dataStartPosition != C.POSITION_UNSET) { + if (dataStartPosition != C.INDEX_UNSET) { input.skipFully(dataStartPosition); state = STATE_READING_SAMPLE_DATA; return; @@ -226,7 +226,7 @@ public final class WavExtractor implements Extractor { } 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(); return Assertions.checkNotNull(outputWriter).sampleData(input, bytesLeft) ? RESULT_END_OF_INPUT diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java index e759a73aac..a9b4d5ebfd 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java @@ -31,9 +31,9 @@ public final class ChapterFrame extends Id3Frame { public final String chapterId; public final int startTimeMs; 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; - /** 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; private final Id3Frame[] subFrames; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java index 0ee41664e4..505aa64bd8 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java @@ -657,11 +657,11 @@ public final class Id3Decoder extends SimpleMetadataDecoder { int endTime = id3Data.readInt(); long startOffset = id3Data.readUnsignedInt(); if (startOffset == 0xFFFFFFFFL) { - startOffset = C.POSITION_UNSET; + startOffset = C.INDEX_UNSET; } long endOffset = id3Data.readUnsignedInt(); if (endOffset == 0xFFFFFFFFL) { - endOffset = C.POSITION_UNSET; + endOffset = C.INDEX_UNSET; } ArrayList subFrames = new ArrayList<>(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java b/library/extractor/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java index e9a7be7015..a8f2b2dd0a 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java @@ -1005,10 +1005,10 @@ public final class Cea708Decoder extends CeaDecoder { public void clear() { rolledUpCaptions.clear(); captionStringBuilder.clear(); - italicsStartPosition = C.POSITION_UNSET; - underlineStartPosition = C.POSITION_UNSET; - foregroundColorStartPosition = C.POSITION_UNSET; - backgroundColorStartPosition = C.POSITION_UNSET; + italicsStartPosition = C.INDEX_UNSET; + underlineStartPosition = C.INDEX_UNSET; + foregroundColorStartPosition = C.INDEX_UNSET; + backgroundColorStartPosition = C.INDEX_UNSET; row = 0; } @@ -1120,27 +1120,27 @@ public final class Cea708Decoder extends CeaDecoder { // TODO: Add support for other offsets. // TODO: Add support for other pen sizes. - if (italicsStartPosition != C.POSITION_UNSET) { + if (italicsStartPosition != C.INDEX_UNSET) { if (!italicsToggle) { captionStringBuilder.setSpan( new StyleSpan(Typeface.ITALIC), italicsStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - italicsStartPosition = C.POSITION_UNSET; + italicsStartPosition = C.INDEX_UNSET; } } else if (italicsToggle) { italicsStartPosition = captionStringBuilder.length(); } - if (underlineStartPosition != C.POSITION_UNSET) { + if (underlineStartPosition != C.INDEX_UNSET) { if (!underlineToggle) { captionStringBuilder.setSpan( new UnderlineSpan(), underlineStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - underlineStartPosition = C.POSITION_UNSET; + underlineStartPosition = C.INDEX_UNSET; } } else if (underlineToggle) { underlineStartPosition = captionStringBuilder.length(); @@ -1151,7 +1151,7 @@ public final class Cea708Decoder extends CeaDecoder { } public void setPenColor(int foregroundColor, int backgroundColor, int edgeColor) { - if (foregroundColorStartPosition != C.POSITION_UNSET) { + if (foregroundColorStartPosition != C.INDEX_UNSET) { if (this.foregroundColor != foregroundColor) { captionStringBuilder.setSpan( new ForegroundColorSpan(this.foregroundColor), @@ -1165,7 +1165,7 @@ public final class Cea708Decoder extends CeaDecoder { this.foregroundColor = foregroundColor; } - if (backgroundColorStartPosition != C.POSITION_UNSET) { + if (backgroundColorStartPosition != C.INDEX_UNSET) { if (this.backgroundColor != backgroundColor) { captionStringBuilder.setSpan( new BackgroundColorSpan(this.backgroundColor), @@ -1207,16 +1207,16 @@ public final class Cea708Decoder extends CeaDecoder { rolledUpCaptions.add(buildSpannableString()); captionStringBuilder.clear(); - if (italicsStartPosition != C.POSITION_UNSET) { + if (italicsStartPosition != C.INDEX_UNSET) { italicsStartPosition = 0; } - if (underlineStartPosition != C.POSITION_UNSET) { + if (underlineStartPosition != C.INDEX_UNSET) { underlineStartPosition = 0; } - if (foregroundColorStartPosition != C.POSITION_UNSET) { + if (foregroundColorStartPosition != C.INDEX_UNSET) { foregroundColorStartPosition = 0; } - if (backgroundColorStartPosition != C.POSITION_UNSET) { + if (backgroundColorStartPosition != C.INDEX_UNSET) { backgroundColorStartPosition = 0; } @@ -1235,7 +1235,7 @@ public final class Cea708Decoder extends CeaDecoder { int length = spannableStringBuilder.length(); if (length > 0) { - if (italicsStartPosition != C.POSITION_UNSET) { + if (italicsStartPosition != C.INDEX_UNSET) { spannableStringBuilder.setSpan( new StyleSpan(Typeface.ITALIC), italicsStartPosition, @@ -1243,7 +1243,7 @@ public final class Cea708Decoder extends CeaDecoder { Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } - if (underlineStartPosition != C.POSITION_UNSET) { + if (underlineStartPosition != C.INDEX_UNSET) { spannableStringBuilder.setSpan( new UnderlineSpan(), underlineStartPosition, @@ -1251,7 +1251,7 @@ public final class Cea708Decoder extends CeaDecoder { Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } - if (foregroundColorStartPosition != C.POSITION_UNSET) { + if (foregroundColorStartPosition != C.INDEX_UNSET) { spannableStringBuilder.setSpan( new ForegroundColorSpan(foregroundColor), foregroundColorStartPosition, @@ -1259,7 +1259,7 @@ public final class Cea708Decoder extends CeaDecoder { Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } - if (backgroundColorStartPosition != C.POSITION_UNSET) { + if (backgroundColorStartPosition != C.INDEX_UNSET) { spannableStringBuilder.setSpan( new BackgroundColorSpan(backgroundColor), backgroundColorStartPosition, diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java index dea5d20ad9..4d9d17c647 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/PsExtractorSeekTest.java @@ -218,7 +218,7 @@ public final class PsExtractorSeekTest { long initialSeekLoadPosition = seekPoints.first.position; psExtractor.seek(initialSeekLoadPosition, seekTimeUs); - positionHolder.position = C.POSITION_UNSET; + positionHolder.position = C.INDEX_UNSET; ExtractorInput extractorInput = getExtractorInputFromPosition(initialSeekLoadPosition); int extractorReadResult = Extractor.RESULT_CONTINUE; while (true) { diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java index 18bed1670a..bd85f4eaea 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java @@ -426,7 +426,7 @@ public class TestUtil { extractor.seek(initialSeekLoadPosition, seekTimeUs); PositionHolder positionHolder = new PositionHolder(); - positionHolder.position = C.POSITION_UNSET; + positionHolder.position = C.INDEX_UNSET; ExtractorInput extractorInput = TestUtil.getExtractorInputFromPosition(dataSource, initialSeekLoadPosition, uri); int extractorReadResult = Extractor.RESULT_CONTINUE;