diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 8e7e1275f1..250d3174a8 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -22,6 +22,14 @@
* Add missing return type to proguard `-keepclasseswithmembers` rule for
`DefaultVideoFrameProcessor.Factory.Builder.build()`
([#1187](https://github.com/androidx/media/issues/1187)).
+ * Remove `Buffer.isDecodeOnly()` and `C.BUFFER_FLAG_DECODE_ONLY`. There is
+ no need to set this flag as renderers and decoders will decide to skip
+ buffers based on timestamp. Custom `Renderer` implementations should
+ check if the buffer time is at least
+ `BaseRenderer.getLastResetPositionUs()` to decide whether a sample
+ should be shown. Custom `SimpleDecoder` implementations can check
+ `isAtLeastOutputStartTimeUs` if needed or mark other buffers with
+ `DecoderOutputBuffer.shouldBeSkipped` to skip them.
* Transformer:
* Add `audioConversionProcess` and `videoConversionProcess` to
`ExportResult` indicating how the respective track in the output file
diff --git a/libraries/common/src/main/java/androidx/media3/common/C.java b/libraries/common/src/main/java/androidx/media3/common/C.java
index cc42ac8888..fd42dca63a 100644
--- a/libraries/common/src/main/java/androidx/media3/common/C.java
+++ b/libraries/common/src/main/java/androidx/media3/common/C.java
@@ -613,12 +613,18 @@ public final class C {
public static final int ALLOW_CAPTURE_BY_SYSTEM = AudioAttributes.ALLOW_CAPTURE_BY_SYSTEM;
/**
- * Flags which can apply to a buffer containing a media sample. Possible flag values are {@link
- * #BUFFER_FLAG_KEY_FRAME}, {@link #BUFFER_FLAG_END_OF_STREAM}, {@link #BUFFER_FLAG_FIRST_SAMPLE},
- * {@link #BUFFER_FLAG_LAST_SAMPLE}, {@link #BUFFER_FLAG_ENCRYPTED} and {@link
- * #BUFFER_FLAG_DECODE_ONLY}.
+ * Flags which can apply to a buffer containing a media sample.
+ *
+ *
Possible flag values are:
+ *
+ *
+ * - {@link #BUFFER_FLAG_KEY_FRAME}
+ *
- {@link #BUFFER_FLAG_END_OF_STREAM}
+ *
- {@link #BUFFER_FLAG_FIRST_SAMPLE}
+ *
- {@link #BUFFER_FLAG_LAST_SAMPLE}
+ *
- {@link #BUFFER_FLAG_ENCRYPTED}
+ *
*/
- @SuppressWarnings("deprecation") // Includes deprecated BUFFER_FLAG_DECODE_ONLY flag.
@UnstableApi
@Documented
@Retention(RetentionPolicy.SOURCE)
@@ -631,8 +637,7 @@ public final class C {
BUFFER_FLAG_FIRST_SAMPLE,
BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA,
BUFFER_FLAG_LAST_SAMPLE,
- BUFFER_FLAG_ENCRYPTED,
- BUFFER_FLAG_DECODE_ONLY
+ BUFFER_FLAG_ENCRYPTED
})
public @interface BufferFlags {}
@@ -655,13 +660,6 @@ public final class C {
/** Indicates that a buffer is (at least partially) encrypted. */
@UnstableApi public static final int BUFFER_FLAG_ENCRYPTED = 1 << 30; // 0x40000000
- /**
- * @deprecated Renderers and decoders will check whether the buffer time is greater or equal to
- * the desired start time without the need to set this flag. Custom decoders can mark other
- * buffers with {@code DecoderOutputBuffer.shouldBeSkipped} if needed.
- */
- @UnstableApi @Deprecated public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000
-
/** A realtime {@linkplain MediaFormat#KEY_PRIORITY codec priority}. */
@UnstableApi public static final int MEDIA_CODEC_PRIORITY_REALTIME = 0;
diff --git a/libraries/decoder/src/main/java/androidx/media3/decoder/Buffer.java b/libraries/decoder/src/main/java/androidx/media3/decoder/Buffer.java
index 88ef271b78..ef61c48d95 100644
--- a/libraries/decoder/src/main/java/androidx/media3/decoder/Buffer.java
+++ b/libraries/decoder/src/main/java/androidx/media3/decoder/Buffer.java
@@ -31,18 +31,6 @@ public abstract class Buffer {
flags = 0;
}
- /**
- * @deprecated Check instead whether the buffer time is greater or equal to the desired start
- * time. In custom renderers, the start time is {@code BaseRenderer.getLastResetPositionUs()}.
- * In custom decoders, the check can be done with {@link
- * SimpleDecoder#isAtLeastOutputStartTimeUs}.
- */
- @Deprecated
- @SuppressWarnings("deprecation") // Checking deprecated flag.
- public final boolean isDecodeOnly() {
- return getFlag(C.BUFFER_FLAG_DECODE_ONLY);
- }
-
/** Returns whether the {@link C#BUFFER_FLAG_FIRST_SAMPLE} flag is set. */
public final boolean isFirstSample() {
return getFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
diff --git a/libraries/decoder/src/main/java/androidx/media3/decoder/SimpleDecoder.java b/libraries/decoder/src/main/java/androidx/media3/decoder/SimpleDecoder.java
index 1e671aec9b..cec438b8dd 100644
--- a/libraries/decoder/src/main/java/androidx/media3/decoder/SimpleDecoder.java
+++ b/libraries/decoder/src/main/java/androidx/media3/decoder/SimpleDecoder.java
@@ -236,9 +236,6 @@ public abstract class SimpleDecoder<
}
}
- // Setting and checking deprecated decode-only flag for compatibility with custom decoders that
- // are still using it.
- @SuppressWarnings("deprecation")
private boolean decode() throws InterruptedException {
I inputBuffer;
O outputBuffer;
@@ -262,9 +259,6 @@ public abstract class SimpleDecoder<
outputBuffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
} else {
outputBuffer.timeUs = inputBuffer.timeUs;
- if (!isAtLeastOutputStartTimeUs(inputBuffer.timeUs) || inputBuffer.isDecodeOnly()) {
- outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
- }
if (inputBuffer.isFirstSample()) {
outputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
}
@@ -293,7 +287,6 @@ public abstract class SimpleDecoder<
if (flushed) {
outputBuffer.release();
} else if ((!outputBuffer.isEndOfStream() && !isAtLeastOutputStartTimeUs(outputBuffer.timeUs))
- || outputBuffer.isDecodeOnly()
|| outputBuffer.shouldBeSkipped) {
skippedOutputBufferCount++;
outputBuffer.release();
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DecoderAudioRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DecoderAudioRenderer.java
index bc895f6846..680a9750aa 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DecoderAudioRenderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DecoderAudioRenderer.java
@@ -491,8 +491,6 @@ public abstract class DecoderAudioRenderer<
}
}
- // Setting deprecated decode-only flag for compatibility with decoders that are still using it.
- @SuppressWarnings("deprecation")
private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException {
if (decoder == null
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
@@ -534,9 +532,6 @@ public abstract class DecoderAudioRenderer<
firstStreamSampleRead = true;
inputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
}
- if (inputBuffer.timeUs < getLastResetPositionUs()) {
- inputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
- }
inputBuffer.flip();
inputBuffer.format = inputFormat;
decoder.queueInputBuffer(inputBuffer);
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/image/ImageRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/image/ImageRenderer.java
index 1edc42b4cb..878902be10 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/image/ImageRenderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/image/ImageRenderer.java
@@ -424,7 +424,6 @@ public class ImageRenderer extends BaseRenderer {
* current iteration of the rendering loop.
* @return Whether we can feed more input data to the decoder.
*/
- @SuppressWarnings("deprecation") // Clearing C.BUFFER_FLAG_DECODE_ONLY for compatibility
private boolean feedInputBuffer(long positionUs) throws ImageDecoderException {
if (readyToOutputTiles && tileInfo != null) {
return false;
@@ -461,8 +460,6 @@ public class ImageRenderer extends BaseRenderer {
checkStateNotNull(inputBuffer.data).remaining() > 0
|| checkStateNotNull(inputBuffer).isEndOfStream();
if (shouldQueueBuffer) {
- // TODO: b/318696449 - Don't use the deprecated BUFFER_FLAG_DECODE_ONLY with image chunks.
- checkStateNotNull(inputBuffer).clearFlag(C.BUFFER_FLAG_DECODE_ONLY);
checkStateNotNull(decoder).queueInputBuffer(checkStateNotNull(inputBuffer));
currentTileIndex = 0;
}
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 332b2faffc..9a7544d171 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
@@ -693,9 +693,7 @@ public class SampleQueue implements TrackOutput {
sampleDataQueue.rewind();
}
- // Setting deprecated decode-only flag for compatibility with renderers that are still using it.
- // See comments in setUpstreamFormat for reference equality warning.
- @SuppressWarnings({"ReferenceEquality", "deprecation"})
+ @SuppressWarnings("ReferenceEquality") // See comments in setUpstreamFormat.
private synchronized int peekSampleMetadata(
FormatHolder formatHolder,
DecoderInputBuffer buffer,
@@ -733,9 +731,6 @@ public class SampleQueue implements TrackOutput {
buffer.addFlag(C.BUFFER_FLAG_LAST_SAMPLE);
}
buffer.timeUs = timesUs[relativeReadIndex];
- if (buffer.timeUs < startTimeUs) {
- buffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
- }
extrasHolder.size = sizes[relativeReadIndex];
extrasHolder.offset = offsets[relativeReadIndex];
extrasHolder.cryptoData = cryptoDatas[relativeReadIndex];
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/TextRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/TextRenderer.java
index 3bd87d620f..6368f6a471 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/TextRenderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/TextRenderer.java
@@ -248,8 +248,6 @@ public final class TextRenderer extends BaseRenderer implements Callback {
}
}
- // Setting deprecated decode-only flag for compatibility with decoders that are still using it.
- @SuppressWarnings("deprecation")
@Override
public void render(long positionUs, long elapsedRealtimeUs) {
if (isCurrentStreamFinal()
@@ -349,7 +347,6 @@ public final class TextRenderer extends BaseRenderer implements Callback {
}
}
- @SuppressWarnings("deprecation") // Using deprecated C.BUFFER_FLAG_DECODE_ONLY for compatibility
private void renderFromSubtitles(long positionUs) {
lastRendererPositionUs = positionUs;
if (nextSubtitle == null) {
@@ -447,9 +444,6 @@ public final class TextRenderer extends BaseRenderer implements Callback {
waitingForKeyFrame &= !nextInputBuffer.isKeyFrame();
}
if (!waitingForKeyFrame) {
- if (nextInputBuffer.timeUs < getLastResetPositionUs()) {
- nextInputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
- }
checkNotNull(subtitleDecoder).queueInputBuffer(nextInputBuffer);
this.nextSubtitleInputBuffer = null;
}
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DecoderVideoRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DecoderVideoRenderer.java
index 2364e908ef..e128285879 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DecoderVideoRenderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DecoderVideoRenderer.java
@@ -739,8 +739,6 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
}
}
- // Setting deprecated decode-only flag for compatibility with decoders that are still using it.
- @SuppressWarnings("deprecation")
private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException {
if (decoder == null
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
@@ -783,9 +781,6 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
formatQueue.add(inputBuffer.timeUs, checkNotNull(inputFormat));
waitingForFirstSampleInFormat = false;
}
- if (inputBuffer.timeUs < getLastResetPositionUs()) {
- inputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
- }
inputBuffer.flip();
inputBuffer.format = inputFormat;
onQueueInputBuffer(inputBuffer);
diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/SampleQueueTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/SampleQueueTest.java
index b990923b73..54545ec866 100644
--- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/SampleQueueTest.java
+++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/SampleQueueTest.java
@@ -209,7 +209,6 @@ public final class SampleQueueTest {
assertReadSample(
/* timeUs= */ i * 1000,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
/* sampleData= */ new byte[1],
/* offset= */ 0,
@@ -272,7 +271,6 @@ public final class SampleQueueTest {
assertReadSample(
0,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -281,7 +279,6 @@ public final class SampleQueueTest {
assertReadSample(
1000,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -297,7 +294,6 @@ public final class SampleQueueTest {
assertReadSample(
2000,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -327,7 +323,6 @@ public final class SampleQueueTest {
assertReadSample(
1000,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -351,7 +346,6 @@ public final class SampleQueueTest {
assertReadSample(
2000,
/* isKeyFrame= */ false,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -370,13 +364,7 @@ public final class SampleQueueTest {
assertReadFormat(true, FORMAT_1);
// Read the sample.
assertReadSample(
- 3000,
- /* isKeyFrame= */ false,
- /* isDecodeOnly= */ false,
- /* isEncrypted= */ false,
- DATA,
- ALLOCATION_SIZE - 1,
- 1);
+ 3000, /* isKeyFrame= */ false, /* isEncrypted= */ false, DATA, ALLOCATION_SIZE - 1, 1);
// Allocation should still be held.
assertAllocationCount(1);
sampleQueue.discardToRead();
@@ -397,7 +385,6 @@ public final class SampleQueueTest {
assertReadLastSample(
1000,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -681,7 +668,6 @@ public final class SampleQueueTest {
assertReadSample(
/* timeUs= */ 0,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -778,8 +764,7 @@ public final class SampleQueueTest {
/* startFormat= */ null,
DATA_SECOND_KEYFRAME_INDEX,
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
- /* sampleOffsetUs= */ 0,
- /* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP);
+ /* sampleOffsetUs= */ 0);
assertNoSamplesToRead(FORMAT_2);
}
@@ -811,8 +796,7 @@ public final class SampleQueueTest {
/* startFormat= */ null,
DATA_SECOND_KEYFRAME_INDEX,
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
- /* sampleOffsetUs= */ 0,
- /* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP + 1);
+ /* sampleOffsetUs= */ 0);
assertNoSamplesToRead(FORMAT_2);
}
@@ -829,8 +813,7 @@ public final class SampleQueueTest {
/* startFormat= */ null,
DATA_SECOND_KEYFRAME_INDEX,
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
- /* sampleOffsetUs= */ 0,
- /* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP);
+ /* sampleOffsetUs= */ 0);
assertNoSamplesToRead(FORMAT_2);
// Seek back to the start.
@@ -947,7 +930,6 @@ public final class SampleQueueTest {
assertReadSample(
SAMPLE_TIMESTAMPS[7],
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
DATA.length - SAMPLE_OFFSETS[7] - SAMPLE_SIZES[7],
@@ -964,8 +946,7 @@ public final class SampleQueueTest {
/* startFormat= */ null,
/* firstSampleIndex= */ 0,
/* sampleCount= */ SAMPLE_TIMESTAMPS.length,
- /* sampleOffsetUs= */ 0,
- /* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP);
+ /* sampleOffsetUs= */ 0);
}
@Test
@@ -1351,11 +1332,7 @@ public final class SampleQueueTest {
sampleQueue.setSampleOffsetUs(sampleOffsetUs);
writeTestData();
assertReadTestData(
- /* startFormat= */ null,
- /* firstSampleIndex= */ 0,
- /* sampleCount= */ 8,
- sampleOffsetUs,
- /* decodeOnlyUntilUs= */ 0);
+ /* startFormat= */ null, /* firstSampleIndex= */ 0, /* sampleCount= */ 8, sampleOffsetUs);
assertReadEndOfStream(/* formatRequired= */ false);
}
@@ -1378,7 +1355,6 @@ public final class SampleQueueTest {
assertReadSample(
unadjustedTimestampUs + sampleOffsetUs,
/* isKeyFrame= */ false,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -1426,7 +1402,6 @@ public final class SampleQueueTest {
assertReadSample(
/* timeUs= */ 0,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -1435,7 +1410,6 @@ public final class SampleQueueTest {
assertReadSample(
/* timeUs= */ 1,
/* isKeyFrame= */ false,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -1456,7 +1430,6 @@ public final class SampleQueueTest {
assertReadSample(
spliceSampleTimeUs,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -1487,7 +1460,6 @@ public final class SampleQueueTest {
assertReadSample(
spliceSampleTimeUs,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -1505,13 +1477,12 @@ public final class SampleQueueTest {
long spliceSampleTimeUs = SAMPLE_TIMESTAMPS[4];
writeFormat(FORMAT_SPLICED);
writeSample(DATA, spliceSampleTimeUs, C.BUFFER_FLAG_KEY_FRAME);
- assertReadTestData(/* startFormat= */ null, 0, 4, sampleOffsetUs, /* decodeOnlyUntilUs= */ 0);
+ assertReadTestData(/* startFormat= */ null, 0, 4, sampleOffsetUs);
assertReadFormat(
false, FORMAT_SPLICED.buildUpon().setSubsampleOffsetUs(sampleOffsetUs).build());
assertReadSample(
spliceSampleTimeUs + sampleOffsetUs,
/* isKeyFrame= */ true,
- /* isDecodeOnly= */ false,
/* isEncrypted= */ false,
DATA,
/* offset= */ 0,
@@ -1619,7 +1590,6 @@ public final class SampleQueueTest {
firstSampleIndex,
sampleCount,
/* sampleOffsetUs= */ 0,
- /* decodeOnlyUntilUs= */ 0,
SAMPLE_FORMATS_SYNC_SAMPLES_ONLY,
SAMPLE_FLAGS_SYNC_SAMPLES_ONLY);
}
@@ -1656,12 +1626,7 @@ public final class SampleQueueTest {
* @param sampleCount The number of samples to read.
*/
private void assertReadTestData(Format startFormat, int firstSampleIndex, int sampleCount) {
- assertReadTestData(
- startFormat,
- firstSampleIndex,
- sampleCount,
- /* sampleOffsetUs= */ 0,
- /* decodeOnlyUntilUs= */ 0);
+ assertReadTestData(startFormat, firstSampleIndex, sampleCount, /* sampleOffsetUs= */ 0);
}
/**
@@ -1673,19 +1638,9 @@ public final class SampleQueueTest {
* @param sampleOffsetUs The expected sample offset.
*/
private void assertReadTestData(
- Format startFormat,
- int firstSampleIndex,
- int sampleCount,
- long sampleOffsetUs,
- long decodeOnlyUntilUs) {
+ Format startFormat, int firstSampleIndex, int sampleCount, long sampleOffsetUs) {
assertReadTestData(
- startFormat,
- firstSampleIndex,
- sampleCount,
- sampleOffsetUs,
- decodeOnlyUntilUs,
- SAMPLE_FORMATS,
- SAMPLE_FLAGS);
+ startFormat, firstSampleIndex, sampleCount, sampleOffsetUs, SAMPLE_FORMATS, SAMPLE_FLAGS);
}
/**
@@ -1701,7 +1656,6 @@ public final class SampleQueueTest {
int firstSampleIndex,
int sampleCount,
long sampleOffsetUs,
- long decodeOnlyUntilUs,
Format[] sampleFormats,
int[] sampleFlags) {
Format format = adjustFormat(startFormat, sampleOffsetUs);
@@ -1721,7 +1675,6 @@ public final class SampleQueueTest {
assertReadSample(
expectedTimeUs,
(sampleFlags[i] & C.BUFFER_FLAG_KEY_FRAME) != 0,
- /* isDecodeOnly= */ expectedTimeUs < decodeOnlyUntilUs,
/* isEncrypted= */ false,
DATA,
DATA.length - SAMPLE_OFFSETS[i] - SAMPLE_SIZES[i],
@@ -1798,7 +1751,6 @@ public final class SampleQueueTest {
// inputBuffer should not contain sample data, but end of stream flag should be set.
assertInputBufferContainsNoSampleData();
assertThat(inputBuffer.isEndOfStream()).isTrue();
- assertThat(inputBuffer.isDecodeOnly()).isFalse();
assertThat(inputBuffer.isEncrypted()).isFalse();
}
@@ -1833,7 +1785,6 @@ public final class SampleQueueTest {
assertReadSample(
ENCRYPTED_SAMPLE_TIMESTAMPS[sampleIndex],
isKeyFrame,
- /* isDecodeOnly= */ false,
isEncrypted,
sampleData,
/* offset= */ 0,
@@ -1846,7 +1797,6 @@ public final class SampleQueueTest {
*
* @param timeUs The expected buffer timestamp.
* @param isKeyFrame The expected keyframe flag.
- * @param isDecodeOnly The expected decodeOnly flag.
* @param isEncrypted The expected encrypted flag.
* @param sampleData An array containing the expected sample data.
* @param offset The offset in {@code sampleData} of the expected sample data.
@@ -1855,7 +1805,6 @@ public final class SampleQueueTest {
private void assertReadSample(
long timeUs,
boolean isKeyFrame,
- boolean isDecodeOnly,
boolean isEncrypted,
byte[] sampleData,
int offset,
@@ -1870,13 +1819,7 @@ public final class SampleQueueTest {
FLAG_OMIT_SAMPLE_DATA | FLAG_PEEK,
/* loadingFinished= */ false);
assertSampleBufferReadResult(
- flagsOnlyBuffer,
- result,
- timeUs,
- isKeyFrame,
- isDecodeOnly,
- isEncrypted,
- /* isLastSample= */ false);
+ flagsOnlyBuffer, result, timeUs, isKeyFrame, isEncrypted, /* isLastSample= */ false);
// Check that peek yields the expected values.
clearFormatHolderAndInputBuffer();
@@ -1885,7 +1828,6 @@ public final class SampleQueueTest {
result,
timeUs,
isKeyFrame,
- isDecodeOnly,
isEncrypted,
/* isLastSample= */ false,
sampleData,
@@ -1901,7 +1843,6 @@ public final class SampleQueueTest {
result,
timeUs,
isKeyFrame,
- isDecodeOnly,
isEncrypted,
/* isLastSample= */ false,
sampleData,
@@ -1916,7 +1857,6 @@ public final class SampleQueueTest {
*
* @param timeUs The expected buffer timestamp.
* @param isKeyFrame The expected keyframe flag.
- * @param isDecodeOnly The expected decodeOnly flag.
* @param isEncrypted The expected encrypted flag.
* @param sampleData An array containing the expected sample data.
* @param offset The offset in {@code sampleData} of the expected sample data.
@@ -1925,7 +1865,6 @@ public final class SampleQueueTest {
private void assertReadLastSample(
long timeUs,
boolean isKeyFrame,
- boolean isDecodeOnly,
boolean isEncrypted,
byte[] sampleData,
int offset,
@@ -1940,13 +1879,7 @@ public final class SampleQueueTest {
FLAG_OMIT_SAMPLE_DATA | FLAG_PEEK,
/* loadingFinished= */ true);
assertSampleBufferReadResult(
- flagsOnlyBuffer,
- result,
- timeUs,
- isKeyFrame,
- isDecodeOnly,
- isEncrypted,
- /* isLastSample= */ true);
+ flagsOnlyBuffer, result, timeUs, isKeyFrame, isEncrypted, /* isLastSample= */ true);
// Check that peek yields the expected values.
clearFormatHolderAndInputBuffer();
@@ -1955,7 +1888,6 @@ public final class SampleQueueTest {
result,
timeUs,
isKeyFrame,
- isDecodeOnly,
isEncrypted,
/* isLastSample= */ true,
sampleData,
@@ -1971,7 +1903,6 @@ public final class SampleQueueTest {
result,
timeUs,
isKeyFrame,
- isDecodeOnly,
isEncrypted,
/* isLastSample= */ true,
sampleData,
@@ -1984,7 +1915,6 @@ public final class SampleQueueTest {
int result,
long timeUs,
boolean isKeyFrame,
- boolean isDecodeOnly,
boolean isEncrypted,
boolean isLastSample) {
assertThat(result).isEqualTo(RESULT_BUFFER_READ);
@@ -1993,7 +1923,6 @@ public final class SampleQueueTest {
// inputBuffer should be populated with metadata.
assertThat(inputBuffer.timeUs).isEqualTo(timeUs);
assertThat(inputBuffer.isKeyFrame()).isEqualTo(isKeyFrame);
- assertThat(inputBuffer.isDecodeOnly()).isEqualTo(isDecodeOnly);
assertThat(inputBuffer.isEncrypted()).isEqualTo(isEncrypted);
assertThat(inputBuffer.isLastSample()).isEqualTo(isLastSample);
}
@@ -2002,14 +1931,13 @@ public final class SampleQueueTest {
int result,
long timeUs,
boolean isKeyFrame,
- boolean isDecodeOnly,
boolean isEncrypted,
boolean isLastSample,
byte[] sampleData,
int offset,
int length) {
assertSampleBufferReadResult(
- inputBuffer, result, timeUs, isKeyFrame, isDecodeOnly, isEncrypted, isLastSample);
+ inputBuffer, result, timeUs, isKeyFrame, isEncrypted, isLastSample);
// inputBuffer should be populated with data.
inputBuffer.flip();
assertThat(inputBuffer.data.limit()).isEqualTo(length);
@@ -2038,7 +1966,6 @@ public final class SampleQueueTest {
private void assertInputBufferHasNoDefaultFlagsSet() {
assertThat(inputBuffer.isEndOfStream()).isFalse();
- assertThat(inputBuffer.isDecodeOnly()).isFalse();
assertThat(inputBuffer.isEncrypted()).isFalse();
}
diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/text/SimpleSubtitleDecoder.java b/libraries/extractor/src/main/java/androidx/media3/extractor/text/SimpleSubtitleDecoder.java
index 7cc2a5caa5..75f017fca1 100644
--- a/libraries/extractor/src/main/java/androidx/media3/extractor/text/SimpleSubtitleDecoder.java
+++ b/libraries/extractor/src/main/java/androidx/media3/extractor/text/SimpleSubtitleDecoder.java
@@ -16,7 +16,6 @@
package androidx.media3.extractor.text;
import androidx.annotation.Nullable;
-import androidx.media3.common.C;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.decoder.SimpleDecoder;
@@ -70,8 +69,7 @@ public abstract class SimpleSubtitleDecoder
return new SubtitleDecoderException("Unexpected decode error", error);
}
- // Clearing deprecated decode-only flag for compatibility with decoders that are still using it.
- @SuppressWarnings({"ByteBufferBackingArray", "deprecation"})
+ @SuppressWarnings("ByteBufferBackingArray")
@Override
@Nullable
protected final SubtitleDecoderException decode(
@@ -80,8 +78,6 @@ public abstract class SimpleSubtitleDecoder
ByteBuffer inputData = Assertions.checkNotNull(inputBuffer.data);
Subtitle subtitle = decode(inputData.array(), inputData.limit(), reset);
outputBuffer.setContent(inputBuffer.timeUs, subtitle, inputBuffer.subsampleOffsetUs);
- // Clear BUFFER_FLAG_DECODE_ONLY (see [Internal: b/27893809]).
- outputBuffer.clearFlag(C.BUFFER_FLAG_DECODE_ONLY);
return null;
} catch (SubtitleDecoderException e) {
return e;
diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/text/SubtitleTranscodingTrackOutput.java b/libraries/extractor/src/main/java/androidx/media3/extractor/text/SubtitleTranscodingTrackOutput.java
index 4122261cda..44f4ffa460 100644
--- a/libraries/extractor/src/main/java/androidx/media3/extractor/text/SubtitleTranscodingTrackOutput.java
+++ b/libraries/extractor/src/main/java/androidx/media3/extractor/text/SubtitleTranscodingTrackOutput.java
@@ -157,16 +157,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
- // Clearing deprecated decode-only flag for compatibility with decoders that are still using it.
- @SuppressWarnings("deprecation")
private void outputSample(CuesWithTiming cuesWithTiming, long timeUs, int flags) {
checkStateNotNull(currentFormat); // format() must be called before sampleMetadata()
byte[] cuesWithDurationBytes =
cueEncoder.encode(cuesWithTiming.cues, cuesWithTiming.durationUs);
parsableScratch.reset(cuesWithDurationBytes);
delegate.sampleData(parsableScratch, cuesWithDurationBytes.length);
- // Clear FLAG_DECODE_ONLY if it is set.
- flags &= ~C.BUFFER_FLAG_DECODE_ONLY;
long outputSampleTimeUs;
if (cuesWithTiming.startTimeUs == C.TIME_UNSET) {
checkState(currentFormat.subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE);