mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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;
|
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. */
|
/** A selection reason constant for selections whose reasons are unknown or unspecified. */
|
||||||
public static final int SELECTION_REASON_UNKNOWN = 0;
|
public static final int SELECTION_REASON_UNKNOWN = 0;
|
||||||
/** A selection reason constant for an initial track selection. */
|
/** A selection reason constant for an initial track selection. */
|
||||||
|
|
|
||||||
|
|
@ -1096,6 +1096,7 @@ public final class DownloadHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@C.SelectionReason
|
||||||
public int getSelectionReason() {
|
public int getSelectionReason() {
|
||||||
return C.SELECTION_REASON_UNKNOWN;
|
return C.SELECTION_REASON_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source;
|
||||||
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.C.DataType;
|
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.C.TrackType;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
|
||||||
|
|
@ -37,8 +38,8 @@ public final class MediaLoadData {
|
||||||
*/
|
*/
|
||||||
@Nullable public final Format trackFormat;
|
@Nullable public final Format trackFormat;
|
||||||
/**
|
/**
|
||||||
* One of the {@link C} {@code SELECTION_REASON_*} constants if the data belongs to a track.
|
* One of the {@link SelectionReason selection reasons} if the data belongs to a track. {@link
|
||||||
* {@link C#SELECTION_REASON_UNKNOWN} otherwise.
|
* C#SELECTION_REASON_UNKNOWN} otherwise.
|
||||||
*/
|
*/
|
||||||
public final int trackSelectionReason;
|
public final int trackSelectionReason;
|
||||||
/**
|
/**
|
||||||
|
|
@ -82,9 +83,9 @@ public final class MediaLoadData {
|
||||||
*/
|
*/
|
||||||
public MediaLoadData(
|
public MediaLoadData(
|
||||||
@DataType int dataType,
|
@DataType int dataType,
|
||||||
int trackType,
|
@TrackType int trackType,
|
||||||
@Nullable Format trackFormat,
|
@Nullable Format trackFormat,
|
||||||
int trackSelectionReason,
|
@SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long mediaStartTimeMs,
|
long mediaStartTimeMs,
|
||||||
long mediaEndTimeMs) {
|
long mediaEndTimeMs) {
|
||||||
|
|
|
||||||
|
|
@ -229,9 +229,9 @@ public interface MediaSourceEventListener {
|
||||||
public void loadStarted(
|
public void loadStarted(
|
||||||
LoadEventInfo loadEventInfo,
|
LoadEventInfo loadEventInfo,
|
||||||
@DataType int dataType,
|
@DataType int dataType,
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
@Nullable Format trackFormat,
|
@Nullable Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long mediaStartTimeUs,
|
long mediaStartTimeUs,
|
||||||
long mediaEndTimeUs) {
|
long mediaEndTimeUs) {
|
||||||
|
|
@ -274,9 +274,9 @@ public interface MediaSourceEventListener {
|
||||||
public void loadCompleted(
|
public void loadCompleted(
|
||||||
LoadEventInfo loadEventInfo,
|
LoadEventInfo loadEventInfo,
|
||||||
@DataType int dataType,
|
@DataType int dataType,
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
@Nullable Format trackFormat,
|
@Nullable Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long mediaStartTimeUs,
|
long mediaStartTimeUs,
|
||||||
long mediaEndTimeUs) {
|
long mediaEndTimeUs) {
|
||||||
|
|
@ -320,9 +320,9 @@ public interface MediaSourceEventListener {
|
||||||
public void loadCanceled(
|
public void loadCanceled(
|
||||||
LoadEventInfo loadEventInfo,
|
LoadEventInfo loadEventInfo,
|
||||||
@DataType int dataType,
|
@DataType int dataType,
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
@Nullable Format trackFormat,
|
@Nullable Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long mediaStartTimeUs,
|
long mediaStartTimeUs,
|
||||||
long mediaEndTimeUs) {
|
long mediaEndTimeUs) {
|
||||||
|
|
@ -378,9 +378,9 @@ public interface MediaSourceEventListener {
|
||||||
public void loadError(
|
public void loadError(
|
||||||
LoadEventInfo loadEventInfo,
|
LoadEventInfo loadEventInfo,
|
||||||
@DataType int dataType,
|
@DataType int dataType,
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
@Nullable Format trackFormat,
|
@Nullable Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long mediaStartTimeUs,
|
long mediaStartTimeUs,
|
||||||
long mediaEndTimeUs,
|
long mediaEndTimeUs,
|
||||||
|
|
@ -445,9 +445,9 @@ public interface MediaSourceEventListener {
|
||||||
|
|
||||||
/** Dispatches {@link #onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)}. */
|
/** Dispatches {@link #onDownstreamFormatChanged(int, MediaPeriodId, MediaLoadData)}. */
|
||||||
public void downstreamFormatChanged(
|
public void downstreamFormatChanged(
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
@Nullable Format trackFormat,
|
@Nullable Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long mediaTimeUs) {
|
long mediaTimeUs) {
|
||||||
downstreamFormatChanged(
|
downstreamFormatChanged(
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public abstract class BaseMediaChunk extends MediaChunk {
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long startTimeUs,
|
long startTimeUs,
|
||||||
long endTimeUs,
|
long endTimeUs,
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,11 @@ public abstract class Chunk implements Loadable {
|
||||||
/** The format of the track to which this chunk belongs. */
|
/** The format of the track to which this chunk belongs. */
|
||||||
public final Format trackFormat;
|
public final Format trackFormat;
|
||||||
/**
|
/**
|
||||||
* One of the {@link C} {@code SELECTION_REASON_*} constants if the chunk belongs to a track.
|
* One of the {@link C.SelectionReason selection reasons} if the chunk belongs to a track. {@link
|
||||||
* {@link C#SELECTION_REASON_UNKNOWN} if the chunk does not belong to a track, or if the selection
|
* C#SELECTION_REASON_UNKNOWN} if the chunk does not belong to a track, or if the selection reason
|
||||||
* reason is unknown.
|
* 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
|
* 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.
|
* 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,
|
DataSpec dataSpec,
|
||||||
@DataType int type,
|
@DataType int type,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long startTimeUs,
|
long startTimeUs,
|
||||||
long endTimeUs) {
|
long endTimeUs) {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ContainerMediaChunk extends BaseMediaChunk {
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long startTimeUs,
|
long startTimeUs,
|
||||||
long endTimeUs,
|
long endTimeUs,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public abstract class DataChunk extends Chunk {
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
@DataType int type,
|
@DataType int type,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
@Nullable byte[] data) {
|
@Nullable byte[] data) {
|
||||||
super(
|
super(
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public final class InitializationChunk extends Chunk {
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
ChunkExtractor chunkExtractor) {
|
ChunkExtractor chunkExtractor) {
|
||||||
super(
|
super(
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public abstract class MediaChunk extends Chunk {
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long startTimeUs,
|
long startTimeUs,
|
||||||
long endTimeUs,
|
long endTimeUs,
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk {
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long startTimeUs,
|
long startTimeUs,
|
||||||
long endTimeUs,
|
long endTimeUs,
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
||||||
RepresentationHolder representationHolder,
|
RepresentationHolder representationHolder,
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
Object trackSelectionData,
|
Object trackSelectionData,
|
||||||
@Nullable RangedUri initializationUri,
|
@Nullable RangedUri initializationUri,
|
||||||
RangedUri indexUri) {
|
RangedUri indexUri) {
|
||||||
|
|
@ -644,9 +644,9 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
||||||
protected Chunk newMediaChunk(
|
protected Chunk newMediaChunk(
|
||||||
RepresentationHolder representationHolder,
|
RepresentationHolder representationHolder,
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
Object trackSelectionData,
|
Object trackSelectionData,
|
||||||
long firstSegmentNum,
|
long firstSegmentNum,
|
||||||
int maxSegmentCount,
|
int maxSegmentCount,
|
||||||
|
|
|
||||||
|
|
@ -875,7 +875,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
DataSource dataSource,
|
DataSource dataSource,
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Format trackFormat,
|
Format trackFormat,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
byte[] scratchSpace) {
|
byte[] scratchSpace) {
|
||||||
super(
|
super(
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
HlsChunkSource.SegmentBaseHolder segmentBaseHolder,
|
HlsChunkSource.SegmentBaseHolder segmentBaseHolder,
|
||||||
Uri playlistUrl,
|
Uri playlistUrl,
|
||||||
@Nullable List<Format> muxedCaptionFormats,
|
@Nullable List<Format> muxedCaptionFormats,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
boolean isMasterTimestampSource,
|
boolean isMasterTimestampSource,
|
||||||
TimestampAdjusterProvider timestampAdjusterProvider,
|
TimestampAdjusterProvider timestampAdjusterProvider,
|
||||||
|
|
@ -280,7 +280,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
boolean initSegmentEncrypted,
|
boolean initSegmentEncrypted,
|
||||||
Uri playlistUrl,
|
Uri playlistUrl,
|
||||||
@Nullable List<Format> muxedCaptionFormats,
|
@Nullable List<Format> muxedCaptionFormats,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
long startTimeUs,
|
long startTimeUs,
|
||||||
long endTimeUs,
|
long endTimeUs,
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
|
||||||
long chunkStartTimeUs,
|
long chunkStartTimeUs,
|
||||||
long chunkEndTimeUs,
|
long chunkEndTimeUs,
|
||||||
long chunkSeekTimeUs,
|
long chunkSeekTimeUs,
|
||||||
int trackSelectionReason,
|
@C.SelectionReason int trackSelectionReason,
|
||||||
@Nullable Object trackSelectionData,
|
@Nullable Object trackSelectionData,
|
||||||
ChunkExtractor chunkExtractor) {
|
ChunkExtractor chunkExtractor) {
|
||||||
DataSpec dataSpec = new DataSpec(uri);
|
DataSpec dataSpec = new DataSpec(uri);
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,13 @@ public final class FakeMediaChunk extends MediaChunk {
|
||||||
* @param trackFormat The {@link Format}.
|
* @param trackFormat The {@link Format}.
|
||||||
* @param startTimeUs The start time of the media, in microseconds.
|
* @param startTimeUs The start time of the media, in microseconds.
|
||||||
* @param endTimeUs The end 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(
|
super(
|
||||||
DATA_SOURCE,
|
DATA_SOURCE,
|
||||||
new DataSpec(Uri.EMPTY),
|
new DataSpec(Uri.EMPTY),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue