Remove decode-only flag
No known component is using this flag anymore and it has been deprecated for a while for custom renderers and decoders. PiperOrigin-RevId: 619154299
This commit is contained in:
parent
ef2314c404
commit
6e0f8e3b0d
@ -22,6 +22,14 @@
|
|||||||
* Add missing return type to proguard `-keepclasseswithmembers` rule for
|
* Add missing return type to proguard `-keepclasseswithmembers` rule for
|
||||||
`DefaultVideoFrameProcessor.Factory.Builder.build()`
|
`DefaultVideoFrameProcessor.Factory.Builder.build()`
|
||||||
([#1187](https://github.com/androidx/media/issues/1187)).
|
([#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:
|
* Transformer:
|
||||||
* Add `audioConversionProcess` and `videoConversionProcess` to
|
* Add `audioConversionProcess` and `videoConversionProcess` to
|
||||||
`ExportResult` indicating how the respective track in the output file
|
`ExportResult` indicating how the respective track in the output file
|
||||||
|
@ -613,12 +613,18 @@ public final class C {
|
|||||||
public static final int ALLOW_CAPTURE_BY_SYSTEM = AudioAttributes.ALLOW_CAPTURE_BY_SYSTEM;
|
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
|
* Flags which can apply to a buffer containing a media sample.
|
||||||
* #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
|
* <p>Possible flag values are:
|
||||||
* #BUFFER_FLAG_DECODE_ONLY}.
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #BUFFER_FLAG_KEY_FRAME}
|
||||||
|
* <li>{@link #BUFFER_FLAG_END_OF_STREAM}
|
||||||
|
* <li>{@link #BUFFER_FLAG_FIRST_SAMPLE}
|
||||||
|
* <li>{@link #BUFFER_FLAG_LAST_SAMPLE}
|
||||||
|
* <li>{@link #BUFFER_FLAG_ENCRYPTED}
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation") // Includes deprecated BUFFER_FLAG_DECODE_ONLY flag.
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@Documented
|
@Documented
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@ -631,8 +637,7 @@ public final class C {
|
|||||||
BUFFER_FLAG_FIRST_SAMPLE,
|
BUFFER_FLAG_FIRST_SAMPLE,
|
||||||
BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA,
|
BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA,
|
||||||
BUFFER_FLAG_LAST_SAMPLE,
|
BUFFER_FLAG_LAST_SAMPLE,
|
||||||
BUFFER_FLAG_ENCRYPTED,
|
BUFFER_FLAG_ENCRYPTED
|
||||||
BUFFER_FLAG_DECODE_ONLY
|
|
||||||
})
|
})
|
||||||
public @interface BufferFlags {}
|
public @interface BufferFlags {}
|
||||||
|
|
||||||
@ -655,13 +660,6 @@ public final class C {
|
|||||||
/** Indicates that a buffer is (at least partially) encrypted. */
|
/** Indicates that a buffer is (at least partially) encrypted. */
|
||||||
@UnstableApi public static final int BUFFER_FLAG_ENCRYPTED = 1 << 30; // 0x40000000
|
@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}. */
|
/** A realtime {@linkplain MediaFormat#KEY_PRIORITY codec priority}. */
|
||||||
@UnstableApi public static final int MEDIA_CODEC_PRIORITY_REALTIME = 0;
|
@UnstableApi public static final int MEDIA_CODEC_PRIORITY_REALTIME = 0;
|
||||||
|
|
||||||
|
@ -31,18 +31,6 @@ public abstract class Buffer {
|
|||||||
flags = 0;
|
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. */
|
/** Returns whether the {@link C#BUFFER_FLAG_FIRST_SAMPLE} flag is set. */
|
||||||
public final boolean isFirstSample() {
|
public final boolean isFirstSample() {
|
||||||
return getFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
|
return getFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
|
||||||
|
@ -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 {
|
private boolean decode() throws InterruptedException {
|
||||||
I inputBuffer;
|
I inputBuffer;
|
||||||
O outputBuffer;
|
O outputBuffer;
|
||||||
@ -262,9 +259,6 @@ public abstract class SimpleDecoder<
|
|||||||
outputBuffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
|
outputBuffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
|
||||||
} else {
|
} else {
|
||||||
outputBuffer.timeUs = inputBuffer.timeUs;
|
outputBuffer.timeUs = inputBuffer.timeUs;
|
||||||
if (!isAtLeastOutputStartTimeUs(inputBuffer.timeUs) || inputBuffer.isDecodeOnly()) {
|
|
||||||
outputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
|
|
||||||
}
|
|
||||||
if (inputBuffer.isFirstSample()) {
|
if (inputBuffer.isFirstSample()) {
|
||||||
outputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
|
outputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
|
||||||
}
|
}
|
||||||
@ -293,7 +287,6 @@ public abstract class SimpleDecoder<
|
|||||||
if (flushed) {
|
if (flushed) {
|
||||||
outputBuffer.release();
|
outputBuffer.release();
|
||||||
} else if ((!outputBuffer.isEndOfStream() && !isAtLeastOutputStartTimeUs(outputBuffer.timeUs))
|
} else if ((!outputBuffer.isEndOfStream() && !isAtLeastOutputStartTimeUs(outputBuffer.timeUs))
|
||||||
|| outputBuffer.isDecodeOnly()
|
|
||||||
|| outputBuffer.shouldBeSkipped) {
|
|| outputBuffer.shouldBeSkipped) {
|
||||||
skippedOutputBufferCount++;
|
skippedOutputBufferCount++;
|
||||||
outputBuffer.release();
|
outputBuffer.release();
|
||||||
|
@ -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 {
|
private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException {
|
||||||
if (decoder == null
|
if (decoder == null
|
||||||
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
|
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
|
||||||
@ -534,9 +532,6 @@ public abstract class DecoderAudioRenderer<
|
|||||||
firstStreamSampleRead = true;
|
firstStreamSampleRead = true;
|
||||||
inputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
|
inputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
|
||||||
}
|
}
|
||||||
if (inputBuffer.timeUs < getLastResetPositionUs()) {
|
|
||||||
inputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
|
|
||||||
}
|
|
||||||
inputBuffer.flip();
|
inputBuffer.flip();
|
||||||
inputBuffer.format = inputFormat;
|
inputBuffer.format = inputFormat;
|
||||||
decoder.queueInputBuffer(inputBuffer);
|
decoder.queueInputBuffer(inputBuffer);
|
||||||
|
@ -424,7 +424,6 @@ public class ImageRenderer extends BaseRenderer {
|
|||||||
* current iteration of the rendering loop.
|
* current iteration of the rendering loop.
|
||||||
* @return Whether we can feed more input data to the decoder.
|
* @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 {
|
private boolean feedInputBuffer(long positionUs) throws ImageDecoderException {
|
||||||
if (readyToOutputTiles && tileInfo != null) {
|
if (readyToOutputTiles && tileInfo != null) {
|
||||||
return false;
|
return false;
|
||||||
@ -461,8 +460,6 @@ public class ImageRenderer extends BaseRenderer {
|
|||||||
checkStateNotNull(inputBuffer.data).remaining() > 0
|
checkStateNotNull(inputBuffer.data).remaining() > 0
|
||||||
|| checkStateNotNull(inputBuffer).isEndOfStream();
|
|| checkStateNotNull(inputBuffer).isEndOfStream();
|
||||||
if (shouldQueueBuffer) {
|
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));
|
checkStateNotNull(decoder).queueInputBuffer(checkStateNotNull(inputBuffer));
|
||||||
currentTileIndex = 0;
|
currentTileIndex = 0;
|
||||||
}
|
}
|
||||||
|
@ -693,9 +693,7 @@ public class SampleQueue implements TrackOutput {
|
|||||||
sampleDataQueue.rewind();
|
sampleDataQueue.rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting deprecated decode-only flag for compatibility with renderers that are still using it.
|
@SuppressWarnings("ReferenceEquality") // See comments in setUpstreamFormat.
|
||||||
// See comments in setUpstreamFormat for reference equality warning.
|
|
||||||
@SuppressWarnings({"ReferenceEquality", "deprecation"})
|
|
||||||
private synchronized int peekSampleMetadata(
|
private synchronized int peekSampleMetadata(
|
||||||
FormatHolder formatHolder,
|
FormatHolder formatHolder,
|
||||||
DecoderInputBuffer buffer,
|
DecoderInputBuffer buffer,
|
||||||
@ -733,9 +731,6 @@ public class SampleQueue implements TrackOutput {
|
|||||||
buffer.addFlag(C.BUFFER_FLAG_LAST_SAMPLE);
|
buffer.addFlag(C.BUFFER_FLAG_LAST_SAMPLE);
|
||||||
}
|
}
|
||||||
buffer.timeUs = timesUs[relativeReadIndex];
|
buffer.timeUs = timesUs[relativeReadIndex];
|
||||||
if (buffer.timeUs < startTimeUs) {
|
|
||||||
buffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
|
|
||||||
}
|
|
||||||
extrasHolder.size = sizes[relativeReadIndex];
|
extrasHolder.size = sizes[relativeReadIndex];
|
||||||
extrasHolder.offset = offsets[relativeReadIndex];
|
extrasHolder.offset = offsets[relativeReadIndex];
|
||||||
extrasHolder.cryptoData = cryptoDatas[relativeReadIndex];
|
extrasHolder.cryptoData = cryptoDatas[relativeReadIndex];
|
||||||
|
@ -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
|
@Override
|
||||||
public void render(long positionUs, long elapsedRealtimeUs) {
|
public void render(long positionUs, long elapsedRealtimeUs) {
|
||||||
if (isCurrentStreamFinal()
|
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) {
|
private void renderFromSubtitles(long positionUs) {
|
||||||
lastRendererPositionUs = positionUs;
|
lastRendererPositionUs = positionUs;
|
||||||
if (nextSubtitle == null) {
|
if (nextSubtitle == null) {
|
||||||
@ -447,9 +444,6 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
|||||||
waitingForKeyFrame &= !nextInputBuffer.isKeyFrame();
|
waitingForKeyFrame &= !nextInputBuffer.isKeyFrame();
|
||||||
}
|
}
|
||||||
if (!waitingForKeyFrame) {
|
if (!waitingForKeyFrame) {
|
||||||
if (nextInputBuffer.timeUs < getLastResetPositionUs()) {
|
|
||||||
nextInputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
|
|
||||||
}
|
|
||||||
checkNotNull(subtitleDecoder).queueInputBuffer(nextInputBuffer);
|
checkNotNull(subtitleDecoder).queueInputBuffer(nextInputBuffer);
|
||||||
this.nextSubtitleInputBuffer = null;
|
this.nextSubtitleInputBuffer = null;
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException {
|
||||||
if (decoder == null
|
if (decoder == null
|
||||||
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
|
|| decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
|
||||||
@ -783,9 +781,6 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
|
|||||||
formatQueue.add(inputBuffer.timeUs, checkNotNull(inputFormat));
|
formatQueue.add(inputBuffer.timeUs, checkNotNull(inputFormat));
|
||||||
waitingForFirstSampleInFormat = false;
|
waitingForFirstSampleInFormat = false;
|
||||||
}
|
}
|
||||||
if (inputBuffer.timeUs < getLastResetPositionUs()) {
|
|
||||||
inputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
|
|
||||||
}
|
|
||||||
inputBuffer.flip();
|
inputBuffer.flip();
|
||||||
inputBuffer.format = inputFormat;
|
inputBuffer.format = inputFormat;
|
||||||
onQueueInputBuffer(inputBuffer);
|
onQueueInputBuffer(inputBuffer);
|
||||||
|
@ -209,7 +209,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
/* timeUs= */ i * 1000,
|
/* timeUs= */ i * 1000,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
/* sampleData= */ new byte[1],
|
/* sampleData= */ new byte[1],
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -272,7 +271,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
0,
|
0,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -281,7 +279,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
1000,
|
1000,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -297,7 +294,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
2000,
|
2000,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -327,7 +323,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
1000,
|
1000,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -351,7 +346,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
2000,
|
2000,
|
||||||
/* isKeyFrame= */ false,
|
/* isKeyFrame= */ false,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -370,13 +364,7 @@ public final class SampleQueueTest {
|
|||||||
assertReadFormat(true, FORMAT_1);
|
assertReadFormat(true, FORMAT_1);
|
||||||
// Read the sample.
|
// Read the sample.
|
||||||
assertReadSample(
|
assertReadSample(
|
||||||
3000,
|
3000, /* isKeyFrame= */ false, /* isEncrypted= */ false, DATA, ALLOCATION_SIZE - 1, 1);
|
||||||
/* isKeyFrame= */ false,
|
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
|
||||||
DATA,
|
|
||||||
ALLOCATION_SIZE - 1,
|
|
||||||
1);
|
|
||||||
// Allocation should still be held.
|
// Allocation should still be held.
|
||||||
assertAllocationCount(1);
|
assertAllocationCount(1);
|
||||||
sampleQueue.discardToRead();
|
sampleQueue.discardToRead();
|
||||||
@ -397,7 +385,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadLastSample(
|
assertReadLastSample(
|
||||||
1000,
|
1000,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -681,7 +668,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
/* timeUs= */ 0,
|
/* timeUs= */ 0,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -778,8 +764,7 @@ public final class SampleQueueTest {
|
|||||||
/* startFormat= */ null,
|
/* startFormat= */ null,
|
||||||
DATA_SECOND_KEYFRAME_INDEX,
|
DATA_SECOND_KEYFRAME_INDEX,
|
||||||
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
|
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
|
||||||
/* sampleOffsetUs= */ 0,
|
/* sampleOffsetUs= */ 0);
|
||||||
/* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP);
|
|
||||||
assertNoSamplesToRead(FORMAT_2);
|
assertNoSamplesToRead(FORMAT_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,8 +796,7 @@ public final class SampleQueueTest {
|
|||||||
/* startFormat= */ null,
|
/* startFormat= */ null,
|
||||||
DATA_SECOND_KEYFRAME_INDEX,
|
DATA_SECOND_KEYFRAME_INDEX,
|
||||||
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
|
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
|
||||||
/* sampleOffsetUs= */ 0,
|
/* sampleOffsetUs= */ 0);
|
||||||
/* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP + 1);
|
|
||||||
assertNoSamplesToRead(FORMAT_2);
|
assertNoSamplesToRead(FORMAT_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,8 +813,7 @@ public final class SampleQueueTest {
|
|||||||
/* startFormat= */ null,
|
/* startFormat= */ null,
|
||||||
DATA_SECOND_KEYFRAME_INDEX,
|
DATA_SECOND_KEYFRAME_INDEX,
|
||||||
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
|
/* sampleCount= */ SAMPLE_TIMESTAMPS.length - DATA_SECOND_KEYFRAME_INDEX,
|
||||||
/* sampleOffsetUs= */ 0,
|
/* sampleOffsetUs= */ 0);
|
||||||
/* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP);
|
|
||||||
assertNoSamplesToRead(FORMAT_2);
|
assertNoSamplesToRead(FORMAT_2);
|
||||||
|
|
||||||
// Seek back to the start.
|
// Seek back to the start.
|
||||||
@ -947,7 +930,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
SAMPLE_TIMESTAMPS[7],
|
SAMPLE_TIMESTAMPS[7],
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
DATA.length - SAMPLE_OFFSETS[7] - SAMPLE_SIZES[7],
|
DATA.length - SAMPLE_OFFSETS[7] - SAMPLE_SIZES[7],
|
||||||
@ -964,8 +946,7 @@ public final class SampleQueueTest {
|
|||||||
/* startFormat= */ null,
|
/* startFormat= */ null,
|
||||||
/* firstSampleIndex= */ 0,
|
/* firstSampleIndex= */ 0,
|
||||||
/* sampleCount= */ SAMPLE_TIMESTAMPS.length,
|
/* sampleCount= */ SAMPLE_TIMESTAMPS.length,
|
||||||
/* sampleOffsetUs= */ 0,
|
/* sampleOffsetUs= */ 0);
|
||||||
/* decodeOnlyUntilUs= */ LAST_SAMPLE_TIMESTAMP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1351,11 +1332,7 @@ public final class SampleQueueTest {
|
|||||||
sampleQueue.setSampleOffsetUs(sampleOffsetUs);
|
sampleQueue.setSampleOffsetUs(sampleOffsetUs);
|
||||||
writeTestData();
|
writeTestData();
|
||||||
assertReadTestData(
|
assertReadTestData(
|
||||||
/* startFormat= */ null,
|
/* startFormat= */ null, /* firstSampleIndex= */ 0, /* sampleCount= */ 8, sampleOffsetUs);
|
||||||
/* firstSampleIndex= */ 0,
|
|
||||||
/* sampleCount= */ 8,
|
|
||||||
sampleOffsetUs,
|
|
||||||
/* decodeOnlyUntilUs= */ 0);
|
|
||||||
assertReadEndOfStream(/* formatRequired= */ false);
|
assertReadEndOfStream(/* formatRequired= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1378,7 +1355,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
unadjustedTimestampUs + sampleOffsetUs,
|
unadjustedTimestampUs + sampleOffsetUs,
|
||||||
/* isKeyFrame= */ false,
|
/* isKeyFrame= */ false,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1426,7 +1402,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
/* timeUs= */ 0,
|
/* timeUs= */ 0,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1435,7 +1410,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
/* timeUs= */ 1,
|
/* timeUs= */ 1,
|
||||||
/* isKeyFrame= */ false,
|
/* isKeyFrame= */ false,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1456,7 +1430,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
spliceSampleTimeUs,
|
spliceSampleTimeUs,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1487,7 +1460,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
spliceSampleTimeUs,
|
spliceSampleTimeUs,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1505,13 +1477,12 @@ public final class SampleQueueTest {
|
|||||||
long spliceSampleTimeUs = SAMPLE_TIMESTAMPS[4];
|
long spliceSampleTimeUs = SAMPLE_TIMESTAMPS[4];
|
||||||
writeFormat(FORMAT_SPLICED);
|
writeFormat(FORMAT_SPLICED);
|
||||||
writeSample(DATA, spliceSampleTimeUs, C.BUFFER_FLAG_KEY_FRAME);
|
writeSample(DATA, spliceSampleTimeUs, C.BUFFER_FLAG_KEY_FRAME);
|
||||||
assertReadTestData(/* startFormat= */ null, 0, 4, sampleOffsetUs, /* decodeOnlyUntilUs= */ 0);
|
assertReadTestData(/* startFormat= */ null, 0, 4, sampleOffsetUs);
|
||||||
assertReadFormat(
|
assertReadFormat(
|
||||||
false, FORMAT_SPLICED.buildUpon().setSubsampleOffsetUs(sampleOffsetUs).build());
|
false, FORMAT_SPLICED.buildUpon().setSubsampleOffsetUs(sampleOffsetUs).build());
|
||||||
assertReadSample(
|
assertReadSample(
|
||||||
spliceSampleTimeUs + sampleOffsetUs,
|
spliceSampleTimeUs + sampleOffsetUs,
|
||||||
/* isKeyFrame= */ true,
|
/* isKeyFrame= */ true,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1619,7 +1590,6 @@ public final class SampleQueueTest {
|
|||||||
firstSampleIndex,
|
firstSampleIndex,
|
||||||
sampleCount,
|
sampleCount,
|
||||||
/* sampleOffsetUs= */ 0,
|
/* sampleOffsetUs= */ 0,
|
||||||
/* decodeOnlyUntilUs= */ 0,
|
|
||||||
SAMPLE_FORMATS_SYNC_SAMPLES_ONLY,
|
SAMPLE_FORMATS_SYNC_SAMPLES_ONLY,
|
||||||
SAMPLE_FLAGS_SYNC_SAMPLES_ONLY);
|
SAMPLE_FLAGS_SYNC_SAMPLES_ONLY);
|
||||||
}
|
}
|
||||||
@ -1656,12 +1626,7 @@ public final class SampleQueueTest {
|
|||||||
* @param sampleCount The number of samples to read.
|
* @param sampleCount The number of samples to read.
|
||||||
*/
|
*/
|
||||||
private void assertReadTestData(Format startFormat, int firstSampleIndex, int sampleCount) {
|
private void assertReadTestData(Format startFormat, int firstSampleIndex, int sampleCount) {
|
||||||
assertReadTestData(
|
assertReadTestData(startFormat, firstSampleIndex, sampleCount, /* sampleOffsetUs= */ 0);
|
||||||
startFormat,
|
|
||||||
firstSampleIndex,
|
|
||||||
sampleCount,
|
|
||||||
/* sampleOffsetUs= */ 0,
|
|
||||||
/* decodeOnlyUntilUs= */ 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1673,19 +1638,9 @@ public final class SampleQueueTest {
|
|||||||
* @param sampleOffsetUs The expected sample offset.
|
* @param sampleOffsetUs The expected sample offset.
|
||||||
*/
|
*/
|
||||||
private void assertReadTestData(
|
private void assertReadTestData(
|
||||||
Format startFormat,
|
Format startFormat, int firstSampleIndex, int sampleCount, long sampleOffsetUs) {
|
||||||
int firstSampleIndex,
|
|
||||||
int sampleCount,
|
|
||||||
long sampleOffsetUs,
|
|
||||||
long decodeOnlyUntilUs) {
|
|
||||||
assertReadTestData(
|
assertReadTestData(
|
||||||
startFormat,
|
startFormat, firstSampleIndex, sampleCount, sampleOffsetUs, SAMPLE_FORMATS, SAMPLE_FLAGS);
|
||||||
firstSampleIndex,
|
|
||||||
sampleCount,
|
|
||||||
sampleOffsetUs,
|
|
||||||
decodeOnlyUntilUs,
|
|
||||||
SAMPLE_FORMATS,
|
|
||||||
SAMPLE_FLAGS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1701,7 +1656,6 @@ public final class SampleQueueTest {
|
|||||||
int firstSampleIndex,
|
int firstSampleIndex,
|
||||||
int sampleCount,
|
int sampleCount,
|
||||||
long sampleOffsetUs,
|
long sampleOffsetUs,
|
||||||
long decodeOnlyUntilUs,
|
|
||||||
Format[] sampleFormats,
|
Format[] sampleFormats,
|
||||||
int[] sampleFlags) {
|
int[] sampleFlags) {
|
||||||
Format format = adjustFormat(startFormat, sampleOffsetUs);
|
Format format = adjustFormat(startFormat, sampleOffsetUs);
|
||||||
@ -1721,7 +1675,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
expectedTimeUs,
|
expectedTimeUs,
|
||||||
(sampleFlags[i] & C.BUFFER_FLAG_KEY_FRAME) != 0,
|
(sampleFlags[i] & C.BUFFER_FLAG_KEY_FRAME) != 0,
|
||||||
/* isDecodeOnly= */ expectedTimeUs < decodeOnlyUntilUs,
|
|
||||||
/* isEncrypted= */ false,
|
/* isEncrypted= */ false,
|
||||||
DATA,
|
DATA,
|
||||||
DATA.length - SAMPLE_OFFSETS[i] - SAMPLE_SIZES[i],
|
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.
|
// inputBuffer should not contain sample data, but end of stream flag should be set.
|
||||||
assertInputBufferContainsNoSampleData();
|
assertInputBufferContainsNoSampleData();
|
||||||
assertThat(inputBuffer.isEndOfStream()).isTrue();
|
assertThat(inputBuffer.isEndOfStream()).isTrue();
|
||||||
assertThat(inputBuffer.isDecodeOnly()).isFalse();
|
|
||||||
assertThat(inputBuffer.isEncrypted()).isFalse();
|
assertThat(inputBuffer.isEncrypted()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1833,7 +1785,6 @@ public final class SampleQueueTest {
|
|||||||
assertReadSample(
|
assertReadSample(
|
||||||
ENCRYPTED_SAMPLE_TIMESTAMPS[sampleIndex],
|
ENCRYPTED_SAMPLE_TIMESTAMPS[sampleIndex],
|
||||||
isKeyFrame,
|
isKeyFrame,
|
||||||
/* isDecodeOnly= */ false,
|
|
||||||
isEncrypted,
|
isEncrypted,
|
||||||
sampleData,
|
sampleData,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
@ -1846,7 +1797,6 @@ public final class SampleQueueTest {
|
|||||||
*
|
*
|
||||||
* @param timeUs The expected buffer timestamp.
|
* @param timeUs The expected buffer timestamp.
|
||||||
* @param isKeyFrame The expected keyframe flag.
|
* @param isKeyFrame The expected keyframe flag.
|
||||||
* @param isDecodeOnly The expected decodeOnly flag.
|
|
||||||
* @param isEncrypted The expected encrypted flag.
|
* @param isEncrypted The expected encrypted flag.
|
||||||
* @param sampleData An array containing the expected sample data.
|
* @param sampleData An array containing the expected sample data.
|
||||||
* @param offset The offset in {@code sampleData} of 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(
|
private void assertReadSample(
|
||||||
long timeUs,
|
long timeUs,
|
||||||
boolean isKeyFrame,
|
boolean isKeyFrame,
|
||||||
boolean isDecodeOnly,
|
|
||||||
boolean isEncrypted,
|
boolean isEncrypted,
|
||||||
byte[] sampleData,
|
byte[] sampleData,
|
||||||
int offset,
|
int offset,
|
||||||
@ -1870,13 +1819,7 @@ public final class SampleQueueTest {
|
|||||||
FLAG_OMIT_SAMPLE_DATA | FLAG_PEEK,
|
FLAG_OMIT_SAMPLE_DATA | FLAG_PEEK,
|
||||||
/* loadingFinished= */ false);
|
/* loadingFinished= */ false);
|
||||||
assertSampleBufferReadResult(
|
assertSampleBufferReadResult(
|
||||||
flagsOnlyBuffer,
|
flagsOnlyBuffer, result, timeUs, isKeyFrame, isEncrypted, /* isLastSample= */ false);
|
||||||
result,
|
|
||||||
timeUs,
|
|
||||||
isKeyFrame,
|
|
||||||
isDecodeOnly,
|
|
||||||
isEncrypted,
|
|
||||||
/* isLastSample= */ false);
|
|
||||||
|
|
||||||
// Check that peek yields the expected values.
|
// Check that peek yields the expected values.
|
||||||
clearFormatHolderAndInputBuffer();
|
clearFormatHolderAndInputBuffer();
|
||||||
@ -1885,7 +1828,6 @@ public final class SampleQueueTest {
|
|||||||
result,
|
result,
|
||||||
timeUs,
|
timeUs,
|
||||||
isKeyFrame,
|
isKeyFrame,
|
||||||
isDecodeOnly,
|
|
||||||
isEncrypted,
|
isEncrypted,
|
||||||
/* isLastSample= */ false,
|
/* isLastSample= */ false,
|
||||||
sampleData,
|
sampleData,
|
||||||
@ -1901,7 +1843,6 @@ public final class SampleQueueTest {
|
|||||||
result,
|
result,
|
||||||
timeUs,
|
timeUs,
|
||||||
isKeyFrame,
|
isKeyFrame,
|
||||||
isDecodeOnly,
|
|
||||||
isEncrypted,
|
isEncrypted,
|
||||||
/* isLastSample= */ false,
|
/* isLastSample= */ false,
|
||||||
sampleData,
|
sampleData,
|
||||||
@ -1916,7 +1857,6 @@ public final class SampleQueueTest {
|
|||||||
*
|
*
|
||||||
* @param timeUs The expected buffer timestamp.
|
* @param timeUs The expected buffer timestamp.
|
||||||
* @param isKeyFrame The expected keyframe flag.
|
* @param isKeyFrame The expected keyframe flag.
|
||||||
* @param isDecodeOnly The expected decodeOnly flag.
|
|
||||||
* @param isEncrypted The expected encrypted flag.
|
* @param isEncrypted The expected encrypted flag.
|
||||||
* @param sampleData An array containing the expected sample data.
|
* @param sampleData An array containing the expected sample data.
|
||||||
* @param offset The offset in {@code sampleData} of 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(
|
private void assertReadLastSample(
|
||||||
long timeUs,
|
long timeUs,
|
||||||
boolean isKeyFrame,
|
boolean isKeyFrame,
|
||||||
boolean isDecodeOnly,
|
|
||||||
boolean isEncrypted,
|
boolean isEncrypted,
|
||||||
byte[] sampleData,
|
byte[] sampleData,
|
||||||
int offset,
|
int offset,
|
||||||
@ -1940,13 +1879,7 @@ public final class SampleQueueTest {
|
|||||||
FLAG_OMIT_SAMPLE_DATA | FLAG_PEEK,
|
FLAG_OMIT_SAMPLE_DATA | FLAG_PEEK,
|
||||||
/* loadingFinished= */ true);
|
/* loadingFinished= */ true);
|
||||||
assertSampleBufferReadResult(
|
assertSampleBufferReadResult(
|
||||||
flagsOnlyBuffer,
|
flagsOnlyBuffer, result, timeUs, isKeyFrame, isEncrypted, /* isLastSample= */ true);
|
||||||
result,
|
|
||||||
timeUs,
|
|
||||||
isKeyFrame,
|
|
||||||
isDecodeOnly,
|
|
||||||
isEncrypted,
|
|
||||||
/* isLastSample= */ true);
|
|
||||||
|
|
||||||
// Check that peek yields the expected values.
|
// Check that peek yields the expected values.
|
||||||
clearFormatHolderAndInputBuffer();
|
clearFormatHolderAndInputBuffer();
|
||||||
@ -1955,7 +1888,6 @@ public final class SampleQueueTest {
|
|||||||
result,
|
result,
|
||||||
timeUs,
|
timeUs,
|
||||||
isKeyFrame,
|
isKeyFrame,
|
||||||
isDecodeOnly,
|
|
||||||
isEncrypted,
|
isEncrypted,
|
||||||
/* isLastSample= */ true,
|
/* isLastSample= */ true,
|
||||||
sampleData,
|
sampleData,
|
||||||
@ -1971,7 +1903,6 @@ public final class SampleQueueTest {
|
|||||||
result,
|
result,
|
||||||
timeUs,
|
timeUs,
|
||||||
isKeyFrame,
|
isKeyFrame,
|
||||||
isDecodeOnly,
|
|
||||||
isEncrypted,
|
isEncrypted,
|
||||||
/* isLastSample= */ true,
|
/* isLastSample= */ true,
|
||||||
sampleData,
|
sampleData,
|
||||||
@ -1984,7 +1915,6 @@ public final class SampleQueueTest {
|
|||||||
int result,
|
int result,
|
||||||
long timeUs,
|
long timeUs,
|
||||||
boolean isKeyFrame,
|
boolean isKeyFrame,
|
||||||
boolean isDecodeOnly,
|
|
||||||
boolean isEncrypted,
|
boolean isEncrypted,
|
||||||
boolean isLastSample) {
|
boolean isLastSample) {
|
||||||
assertThat(result).isEqualTo(RESULT_BUFFER_READ);
|
assertThat(result).isEqualTo(RESULT_BUFFER_READ);
|
||||||
@ -1993,7 +1923,6 @@ public final class SampleQueueTest {
|
|||||||
// inputBuffer should be populated with metadata.
|
// inputBuffer should be populated with metadata.
|
||||||
assertThat(inputBuffer.timeUs).isEqualTo(timeUs);
|
assertThat(inputBuffer.timeUs).isEqualTo(timeUs);
|
||||||
assertThat(inputBuffer.isKeyFrame()).isEqualTo(isKeyFrame);
|
assertThat(inputBuffer.isKeyFrame()).isEqualTo(isKeyFrame);
|
||||||
assertThat(inputBuffer.isDecodeOnly()).isEqualTo(isDecodeOnly);
|
|
||||||
assertThat(inputBuffer.isEncrypted()).isEqualTo(isEncrypted);
|
assertThat(inputBuffer.isEncrypted()).isEqualTo(isEncrypted);
|
||||||
assertThat(inputBuffer.isLastSample()).isEqualTo(isLastSample);
|
assertThat(inputBuffer.isLastSample()).isEqualTo(isLastSample);
|
||||||
}
|
}
|
||||||
@ -2002,14 +1931,13 @@ public final class SampleQueueTest {
|
|||||||
int result,
|
int result,
|
||||||
long timeUs,
|
long timeUs,
|
||||||
boolean isKeyFrame,
|
boolean isKeyFrame,
|
||||||
boolean isDecodeOnly,
|
|
||||||
boolean isEncrypted,
|
boolean isEncrypted,
|
||||||
boolean isLastSample,
|
boolean isLastSample,
|
||||||
byte[] sampleData,
|
byte[] sampleData,
|
||||||
int offset,
|
int offset,
|
||||||
int length) {
|
int length) {
|
||||||
assertSampleBufferReadResult(
|
assertSampleBufferReadResult(
|
||||||
inputBuffer, result, timeUs, isKeyFrame, isDecodeOnly, isEncrypted, isLastSample);
|
inputBuffer, result, timeUs, isKeyFrame, isEncrypted, isLastSample);
|
||||||
// inputBuffer should be populated with data.
|
// inputBuffer should be populated with data.
|
||||||
inputBuffer.flip();
|
inputBuffer.flip();
|
||||||
assertThat(inputBuffer.data.limit()).isEqualTo(length);
|
assertThat(inputBuffer.data.limit()).isEqualTo(length);
|
||||||
@ -2038,7 +1966,6 @@ public final class SampleQueueTest {
|
|||||||
|
|
||||||
private void assertInputBufferHasNoDefaultFlagsSet() {
|
private void assertInputBufferHasNoDefaultFlagsSet() {
|
||||||
assertThat(inputBuffer.isEndOfStream()).isFalse();
|
assertThat(inputBuffer.isEndOfStream()).isFalse();
|
||||||
assertThat(inputBuffer.isDecodeOnly()).isFalse();
|
|
||||||
assertThat(inputBuffer.isEncrypted()).isFalse();
|
assertThat(inputBuffer.isEncrypted()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
package androidx.media3.extractor.text;
|
package androidx.media3.extractor.text;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.decoder.SimpleDecoder;
|
import androidx.media3.decoder.SimpleDecoder;
|
||||||
@ -70,8 +69,7 @@ public abstract class SimpleSubtitleDecoder
|
|||||||
return new SubtitleDecoderException("Unexpected decode error", error);
|
return new SubtitleDecoderException("Unexpected decode error", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clearing deprecated decode-only flag for compatibility with decoders that are still using it.
|
@SuppressWarnings("ByteBufferBackingArray")
|
||||||
@SuppressWarnings({"ByteBufferBackingArray", "deprecation"})
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected final SubtitleDecoderException decode(
|
protected final SubtitleDecoderException decode(
|
||||||
@ -80,8 +78,6 @@ public abstract class SimpleSubtitleDecoder
|
|||||||
ByteBuffer inputData = Assertions.checkNotNull(inputBuffer.data);
|
ByteBuffer inputData = Assertions.checkNotNull(inputBuffer.data);
|
||||||
Subtitle subtitle = decode(inputData.array(), inputData.limit(), reset);
|
Subtitle subtitle = decode(inputData.array(), inputData.limit(), reset);
|
||||||
outputBuffer.setContent(inputBuffer.timeUs, subtitle, inputBuffer.subsampleOffsetUs);
|
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;
|
return null;
|
||||||
} catch (SubtitleDecoderException e) {
|
} catch (SubtitleDecoderException e) {
|
||||||
return e;
|
return e;
|
||||||
|
@ -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) {
|
private void outputSample(CuesWithTiming cuesWithTiming, long timeUs, int flags) {
|
||||||
checkStateNotNull(currentFormat); // format() must be called before sampleMetadata()
|
checkStateNotNull(currentFormat); // format() must be called before sampleMetadata()
|
||||||
byte[] cuesWithDurationBytes =
|
byte[] cuesWithDurationBytes =
|
||||||
cueEncoder.encode(cuesWithTiming.cues, cuesWithTiming.durationUs);
|
cueEncoder.encode(cuesWithTiming.cues, cuesWithTiming.durationUs);
|
||||||
parsableScratch.reset(cuesWithDurationBytes);
|
parsableScratch.reset(cuesWithDurationBytes);
|
||||||
delegate.sampleData(parsableScratch, cuesWithDurationBytes.length);
|
delegate.sampleData(parsableScratch, cuesWithDurationBytes.length);
|
||||||
// Clear FLAG_DECODE_ONLY if it is set.
|
|
||||||
flags &= ~C.BUFFER_FLAG_DECODE_ONLY;
|
|
||||||
long outputSampleTimeUs;
|
long outputSampleTimeUs;
|
||||||
if (cuesWithTiming.startTimeUs == C.TIME_UNSET) {
|
if (cuesWithTiming.startTimeUs == C.TIME_UNSET) {
|
||||||
checkState(currentFormat.subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE);
|
checkState(currentFormat.subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user