mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Move peek result constants into SampleMetadataQueue
PiperOrigin-RevId: 277253308
This commit is contained in:
parent
817772fcbd
commit
81b8396b3e
2 changed files with 34 additions and 35 deletions
|
|
@ -15,14 +15,17 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.source;
|
package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.FormatHolder;
|
import com.google.android.exoplayer2.FormatHolder;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
||||||
import com.google.android.exoplayer2.extractor.TrackOutput.CryptoData;
|
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.Assertions;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
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.
|
* 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 static final int SAMPLE_CAPACITY_INCREMENT = 1000;
|
||||||
|
|
||||||
private int capacity;
|
private int capacity;
|
||||||
|
|
@ -226,15 +250,15 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
@PeekResult
|
@PeekResult
|
||||||
public synchronized int peekNext(Format downstreamFormat) {
|
public synchronized int peekNext(Format downstreamFormat) {
|
||||||
if (readPosition == length) {
|
if (readPosition == length) {
|
||||||
return SampleQueue.PEEK_RESULT_NOTHING;
|
return PEEK_RESULT_NOTHING;
|
||||||
}
|
}
|
||||||
int relativeReadIndex = getRelativeIndex(readPosition);
|
int relativeReadIndex = getRelativeIndex(readPosition);
|
||||||
if (formats[relativeReadIndex] != downstreamFormat) {
|
if (formats[relativeReadIndex] != downstreamFormat) {
|
||||||
return SampleQueue.PEEK_RESULT_FORMAT;
|
return PEEK_RESULT_FORMAT;
|
||||||
} else {
|
} else {
|
||||||
return (flags[relativeReadIndex] & C.BUFFER_FLAG_ENCRYPTED) != 0
|
return (flags[relativeReadIndex] & C.BUFFER_FLAG_ENCRYPTED) != 0
|
||||||
? SampleQueue.PEEK_RESULT_BUFFER_ENCRYPTED
|
? PEEK_RESULT_BUFFER_ENCRYPTED
|
||||||
: SampleQueue.PEEK_RESULT_BUFFER_CLEAR;
|
: PEEK_RESULT_BUFFER_CLEAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
package com.google.android.exoplayer2.source;
|
package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.annotation.IntDef;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
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 com.google.android.exoplayer2.util.Util;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Documented;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/** A queue of media samples. */
|
/** 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;
|
public static final int ADVANCE_FAILED = -1;
|
||||||
|
|
||||||
private static final int INITIAL_SCRATCH_SIZE = 32;
|
private static final int INITIAL_SCRATCH_SIZE = 32;
|
||||||
|
|
@ -480,15 +455,15 @@ public class SampleQueue implements TrackOutput {
|
||||||
* queue is empty.
|
* queue is empty.
|
||||||
*/
|
*/
|
||||||
public boolean isReady(boolean loadingFinished) {
|
public boolean isReady(boolean loadingFinished) {
|
||||||
@SampleQueue.PeekResult int nextInQueue = metadataQueue.peekNext(downstreamFormat);
|
@SampleMetadataQueue.PeekResult int nextInQueue = metadataQueue.peekNext(downstreamFormat);
|
||||||
switch (nextInQueue) {
|
switch (nextInQueue) {
|
||||||
case SampleQueue.PEEK_RESULT_NOTHING:
|
case SampleMetadataQueue.PEEK_RESULT_NOTHING:
|
||||||
return loadingFinished;
|
return loadingFinished;
|
||||||
case SampleQueue.PEEK_RESULT_FORMAT:
|
case SampleMetadataQueue.PEEK_RESULT_FORMAT:
|
||||||
return true;
|
return true;
|
||||||
case SampleQueue.PEEK_RESULT_BUFFER_CLEAR:
|
case SampleMetadataQueue.PEEK_RESULT_BUFFER_CLEAR:
|
||||||
return currentSession == null || playClearSamplesWithoutKeys;
|
return currentSession == null || playClearSamplesWithoutKeys;
|
||||||
case SampleQueue.PEEK_RESULT_BUFFER_ENCRYPTED:
|
case SampleMetadataQueue.PEEK_RESULT_BUFFER_ENCRYPTED:
|
||||||
return drmSessionManager == DrmSessionManager.DUMMY
|
return drmSessionManager == DrmSessionManager.DUMMY
|
||||||
|| Assertions.checkNotNull(currentSession).getState()
|
|| Assertions.checkNotNull(currentSession).getState()
|
||||||
== DrmSession.STATE_OPENED_WITH_KEYS;
|
== DrmSession.STATE_OPENED_WITH_KEYS;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue