diff --git a/library/common/src/main/java/com/google/android/exoplayer2/C.java b/library/common/src/main/java/com/google/android/exoplayer2/C.java
index 35c61faf81..8541583b39 100644
--- a/library/common/src/main/java/com/google/android/exoplayer2/C.java
+++ b/library/common/src/main/java/com/google/android/exoplayer2/C.java
@@ -649,6 +649,29 @@ public final class C {
*/
public static final int DATA_TYPE_CUSTOM_BASE = 10000;
+ /**
+ * Represents a type of media track. May be one of {@link #TRACK_TYPE_UNKNOWN}, {@link
+ * #TRACK_TYPE_DEFAULT}, {@link #TRACK_TYPE_AUDIO}, {@link #TRACK_TYPE_VIDEO}, {@link
+ * #TRACK_TYPE_TEXT}, {@link #TRACK_TYPE_IMAGE}, {@link #TRACK_TYPE_METADATA}, {@link
+ * #TRACK_TYPE_CAMERA_MOTION} or {@link #TRACK_TYPE_NONE}. May also be an app-defined value (see
+ * {@link #TRACK_TYPE_CUSTOM_BASE}).
+ */
+ @Documented
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(
+ open = true,
+ value = {
+ TRACK_TYPE_UNKNOWN,
+ TRACK_TYPE_DEFAULT,
+ TRACK_TYPE_AUDIO,
+ TRACK_TYPE_VIDEO,
+ TRACK_TYPE_TEXT,
+ TRACK_TYPE_IMAGE,
+ TRACK_TYPE_METADATA,
+ TRACK_TYPE_CAMERA_MOTION,
+ TRACK_TYPE_NONE,
+ })
+ public @interface TrackType {}
/** A type constant for tracks of unknown type. */
public static final int TRACK_TYPE_UNKNOWN = -1;
/** A type constant for tracks of some default type, where the type itself is unknown. */
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Format.java b/library/common/src/main/java/com/google/android/exoplayer2/Format.java
index 18f2c5b0b8..150505ddcd 100644
--- a/library/common/src/main/java/com/google/android/exoplayer2/Format.java
+++ b/library/common/src/main/java/com/google/android/exoplayer2/Format.java
@@ -1008,7 +1008,7 @@ public final class Format implements Bundleable {
return this;
}
- int trackType = MimeTypes.getTrackType(sampleMimeType);
+ @C.TrackType int trackType = MimeTypes.getTrackType(sampleMimeType);
// Use manifest value only.
@Nullable String id = manifestFormat.id;
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java b/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java
index 568a9b97ca..920ce01319 100644
--- a/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java
+++ b/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java
@@ -352,8 +352,8 @@ public final class MediaItem implements Bundleable {
}
/**
- * Sets a list of {@link C}{@code .TRACK_TYPE_*} constants for which to use a DRM session even
- * when the tracks are in the clear.
+ * Sets a list of {@link C.TrackType track types} for which to use a DRM session even when the
+ * tracks are in the clear.
*
*
For the common case of using a DRM session for {@link C#TRACK_TYPE_VIDEO} and {@link
* C#TRACK_TYPE_AUDIO} the {@link #setDrmSessionForClearPeriods(boolean)} can be used.
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java b/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
index 7922e93447..60d7c8e46a 100644
--- a/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
+++ b/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
@@ -486,13 +486,14 @@ public final class MimeTypes {
}
/**
- * Returns the {@link C}{@code .TRACK_TYPE_*} constant corresponding to a specified MIME type, or
- * {@link C#TRACK_TYPE_UNKNOWN} if it could not be determined.
+ * Returns the {@link C.TrackType track type} constant corresponding to a specified MIME type,
+ * which may be {@link C#TRACK_TYPE_UNKNOWN} if it could not be determined.
*
* @param mimeType A MIME type.
- * @return The corresponding {@link C}{@code .TRACK_TYPE_*}, or {@link C#TRACK_TYPE_UNKNOWN} if it
- * could not be determined.
+ * @return The corresponding {@link C.TrackType track type}, which may be {@link
+ * C#TRACK_TYPE_UNKNOWN} if it could not be determined.
*/
+ @C.TrackType
public static int getTrackType(@Nullable String mimeType) {
if (TextUtils.isEmpty(mimeType)) {
return C.TRACK_TYPE_UNKNOWN;
@@ -559,9 +560,10 @@ public final class MimeTypes {
* Equivalent to {@code getTrackType(getMediaMimeType(codec))}.
*
* @param codec An RFC 6381 codec string.
- * @return The corresponding {@link C}{@code .TRACK_TYPE_*}, or {@link C#TRACK_TYPE_UNKNOWN} if it
- * could not be determined.
+ * @return The corresponding {@link C.TrackType track type}, which may be {@link
+ * C#TRACK_TYPE_UNKNOWN} if it could not be determined.
*/
+ @C.TrackType
public static int getTrackTypeOfCodec(String codec) {
return getTrackType(getMediaMimeType(codec));
}
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
index c1fb466b10..40d4b2e0a9 100644
--- a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
+++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
@@ -1498,7 +1498,7 @@ public final class Util {
}
/** Returns the number of codec strings in {@code codecs} whose type matches {@code trackType}. */
- public static int getCodecCountOfType(@Nullable String codecs, int trackType) {
+ public static int getCodecCountOfType(@Nullable String codecs, @C.TrackType int trackType) {
String[] codecArray = splitCodecs(codecs);
int count = 0;
for (String codec : codecArray) {
@@ -2333,27 +2333,29 @@ public final class Util {
}
/**
- * Returns a string representation of a {@code TRACK_TYPE_*} constant defined in {@link C}.
+ * Returns a string representation of a {@link C.TrackType}.
*
- * @param trackType A {@code TRACK_TYPE_*} constant,
+ * @param trackType A {@link C.TrackType} constant,
* @return A string representation of this constant.
*/
- public static String getTrackTypeString(int trackType) {
+ public static String getTrackTypeString(@C.TrackType int trackType) {
switch (trackType) {
- case C.TRACK_TYPE_AUDIO:
- return "audio";
case C.TRACK_TYPE_DEFAULT:
return "default";
+ case C.TRACK_TYPE_AUDIO:
+ return "audio";
+ case C.TRACK_TYPE_VIDEO:
+ return "video";
+ case C.TRACK_TYPE_TEXT:
+ return "text";
+ case C.TRACK_TYPE_IMAGE:
+ return "image";
case C.TRACK_TYPE_METADATA:
return "metadata";
case C.TRACK_TYPE_CAMERA_MOTION:
return "camera motion";
case C.TRACK_TYPE_NONE:
return "none";
- case C.TRACK_TYPE_TEXT:
- return "text";
- case C.TRACK_TYPE_VIDEO:
- return "video";
default:
return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?";
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java b/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java
index 2692925333..b947755f6d 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java
@@ -84,6 +84,9 @@ public class DefaultLoadControl implements LoadControl {
/** A default size in bytes for a camera motion buffer. */
public static final int DEFAULT_CAMERA_MOTION_BUFFER_SIZE = 2 * C.DEFAULT_BUFFER_SEGMENT_SIZE;
+ /** A default size in bytes for an image buffer. */
+ public static final int DEFAULT_IMAGE_BUFFER_SIZE = 2 * C.DEFAULT_BUFFER_SEGMENT_SIZE;
+
/** A default size in bytes for a muxed buffer (e.g. containing video, audio and text). */
public static final int DEFAULT_MUXED_BUFFER_SIZE =
DEFAULT_VIDEO_BUFFER_SIZE + DEFAULT_AUDIO_BUFFER_SIZE + DEFAULT_TEXT_BUFFER_SIZE;
@@ -421,7 +424,7 @@ public class DefaultLoadControl implements LoadControl {
}
}
- private static int getDefaultBufferSize(int trackType) {
+ private static int getDefaultBufferSize(@C.TrackType int trackType) {
switch (trackType) {
case C.TRACK_TYPE_DEFAULT:
return DEFAULT_MUXED_BUFFER_SIZE;
@@ -435,8 +438,11 @@ public class DefaultLoadControl implements LoadControl {
return DEFAULT_METADATA_BUFFER_SIZE;
case C.TRACK_TYPE_CAMERA_MOTION:
return DEFAULT_CAMERA_MOTION_BUFFER_SIZE;
+ case C.TRACK_TYPE_IMAGE:
+ return DEFAULT_IMAGE_BUFFER_SIZE;
case C.TRACK_TYPE_NONE:
return 0;
+ case C.TRACK_TYPE_UNKNOWN:
default:
throw new IllegalArgumentException();
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java b/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java
index 8dc5fdcbd2..b56e67ec2b 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java
@@ -208,8 +208,9 @@ public interface Renderer extends PlayerMessage.Target {
* Returns the track type that the renderer handles.
*
* @see ExoPlayer#getRendererType(int)
- * @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
+ * @return The {@link C.TrackType track type}.
*/
+ @C.TrackType
int getTrackType();
/**
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
index 53fdb9c33b..0118dddeaf 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
@@ -1837,7 +1837,8 @@ public class SimpleExoPlayer extends BasePlayer
}
}
- private void sendRendererMessage(int trackType, int messageType, @Nullable Object payload) {
+ private void sendRendererMessage(
+ @C.TrackType int trackType, int messageType, @Nullable Object payload) {
for (Renderer renderer : renderers) {
if (renderer.getTrackType() == trackType) {
player.createMessage(renderer).setType(messageType).setPayload(payload).send();
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapter.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapter.java
index eef4441c92..45df174c97 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapter.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapter.java
@@ -73,7 +73,7 @@ import java.nio.ByteBuffer;
* {@link MediaCodec}.
*/
public Factory(
- int trackType,
+ @C.TrackType int trackType,
boolean forceQueueingSynchronizationWorkaround,
boolean synchronizeCodecInteractionsWithQueueing) {
this(
@@ -331,15 +331,15 @@ import java.nio.ByteBuffer;
}
}
- private static String createCallbackThreadLabel(int trackType) {
+ private static String createCallbackThreadLabel(@C.TrackType int trackType) {
return createThreadLabel(trackType, /* prefix= */ "ExoPlayer:MediaCodecAsyncAdapter:");
}
- private static String createQueueingThreadLabel(int trackType) {
+ private static String createQueueingThreadLabel(@C.TrackType int trackType) {
return createThreadLabel(trackType, /* prefix= */ "ExoPlayer:MediaCodecQueueingThread:");
}
- private static String createThreadLabel(int trackType, String prefix) {
+ private static String createThreadLabel(@C.TrackType int trackType, String prefix) {
StringBuilder labelBuilder = new StringBuilder(prefix);
if (trackType == C.TRACK_TYPE_AUDIO) {
labelBuilder.append("Audio");
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
index 75ac662ff3..829fa8f4ef 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
@@ -360,8 +360,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
private int pendingOutputStreamOffsetCount;
/**
- * @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
- * constants defined in {@link C}.
+ * @param trackType The {@link C.TrackType track type} that the renderer handles.
* @param mediaCodecSelector A decoder selector.
* @param enableDecoderFallback Whether to enable fallback to lower-priority decoders if decoder
* initialization fails. This may result in using a decoder that is less efficient or slower
@@ -371,7 +370,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
* explicitly using {@link MediaFormat#KEY_OPERATING_RATE}).
*/
public MediaCodecRenderer(
- int trackType,
+ @C.TrackType int trackType,
MediaCodecAdapter.Factory codecAdapterFactory,
MediaCodecSelector mediaCodecSelector,
boolean enableDecoderFallback,
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaLoadData.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaLoadData.java
index 5f5eb38db7..440b6c2d11 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaLoadData.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaLoadData.java
@@ -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.TrackType;
import com.google.android.exoplayer2.Format;
/** Descriptor for data being loaded or selected by a {@link MediaSource}. */
@@ -26,10 +27,10 @@ public final class MediaLoadData {
/** The {@link DataType data type}. */
@DataType public final int dataType;
/**
- * One of the {@link C} {@code TRACK_TYPE_*} constants if the data corresponds to media of a
- * specific type. {@link C#TRACK_TYPE_UNKNOWN} otherwise.
+ * One of the {@link TrackType track type}, which is a media track type if the data corresponds to
+ * media of a specific type, or {@link C#TRACK_TYPE_UNKNOWN} otherwise.
*/
- public final int trackType;
+ @TrackType public final int trackType;
/**
* The format of the track to which the data belongs. Null if the data does not belong to a
* specific track.
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
index b6cd400f22..a835ca68b5 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
@@ -69,7 +69,7 @@ public class ChunkSampleStream
private static final String TAG = "ChunkSampleStream";
- public final int primaryTrackType;
+ @C.TrackType public final int primaryTrackType;
private final int[] embeddedTrackTypes;
private final Format[] embeddedTrackFormats;
@@ -99,8 +99,7 @@ public class ChunkSampleStream
/**
* Constructs an instance.
*
- * @param primaryTrackType The type of the primary track. One of the {@link C} {@code
- * TRACK_TYPE_*} constants.
+ * @param primaryTrackType The {@link C.TrackType type} of the primary track.
* @param embeddedTrackTypes The types of any embedded tracks, or null.
* @param embeddedTrackFormats The formats of the embedded tracks, or null.
* @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
@@ -115,7 +114,7 @@ public class ChunkSampleStream
* events.
*/
public ChunkSampleStream(
- int primaryTrackType,
+ @C.TrackType int primaryTrackType,
@Nullable int[] embeddedTrackTypes,
@Nullable Format[] embeddedTrackFormats,
T chunkSource,
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/OutputConsumerAdapterV30.java b/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/OutputConsumerAdapterV30.java
index 648f1c7275..be2f0db7a8 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/OutputConsumerAdapterV30.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/mediaparser/OutputConsumerAdapterV30.java
@@ -429,6 +429,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
tracksEnded = true;
}
+ @C.TrackType
private static int toTrackTypeConstant(@Nullable String string) {
if (string == null) {
return C.TRACK_TYPE_UNKNOWN;
diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
index 058fca8aa8..476a2c5e22 100644
--- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
+++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
@@ -921,7 +921,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
private static final int CATEGORY_MANIFEST_EVENTS = 2;
public final int[] adaptationSetIndices;
- public final int trackType;
+ @C.TrackType public final int trackType;
@TrackGroupCategory public final int trackGroupCategory;
public final int eventStreamGroupIndex;
@@ -981,7 +981,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
private TrackGroupInfo(
- int trackType,
+ @C.TrackType int trackType,
@TrackGroupCategory int trackGroupCategory,
int[] adaptationSetIndices,
int primaryTrackGroupIndex,
diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java
index 48b228e993..f609ef1a89 100644
--- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java
+++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java
@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.source.dash.manifest;
+import com.google.android.exoplayer2.C;
import java.util.Collections;
import java.util.List;
@@ -30,11 +31,8 @@ public class AdaptationSet {
*/
public final int id;
- /**
- * The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C} {@code
- * TRACK_TYPE_*} constants.
- */
- public final int type;
+ /** The {@link C.TrackType track type} of the adaptation set. */
+ @C.TrackType public final int type;
/** {@link Representation}s in the adaptation set. */
public final List representations;
@@ -51,8 +49,7 @@ public class AdaptationSet {
/**
* @param id A non-negative identifier for the adaptation set that's unique in the scope of its
* containing period, or {@link #ID_UNSET} if not specified.
- * @param type The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C}
- * {@code TRACK_TYPE_*} constants.
+ * @param type The {@link C.TrackType track type} of the adaptation set.
* @param representations {@link Representation}s in the adaptation set.
* @param accessibilityDescriptors Accessibility descriptors in the adaptation set.
* @param essentialProperties Essential properties in the adaptation set.
@@ -60,7 +57,7 @@ public class AdaptationSet {
*/
public AdaptationSet(
int id,
- int type,
+ @C.TrackType int type,
List representations,
List accessibilityDescriptors,
List essentialProperties,
diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
index 970ddf0829..092d779f89 100644
--- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
+++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
@@ -376,7 +376,7 @@ public class DashManifestParser extends DefaultHandler
long timeShiftBufferDepthMs)
throws XmlPullParserException, IOException {
int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET);
- int contentType = parseContentType(xpp);
+ @C.TrackType int contentType = parseContentType(xpp);
String mimeType = xpp.getAttributeValue(null, "mimeType");
String codecs = xpp.getAttributeValue(null, "codecs");
@@ -514,7 +514,7 @@ public class DashManifestParser extends DefaultHandler
protected AdaptationSet buildAdaptationSet(
int id,
- int contentType,
+ @C.TrackType int contentType,
List representations,
List accessibilityDescriptors,
List essentialProperties,
@@ -528,6 +528,7 @@ public class DashManifestParser extends DefaultHandler
supplementalProperties);
}
+ @C.TrackType
protected int parseContentType(XmlPullParser xpp) {
String contentType = xpp.getAttributeValue(null, "contentType");
return TextUtils.isEmpty(contentType)
@@ -1676,7 +1677,8 @@ public class DashManifestParser extends DefaultHandler
* @param secondType The second type.
* @return The consistent type.
*/
- private static int checkContentTypeConsistency(int firstType, int secondType) {
+ private static int checkContentTypeConsistency(
+ @C.TrackType int firstType, @C.TrackType int secondType) {
if (firstType == C.TRACK_TYPE_UNKNOWN) {
return secondType;
} else if (secondType == C.TRACK_TYPE_UNKNOWN) {
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java
index bffda30d0b..272187607b 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java
@@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.extractor;
+import com.google.android.exoplayer2.C;
+
/** Receives stream level data extracted by an {@link Extractor}. */
public interface ExtractorOutput {
@@ -48,11 +50,10 @@ public interface ExtractorOutput {
* id}.
*
* @param id A track identifier.
- * @param type The type of the track. Typically one of the {@link com.google.android.exoplayer2.C}
- * {@code TRACK_TYPE_*} constants.
+ * @param type The {@link C.TrackType track type}.
* @return The {@link TrackOutput} for the given track identifier.
*/
- TrackOutput track(int id, int type);
+ TrackOutput track(int id, @C.TrackType int type);
/**
* Called when all tracks have been identified, meaning no new {@code trackId} values will be
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
index f6ed6f7796..067d53ebfe 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
@@ -866,6 +866,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
/** Returns the track type for a given handler value. */
+ @C.TrackType
private static int getTrackTypeForHdlr(int hdlr) {
if (hdlr == TYPE_soun) {
return C.TRACK_TYPE_AUDIO;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java
index 3771be0952..9a4737f35b 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java
@@ -45,7 +45,7 @@ public final class Track {
/**
* One of {@link C#TRACK_TYPE_AUDIO}, {@link C#TRACK_TYPE_VIDEO} and {@link C#TRACK_TYPE_TEXT}.
*/
- public final int type;
+ @C.TrackType public final int type;
/** The track timescale, defined as the number of time units that pass in one second. */
public final long timescale;
@@ -81,7 +81,7 @@ public final class Track {
public Track(
int id,
- int type,
+ @C.TrackType int type,
long timescale,
long movieTimescale,
long durationUs,
diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
index 785e7f1d36..6e4430923e 100644
--- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
+++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
@@ -628,6 +628,7 @@ public final class HlsMediaPeriod
numberOfAudioCodecs <= 1
&& numberOfVideoCodecs <= 1
&& numberOfAudioCodecs + numberOfVideoCodecs > 0;
+ @C.TrackType
int trackType =
!useVideoVariantsOnly && numberOfAudioCodecs > 0
? C.TRACK_TYPE_AUDIO
@@ -754,7 +755,7 @@ public final class HlsMediaPeriod
}
private HlsSampleStreamWrapper buildSampleStreamWrapper(
- int trackType,
+ @C.TrackType int trackType,
Uri[] playlistUrls,
Format[] playlistFormats,
@Nullable Format muxedAudioFormat,
diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
index afe6cdd34f..cc031dd11e 100644
--- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
+++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
@@ -125,7 +125,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
new HashSet<>(
Arrays.asList(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO, C.TRACK_TYPE_METADATA)));
- private final int trackType;
+ @C.TrackType private final int trackType;
private final Callback callback;
private final HlsChunkSource chunkSource;
private final Allocator allocator;
@@ -135,7 +135,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
private final Loader loader;
private final MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher;
- private final @HlsMediaSource.MetadataType int metadataType;
+ @HlsMediaSource.MetadataType private final int metadataType;
private final HlsChunkSource.HlsChunkHolder nextChunkHolder;
private final ArrayList mediaChunks;
private final List readOnlyMediaChunks;
@@ -185,7 +185,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Nullable private HlsMediaChunk sourceChunk;
/**
- * @param trackType The type of the track. One of the {@link C} {@code TRACK_TYPE_*} constants.
+ * @param trackType The {@link C.TrackType track type}.
* @param callback A callback for the wrapper.
* @param chunkSource A {@link HlsChunkSource} from which chunks to load are obtained.
* @param overridingDrmInitData Overriding {@link DrmInitData}, keyed by protection scheme type
@@ -203,7 +203,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* events.
*/
public HlsSampleStreamWrapper(
- int trackType,
+ @C.TrackType int trackType,
Callback callback,
HlsChunkSource chunkSource,
Map overridingDrmInitData,
diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java
index 97e155b379..af2b45e612 100644
--- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java
+++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java
@@ -60,7 +60,7 @@ public class SsManifest implements FilterableManifest {
private static final String URL_PLACEHOLDER_BITRATE_1 = "{bitrate}";
private static final String URL_PLACEHOLDER_BITRATE_2 = "{Bitrate}";
- public final int type;
+ @C.TrackType public final int type;
public final String subType;
public final long timescale;
public final String name;
@@ -82,7 +82,7 @@ public class SsManifest implements FilterableManifest {
public StreamElement(
String baseUri,
String chunkTemplate,
- int type,
+ @C.TrackType int type,
String subType,
long timescale,
String name,
@@ -115,7 +115,7 @@ public class SsManifest implements FilterableManifest {
private StreamElement(
String baseUri,
String chunkTemplate,
- int type,
+ @C.TrackType int type,
String subType,
long timescale,
String name,
diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsTestUtils.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsTestUtils.java
index 1e770756bc..ddcc393058 100644
--- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsTestUtils.java
+++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsTestUtils.java
@@ -59,7 +59,8 @@ public class SsTestUtils {
}
/** Creates test video stream element with the given name, track type and formats. */
- public static StreamElement createStreamElement(String name, int trackType, Format... formats) {
+ public static StreamElement createStreamElement(
+ String name, @C.TrackType int trackType, Format... formats) {
return new StreamElement(
TEST_BASE_URI,
TEST_CHUNK_TEMPLATE,
diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java
index d865ea0090..26b9b35bc4 100644
--- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java
+++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/DefaultRenderersFactoryAsserts.java
@@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.Handler;
import android.os.Looper;
import androidx.test.core.app.ApplicationProvider;
+import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
@@ -45,7 +46,8 @@ public final class DefaultRenderersFactoryAsserts {
* @param clazz The extension renderer class.
* @param type The type of the renderer.
*/
- public static void assertExtensionRendererCreated(Class extends Renderer> clazz, int type) {
+ public static void assertExtensionRendererCreated(
+ Class extends Renderer> clazz, @C.TrackType int type) {
// In EXTENSION_RENDERER_MODE_OFF the renderer should not be created.
Renderer[] renderers = createRenderers(EXTENSION_RENDERER_MODE_OFF);
for (Renderer renderer : renderers) {
diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeRenderer.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeRenderer.java
index 0506d2f96b..3aab64eab6 100644
--- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeRenderer.java
+++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeRenderer.java
@@ -62,7 +62,7 @@ public class FakeRenderer extends BaseRenderer {
public int positionResetCount;
public int sampleBufferReadCount;
- public FakeRenderer(int trackType) {
+ public FakeRenderer(@C.TrackType int trackType) {
super(trackType);
buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
lastSamplePositionUs = Long.MIN_VALUE;