diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8a8d64520f..d910688873 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -26,7 +26,10 @@ * Add `ConcatenatingMediaSource2` that allows combining multiple media items into a single window ([#247](https://github.com/androidx/media/issues/247)). -* Extractors: + * Update `SampleQueue` to store `sourceId` as a `long` rather than an + `int`. This changes the signatures of public methods + `SampleQueue.sourceId` and `SampleQueue.peekSourceId`. + * Extractors: * Throw a ParserException instead of a NullPointerException if the sample table (stbl) is missing a required sample description (stsd) when parsing trak atoms. diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SampleQueue.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SampleQueue.java index b9881c7ec1..bf7c8f396e 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SampleQueue.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SampleQueue.java @@ -81,7 +81,7 @@ public class SampleQueue implements TrackOutput { @Nullable private DrmSession currentDrmSession; private int capacity; - private int[] sourceIds; + private long[] sourceIds; private long[] offsets; private int[] sizes; private int[] flags; @@ -102,7 +102,7 @@ public class SampleQueue implements TrackOutput { private boolean upstreamFormatAdjustmentRequired; @Nullable private Format unadjustedUpstreamFormat; @Nullable private Format upstreamFormat; - private int upstreamSourceId; + private long upstreamSourceId; private boolean upstreamAllSamplesAreSyncSamples; private boolean loggedUnexpectedNonSyncSample; @@ -168,7 +168,7 @@ public class SampleQueue implements TrackOutput { sampleDataQueue = new SampleDataQueue(allocator); extrasHolder = new SampleExtrasHolder(); capacity = SAMPLE_CAPACITY_INCREMENT; - sourceIds = new int[capacity]; + sourceIds = new long[capacity]; offsets = new long[capacity]; timesUs = new long[capacity]; flags = new int[capacity]; @@ -240,7 +240,7 @@ public class SampleQueue implements TrackOutput { * * @param sourceId The source identifier. */ - public final void sourceId(int sourceId) { + public final void sourceId(long sourceId) { upstreamSourceId = sourceId; } @@ -318,7 +318,7 @@ public class SampleQueue implements TrackOutput { * * @return The source id. */ - public final synchronized int peekSourceId() { + public final synchronized long peekSourceId() { int relativeReadIndex = getRelativeIndex(readPosition); return hasNextSample() ? sourceIds[relativeReadIndex] : upstreamSourceId; } @@ -828,7 +828,7 @@ public class SampleQueue implements TrackOutput { if (length == capacity) { // Increase the capacity. int newCapacity = capacity + SAMPLE_CAPACITY_INCREMENT; - int[] newSourceIds = new int[newCapacity]; + long[] newSourceIds = new long[newCapacity]; long[] newOffsets = new long[newCapacity]; long[] newTimesUs = new long[newCapacity]; int[] newFlags = new int[newCapacity]; diff --git a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsSampleStreamWrapper.java b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsSampleStreamWrapper.java index ac3f1a45cf..799eecb8c0 100644 --- a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsSampleStreamWrapper.java +++ b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsSampleStreamWrapper.java @@ -71,6 +71,7 @@ import androidx.media3.extractor.metadata.emsg.EventMessageDecoder; import androidx.media3.extractor.metadata.id3.PrivFrame; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; +import com.google.common.primitives.Ints; import java.io.EOFException; import java.io.IOException; import java.util.ArrayList; @@ -664,7 +665,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; Format format = Assertions.checkNotNull(formatHolder.format); if (sampleQueueIndex == primarySampleQueueIndex) { // Fill in primary sample format with information from the track format. - int chunkUid = sampleQueues[sampleQueueIndex].peekSourceId(); + int chunkUid = Ints.checkedCast(sampleQueues[sampleQueueIndex].peekSourceId()); int chunkIndex = 0; while (chunkIndex < mediaChunks.size() && mediaChunks.get(chunkIndex).uid != chunkUid) { chunkIndex++;