Add open @IntDef for track selection reasons.

#exofixit

PiperOrigin-RevId: 395217458
This commit is contained in:
samrobinson 2021-09-07 12:18:37 +01:00 committed by Ian Baker
parent 7129d84efd
commit 5183eaaf1e
16 changed files with 58 additions and 34 deletions

View file

@ -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. */

View file

@ -1096,6 +1096,7 @@ public final class DownloadHelper {
}
@Override
@C.SelectionReason
public int getSelectionReason() {
return C.SELECTION_REASON_UNKNOWN;
}

View file

@ -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) {

View file

@ -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(

View file

@ -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,

View file

@ -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) {

View file

@ -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,

View file

@ -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(

View file

@ -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(

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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(

View file

@ -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,

View file

@ -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);

View file

@ -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),