Commit 81b8396b by aquilescanta Committed by Oliver Woodman

Move peek result constants into SampleMetadataQueue

PiperOrigin-RevId: 277253308
parent 817772fc
......@@ -15,14 +15,17 @@
*/
package com.google.android.exoplayer2.source;
import androidx.annotation.IntDef;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.extractor.TrackOutput.CryptoData;
import com.google.android.exoplayer2.source.SampleQueue.PeekResult;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* A queue of metadata describing the contents of a media buffer.
......@@ -40,6 +43,27 @@ import com.google.android.exoplayer2.util.Util;
}
/** Values returned by {@link #peekNext} ()}. */
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef(
value = {
PEEK_RESULT_NOTHING,
PEEK_RESULT_FORMAT,
PEEK_RESULT_BUFFER_CLEAR,
PEEK_RESULT_BUFFER_ENCRYPTED
})
public @interface PeekResult {}
/** Nothing is available for reading. */
public static final int PEEK_RESULT_NOTHING = 0;
/** A format change is available for reading */
public static final int PEEK_RESULT_FORMAT = 1;
/** A clear buffer is available for reading. */
public static final int PEEK_RESULT_BUFFER_CLEAR = 2;
/** An encrypted buffer is available for reading. */
public static final int PEEK_RESULT_BUFFER_ENCRYPTED = 3;
private static final int SAMPLE_CAPACITY_INCREMENT = 1000;
private int capacity;
......@@ -226,15 +250,15 @@ import com.google.android.exoplayer2.util.Util;
@PeekResult
public synchronized int peekNext(Format downstreamFormat) {
if (readPosition == length) {
return SampleQueue.PEEK_RESULT_NOTHING;
return PEEK_RESULT_NOTHING;
}
int relativeReadIndex = getRelativeIndex(readPosition);
if (formats[relativeReadIndex] != downstreamFormat) {
return SampleQueue.PEEK_RESULT_FORMAT;
return PEEK_RESULT_FORMAT;
} else {
return (flags[relativeReadIndex] & C.BUFFER_FLAG_ENCRYPTED) != 0
? SampleQueue.PEEK_RESULT_BUFFER_ENCRYPTED
: SampleQueue.PEEK_RESULT_BUFFER_CLEAR;
? PEEK_RESULT_BUFFER_ENCRYPTED
: PEEK_RESULT_BUFFER_CLEAR;
}
}
......
......@@ -16,7 +16,6 @@
package com.google.android.exoplayer2.source;
import android.os.Looper;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
......@@ -35,9 +34,6 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
import java.io.EOFException;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
/** A queue of media samples. */
......@@ -57,27 +53,6 @@ public class SampleQueue implements TrackOutput {
}
/** Values returned by {@link #peekNext()}. */
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef(
value = {
PEEK_RESULT_NOTHING,
PEEK_RESULT_FORMAT,
PEEK_RESULT_BUFFER_CLEAR,
PEEK_RESULT_BUFFER_ENCRYPTED
})
/* package */ @interface PeekResult {}
/** Nothing is available for reading. */
/* package */ static final int PEEK_RESULT_NOTHING = 0;
/** A format change is available for reading */
/* package */ static final int PEEK_RESULT_FORMAT = 1;
/** A clear buffer is available for reading. */
/* package */ static final int PEEK_RESULT_BUFFER_CLEAR = 2;
/** An encrypted buffer is available for reading. */
/* package */ static final int PEEK_RESULT_BUFFER_ENCRYPTED = 3;
public static final int ADVANCE_FAILED = -1;
private static final int INITIAL_SCRATCH_SIZE = 32;
......@@ -480,15 +455,15 @@ public class SampleQueue implements TrackOutput {
* queue is empty.
*/
public boolean isReady(boolean loadingFinished) {
@SampleQueue.PeekResult int nextInQueue = metadataQueue.peekNext(downstreamFormat);
@SampleMetadataQueue.PeekResult int nextInQueue = metadataQueue.peekNext(downstreamFormat);
switch (nextInQueue) {
case SampleQueue.PEEK_RESULT_NOTHING:
case SampleMetadataQueue.PEEK_RESULT_NOTHING:
return loadingFinished;
case SampleQueue.PEEK_RESULT_FORMAT:
case SampleMetadataQueue.PEEK_RESULT_FORMAT:
return true;
case SampleQueue.PEEK_RESULT_BUFFER_CLEAR:
case SampleMetadataQueue.PEEK_RESULT_BUFFER_CLEAR:
return currentSession == null || playClearSamplesWithoutKeys;
case SampleQueue.PEEK_RESULT_BUFFER_ENCRYPTED:
case SampleMetadataQueue.PEEK_RESULT_BUFFER_ENCRYPTED:
return drmSessionManager == DrmSessionManager.DUMMY
|| Assertions.checkNotNull(currentSession).getState()
== DrmSession.STATE_OPENED_WITH_KEYS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment