mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
Add open @IntDef for track selection reasons.
#exofixit PiperOrigin-RevId: 395217458
This commit is contained in:
parent
7129d84efd
commit
5183eaaf1e
16 changed files with 58 additions and 34 deletions
|
|
@ -696,6 +696,24 @@ public final class C {
|
|||
*/
|
||||
public static final int TRACK_TYPE_CUSTOM_BASE = 10000;
|
||||
|
||||
/**
|
||||
* Represents a reason for selection. May be one of {@link #SELECTION_REASON_UNKNOWN}, {@link
|
||||
* #SELECTION_REASON_INITIAL}, {@link #SELECTION_REASON_MANUAL}, {@link
|
||||
* #SELECTION_REASON_ADAPTIVE} or {@link #SELECTION_REASON_TRICK_PLAY}. May also be an app-defined
|
||||
* value (see {@link #SELECTION_REASON_CUSTOM_BASE}).
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(
|
||||
open = true,
|
||||
value = {
|
||||
SELECTION_REASON_UNKNOWN,
|
||||
SELECTION_REASON_INITIAL,
|
||||
SELECTION_REASON_MANUAL,
|
||||
SELECTION_REASON_ADAPTIVE,
|
||||
SELECTION_REASON_TRICK_PLAY
|
||||
})
|
||||
public @interface SelectionReason {}
|
||||
/** A selection reason constant for selections whose reasons are unknown or unspecified. */
|
||||
public static final int SELECTION_REASON_UNKNOWN = 0;
|
||||
/** A selection reason constant for an initial track selection. */
|
||||
|
|
|
|||
|
|
@ -1096,6 +1096,7 @@ public final class DownloadHelper {
|
|||
}
|
||||
|
||||
@Override
|
||||
@C.SelectionReason
|
||||
public int getSelectionReason() {
|
||||
return C.SELECTION_REASON_UNKNOWN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source;
|
|||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.C.DataType;
|
||||
import com.google.android.exoplayer2.C.SelectionReason;
|
||||
import com.google.android.exoplayer2.C.TrackType;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
|
||||
|
|
@ -37,8 +38,8 @@ public final class MediaLoadData {
|
|||
*/
|
||||
@Nullable public final Format trackFormat;
|
||||
/**
|
||||
* One of the {@link C} {@code SELECTION_REASON_*} constants if the data belongs to a track.
|
||||
* {@link C#SELECTION_REASON_UNKNOWN} otherwise.
|
||||
* One of the {@link SelectionReason selection reasons} if the data belongs to a track. {@link
|
||||
* C#SELECTION_REASON_UNKNOWN} otherwise.
|
||||
*/
|
||||
public final int trackSelectionReason;
|
||||
/**
|
||||
|
|
@ -82,9 +83,9 @@ public final class MediaLoadData {
|
|||
*/
|
||||
public MediaLoadData(
|
||||
@DataType int dataType,
|
||||
int trackType,
|
||||
@TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaStartTimeMs,
|
||||
long mediaEndTimeMs) {
|
||||
|
|
|
|||
|
|
@ -229,9 +229,9 @@ public interface MediaSourceEventListener {
|
|||
public void loadStarted(
|
||||
LoadEventInfo loadEventInfo,
|
||||
@DataType int dataType,
|
||||
int trackType,
|
||||
@C.TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaStartTimeUs,
|
||||
long mediaEndTimeUs) {
|
||||
|
|
@ -274,9 +274,9 @@ public interface MediaSourceEventListener {
|
|||
public void loadCompleted(
|
||||
LoadEventInfo loadEventInfo,
|
||||
@DataType int dataType,
|
||||
int trackType,
|
||||
@C.TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaStartTimeUs,
|
||||
long mediaEndTimeUs) {
|
||||
|
|
@ -320,9 +320,9 @@ public interface MediaSourceEventListener {
|
|||
public void loadCanceled(
|
||||
LoadEventInfo loadEventInfo,
|
||||
@DataType int dataType,
|
||||
int trackType,
|
||||
@C.TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaStartTimeUs,
|
||||
long mediaEndTimeUs) {
|
||||
|
|
@ -378,9 +378,9 @@ public interface MediaSourceEventListener {
|
|||
public void loadError(
|
||||
LoadEventInfo loadEventInfo,
|
||||
@DataType int dataType,
|
||||
int trackType,
|
||||
@C.TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaStartTimeUs,
|
||||
long mediaEndTimeUs,
|
||||
|
|
@ -445,9 +445,9 @@ public interface MediaSourceEventListener {
|
|||
|
||||
/** Dispatches {@link #onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)}. */
|
||||
public void downstreamFormatChanged(
|
||||
int trackType,
|
||||
@C.TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaTimeUs) {
|
||||
downstreamFormatChanged(
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public abstract class BaseMediaChunk extends MediaChunk {
|
|||
DataSource dataSource,
|
||||
DataSpec dataSpec,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long startTimeUs,
|
||||
long endTimeUs,
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ public abstract class Chunk implements Loadable {
|
|||
/** The format of the track to which this chunk belongs. */
|
||||
public final Format trackFormat;
|
||||
/**
|
||||
* One of the {@link C} {@code SELECTION_REASON_*} constants if the chunk belongs to a track.
|
||||
* {@link C#SELECTION_REASON_UNKNOWN} if the chunk does not belong to a track, or if the selection
|
||||
* reason is unknown.
|
||||
* One of the {@link C.SelectionReason selection reasons} if the chunk belongs to a track. {@link
|
||||
* C#SELECTION_REASON_UNKNOWN} if the chunk does not belong to a track, or if the selection reason
|
||||
* is unknown.
|
||||
*/
|
||||
public final int trackSelectionReason;
|
||||
@C.SelectionReason public final int trackSelectionReason;
|
||||
/**
|
||||
* Optional data associated with the selection of the track to which this chunk belongs. Null if
|
||||
* the chunk does not belong to a track, or if there is no associated track selection data.
|
||||
|
|
@ -82,7 +82,7 @@ public abstract class Chunk implements Loadable {
|
|||
DataSpec dataSpec,
|
||||
@DataType int type,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long startTimeUs,
|
||||
long endTimeUs) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class ContainerMediaChunk extends BaseMediaChunk {
|
|||
DataSource dataSource,
|
||||
DataSpec dataSpec,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long startTimeUs,
|
||||
long endTimeUs,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public abstract class DataChunk extends Chunk {
|
|||
DataSpec dataSpec,
|
||||
@DataType int type,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
@Nullable byte[] data) {
|
||||
super(
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public final class InitializationChunk extends Chunk {
|
|||
DataSource dataSource,
|
||||
DataSpec dataSpec,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
ChunkExtractor chunkExtractor) {
|
||||
super(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public abstract class MediaChunk extends Chunk {
|
|||
DataSource dataSource,
|
||||
DataSpec dataSpec,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long startTimeUs,
|
||||
long endTimeUs,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk {
|
|||
DataSource dataSource,
|
||||
DataSpec dataSpec,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long startTimeUs,
|
||||
long endTimeUs,
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
|||
RepresentationHolder representationHolder,
|
||||
DataSource dataSource,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
Object trackSelectionData,
|
||||
@Nullable RangedUri initializationUri,
|
||||
RangedUri indexUri) {
|
||||
|
|
@ -644,9 +644,9 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
|||
protected Chunk newMediaChunk(
|
||||
RepresentationHolder representationHolder,
|
||||
DataSource dataSource,
|
||||
int trackType,
|
||||
@C.TrackType int trackType,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
Object trackSelectionData,
|
||||
long firstSegmentNum,
|
||||
int maxSegmentCount,
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
DataSource dataSource,
|
||||
DataSpec dataSpec,
|
||||
Format trackFormat,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
byte[] scratchSpace) {
|
||||
super(
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
HlsChunkSource.SegmentBaseHolder segmentBaseHolder,
|
||||
Uri playlistUrl,
|
||||
@Nullable List<Format> muxedCaptionFormats,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
boolean isMasterTimestampSource,
|
||||
TimestampAdjusterProvider timestampAdjusterProvider,
|
||||
|
|
@ -280,7 +280,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
boolean initSegmentEncrypted,
|
||||
Uri playlistUrl,
|
||||
@Nullable List<Format> muxedCaptionFormats,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long startTimeUs,
|
||||
long endTimeUs,
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
|
|||
long chunkStartTimeUs,
|
||||
long chunkEndTimeUs,
|
||||
long chunkSeekTimeUs,
|
||||
int trackSelectionReason,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
ChunkExtractor chunkExtractor) {
|
||||
DataSpec dataSpec = new DataSpec(uri);
|
||||
|
|
|
|||
|
|
@ -46,9 +46,13 @@ public final class FakeMediaChunk extends MediaChunk {
|
|||
* @param trackFormat The {@link Format}.
|
||||
* @param startTimeUs The start time of the media, in microseconds.
|
||||
* @param endTimeUs The end time of the media, in microseconds.
|
||||
* @param selectionReason The reason for selecting this format.
|
||||
* @param selectionReason One of the {@link C.SelectionReason selection reasons}.
|
||||
*/
|
||||
public FakeMediaChunk(Format trackFormat, long startTimeUs, long endTimeUs, int selectionReason) {
|
||||
public FakeMediaChunk(
|
||||
Format trackFormat,
|
||||
long startTimeUs,
|
||||
long endTimeUs,
|
||||
@C.SelectionReason int selectionReason) {
|
||||
super(
|
||||
DATA_SOURCE,
|
||||
new DataSpec(Uri.EMPTY),
|
||||
|
|
|
|||
Loading…
Reference in a new issue