Commit 469c0e75 by andrewlewis Committed by Christos Tsilopoulos

Use `@C.TrackType` more widely

Also add `TYPE_USE` target on the @IntDef (and fix @Targets for other
@IntDefs).

#exofixit

PiperOrigin-RevId: 396333212
parent 040a45f3
Showing with 107 additions and 99 deletions
......@@ -216,7 +216,7 @@ public class IntentUtil {
}
intent.putExtra(DRM_KEY_REQUEST_PROPERTIES_EXTRA + extrasKeySuffix, drmKeyRequestProperties);
List<Integer> drmSessionForClearTypes = drmConfiguration.sessionForClearTypes;
List<@C.TrackType Integer> drmSessionForClearTypes = drmConfiguration.sessionForClearTypes;
if (!drmSessionForClearTypes.isEmpty()) {
// Only video and audio together are supported.
Assertions.checkState(
......
......@@ -1022,7 +1022,7 @@ public final class CastPlayer extends BasePlayer {
trackGroups[i] = new TrackGroup(CastUtils.mediaTrackToFormat(mediaTrack));
long id = mediaTrack.getId();
int trackType = MimeTypes.getTrackType(mediaTrack.getContentType());
@C.TrackType int trackType = MimeTypes.getTrackType(mediaTrack.getContentType());
int rendererIndex = getRendererIndexForTrackType(trackType);
if (isTrackActive(id, activeTrackIds)
&& rendererIndex != C.INDEX_UNSET
......@@ -1289,7 +1289,7 @@ public final class CastPlayer extends BasePlayer {
return false;
}
private static int getRendererIndexForTrackType(int trackType) {
private static int getRendererIndexForTrackType(@C.TrackType int trackType) {
return trackType == C.TRACK_TYPE_VIDEO
? RENDERER_INDEX_VIDEO
: trackType == C.TRACK_TYPE_AUDIO
......
......@@ -29,8 +29,10 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.InlineMe;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.UUID;
/** Defines constants used by the library. */
......@@ -658,6 +660,7 @@ public final class C {
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE_USE})
@IntDef(
open = true,
value = {
......
......@@ -30,7 +30,7 @@ public final class DeviceInfo implements Bundleable {
/** Types of playback. One of {@link #PLAYBACK_TYPE_LOCAL} or {@link #PLAYBACK_TYPE_REMOTE}. */
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
@Target({ElementType.TYPE_USE})
@IntDef({
PLAYBACK_TYPE_LOCAL,
PLAYBACK_TYPE_REMOTE,
......
......@@ -325,7 +325,8 @@ public final class MediaItem implements Bundleable {
* DrmConfiguration.Builder#setSessionForClearTypes(List)} instead.
*/
@Deprecated
public Builder setDrmSessionForClearTypes(@Nullable List<Integer> sessionForClearTypes) {
public Builder setDrmSessionForClearTypes(
@Nullable List<@C.TrackType Integer> sessionForClearTypes) {
drmConfiguration.setSessionForClearTypes(sessionForClearTypes);
return this;
}
......@@ -567,7 +568,7 @@ public final class MediaItem implements Bundleable {
private boolean multiSession;
private boolean playClearContentWithoutKey;
private boolean forceDefaultLicenseUri;
private ImmutableList<Integer> sessionForClearTypes;
private ImmutableList<@C.TrackType Integer> sessionForClearTypes;
@Nullable private byte[] keySetId;
/**
......@@ -679,18 +680,19 @@ public final class MediaItem implements Bundleable {
}
/**
* Sets a list of {@link C}{@code .TRACK_TYPE_*} constants for which to use a DRM session even
* Sets a list of {@link C.TrackType track type} constants for which to use a DRM session even
* when the tracks are in the clear.
*
* <p>For the common case of using a DRM session for {@link C#TRACK_TYPE_VIDEO} and {@link
* C#TRACK_TYPE_AUDIO} the {@link #setSessionForClearPeriods(boolean)} can be used.
* C#TRACK_TYPE_AUDIO}, {@link #setSessionForClearPeriods(boolean)} can be used.
*
* <p>This method overrides what has been set by previously calling {@link
* #setSessionForClearPeriods(boolean)}.
*
* <p>{@code null} or an empty {@link List} can be used for a reset.
*/
public Builder setSessionForClearTypes(@Nullable List<Integer> sessionForClearTypes) {
public Builder setSessionForClearTypes(
@Nullable List<@C.TrackType Integer> sessionForClearTypes) {
this.sessionForClearTypes =
sessionForClearTypes != null
? ImmutableList.copyOf(sessionForClearTypes)
......@@ -744,7 +746,7 @@ public final class MediaItem implements Bundleable {
public final boolean forceDefaultLicenseUri;
/** The types of clear tracks for which to use a DRM session. */
public final ImmutableList<Integer> sessionForClearTypes;
public final ImmutableList<@C.TrackType Integer> sessionForClearTypes;
@Nullable private final byte[] keySetId;
......
......@@ -154,10 +154,11 @@ public final class MimeTypes {
*
* @param mimeType The custom MIME type to register.
* @param codecPrefix The RFC 6381 codec string prefix associated with the MIME type.
* @param trackType The {@link C}{@code .TRACK_TYPE_*} constant associated with the MIME type.
* This value is ignored if the top-level type of {@code mimeType} is audio, video or text.
* @param trackType The {@link C.TrackType track type} associated with the MIME type. This value
* is ignored if the top-level type of {@code mimeType} is audio, video or text.
*/
public static void registerCustomMimeType(String mimeType, String codecPrefix, int trackType) {
public static void registerCustomMimeType(
String mimeType, String codecPrefix, @C.TrackType int trackType) {
CustomMimeType customMimeType = new CustomMimeType(mimeType, codecPrefix, trackType);
int customMimeTypeCount = customMimeTypes.size();
for (int i = 0; i < customMimeTypeCount; i++) {
......@@ -493,8 +494,7 @@ public final class MimeTypes {
* @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) {
public static @C.TrackType int getTrackType(@Nullable String mimeType) {
if (TextUtils.isEmpty(mimeType)) {
return C.TRACK_TYPE_UNKNOWN;
} else if (isAudio(mimeType)) {
......@@ -563,8 +563,7 @@ public final class MimeTypes {
* @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) {
public static @C.TrackType int getTrackTypeOfCodec(String codec) {
return getTrackType(getMediaMimeType(codec));
}
......@@ -628,7 +627,7 @@ public final class MimeTypes {
return null;
}
private static int getTrackTypeForCustomMimeType(String mimeType) {
private static @C.TrackType int getTrackTypeForCustomMimeType(String mimeType) {
int customMimeTypeCount = customMimeTypes.size();
for (int i = 0; i < customMimeTypeCount; i++) {
CustomMimeType customMimeType = customMimeTypes.get(i);
......@@ -721,9 +720,9 @@ public final class MimeTypes {
private static final class CustomMimeType {
public final String mimeType;
public final String codecPrefix;
public final int trackType;
public final @C.TrackType int trackType;
public CustomMimeType(String mimeType, String codecPrefix, int trackType) {
public CustomMimeType(String mimeType, String codecPrefix, @C.TrackType int trackType) {
this.mimeType = mimeType;
this.codecPrefix = codecPrefix;
this.trackType = trackType;
......
......@@ -1539,11 +1539,12 @@ public final class Util {
* trackType}.
*
* @param codecs A codec sequence string, as defined in RFC 6381.
* @param trackType One of {@link C}{@code .TRACK_TYPE_*}.
* @param trackType The {@link C.TrackType track type}.
* @return A copy of {@code codecs} without the codecs whose track type doesn't match {@code
* trackType}. If this ends up empty, or {@code codecs} is null, return null.
* trackType}. If this ends up empty, or {@code codecs} is null, returns null.
*/
public static @Nullable String getCodecsOfType(@Nullable String codecs, int trackType) {
@Nullable
public static String getCodecsOfType(@Nullable String codecs, @C.TrackType int trackType) {
String[] codecArray = splitCodecs(codecs);
if (codecArray.length == 0) {
return null;
......
......@@ -30,7 +30,7 @@ import java.io.IOException;
/** An abstract base class suitable for most {@link Renderer} implementations. */
public abstract class BaseRenderer implements Renderer, RendererCapabilities {
private final int trackType;
private final @C.TrackType int trackType;
private final FormatHolder formatHolder;
@Nullable private RendererConfiguration configuration;
......@@ -48,14 +48,14 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
* @param trackType The track type that the renderer handles. One of the {@link C} {@code
* TRACK_TYPE_*} constants.
*/
public BaseRenderer(int trackType) {
public BaseRenderer(@C.TrackType int trackType) {
this.trackType = trackType;
formatHolder = new FormatHolder();
readingPositionUs = C.TIME_END_OF_SOURCE;
}
@Override
public final int getTrackType() {
public final @C.TrackType int getTrackType() {
return trackType;
}
......
......@@ -897,8 +897,9 @@ public interface ExoPlayer extends Player {
* return {@link C#TRACK_TYPE_AUDIO} and a text renderer will return {@link C#TRACK_TYPE_TEXT}.
*
* @param index The index of the renderer.
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
* @return The {@link C.TrackType track type} that the renderer handles.
*/
@C.TrackType
int getRendererType(int index);
/**
......
......@@ -928,7 +928,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
return renderers.length;
}
public int getRendererType(int index) {
public @C.TrackType int getRendererType(int index) {
return renderers[index].getTrackType();
}
......
......@@ -35,7 +35,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities
private boolean streamIsFinal;
@Override
public final int getTrackType() {
public final @C.TrackType int getTrackType() {
return C.TRACK_TYPE_NONE;
}
......
......@@ -201,8 +201,9 @@ public interface RendererCapabilities {
* text renderer will return {@link C#TRACK_TYPE_TEXT}, and so on.
*
* @see Renderer#getTrackType()
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
* @return The {@link C.TrackType track type}.
*/
@C.TrackType
int getTrackType();
/**
......
......@@ -1427,7 +1427,7 @@ public class SimpleExoPlayer extends BasePlayer
}
@Override
public int getRendererType(int index) {
public @C.TrackType int getRendererType(int index) {
verifyApplicationThread();
return player.getRendererType(index);
}
......
......@@ -172,7 +172,7 @@ public final class PlaybackStats {
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
@Target({ElementType.TYPE_USE})
@IntDef({
PLAYBACK_STATE_NOT_STARTED,
PLAYBACK_STATE_JOINING_BACKGROUND,
......
......@@ -527,6 +527,7 @@ public final class PlaybackStatsListener
boolean audioEnabled = false;
for (TrackSelection trackSelection : player.getCurrentTrackSelections().getAll()) {
if (trackSelection != null && trackSelection.length() > 0) {
@C.TrackType
int trackType = MimeTypes.getTrackType(trackSelection.getFormat(0).sampleMimeType);
if (trackType == C.TRACK_TYPE_VIDEO) {
videoEnabled = true;
......
......@@ -74,7 +74,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
private UUID uuid;
private ExoMediaDrm.Provider exoMediaDrmProvider;
private boolean multiSession;
private int[] useDrmSessionsForClearContentTrackTypes;
private @C.TrackType int[] useDrmSessionsForClearContentTrackTypes;
private boolean playClearSamplesWithoutKeys;
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
private long sessionKeepaliveMs;
......@@ -165,8 +165,8 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
* track types other than {@link C#TRACK_TYPE_AUDIO} and {@link C#TRACK_TYPE_VIDEO}.
*/
public Builder setUseDrmSessionsForClearContent(
int... useDrmSessionsForClearContentTrackTypes) {
for (int trackType : useDrmSessionsForClearContentTrackTypes) {
@C.TrackType int... useDrmSessionsForClearContentTrackTypes) {
for (@C.TrackType int trackType : useDrmSessionsForClearContentTrackTypes) {
checkArgument(trackType == C.TRACK_TYPE_VIDEO || trackType == C.TRACK_TYPE_AUDIO);
}
this.useDrmSessionsForClearContentTrackTypes =
......@@ -282,7 +282,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
private final MediaDrmCallback callback;
private final HashMap<String, String> keyRequestParameters;
private final boolean multiSession;
private final int[] useDrmSessionsForClearContentTrackTypes;
private final @C.TrackType int[] useDrmSessionsForClearContentTrackTypes;
private final boolean playClearSamplesWithoutKeys;
private final ProvisioningManagerImpl provisioningManagerImpl;
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
......@@ -393,7 +393,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
MediaDrmCallback callback,
HashMap<String, String> keyRequestParameters,
boolean multiSession,
int[] useDrmSessionsForClearContentTrackTypes,
@C.TrackType int[] useDrmSessionsForClearContentTrackTypes,
boolean playClearSamplesWithoutKeys,
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
long sessionKeepaliveMs) {
......
......@@ -52,8 +52,8 @@ import java.nio.ByteBuffer;
private final boolean forceQueueingSynchronizationWorkaround;
private final boolean synchronizeCodecInteractionsWithQueueing;
/** Creates a factory for the specified {@code trackType}. */
public Factory(int trackType) {
/** Creates a factory for codecs handling the specified {@link C.TrackType track type}. */
public Factory(@C.TrackType int trackType) {
this(
trackType,
/* forceQueueingSynchronizationWorkaround= */ false,
......
......@@ -28,10 +28,10 @@ public final class MediaLoadData {
/** The {@link DataType data type}. */
@DataType public final int dataType;
/**
* 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.
* One of the {@link TrackType track types}, which is a media track type if the data corresponds
* to media of a specific type, or {@link C#TRACK_TYPE_UNKNOWN} otherwise.
*/
@TrackType public final int trackType;
public final @TrackType int trackType;
/**
* The format of the track to which the data belongs. Null if the data does not belong to a
* specific track.
......
......@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.source.chunk;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.source.SampleQueue;
......@@ -29,7 +30,7 @@ public final class BaseMediaChunkOutput implements TrackOutputProvider {
private static final String TAG = "BaseMediaChunkOutput";
private final int[] trackTypes;
private final @C.TrackType int[] trackTypes;
private final SampleQueue[] sampleQueues;
/**
......@@ -42,7 +43,7 @@ public final class BaseMediaChunkOutput implements TrackOutputProvider {
}
@Override
public TrackOutput track(int id, int type) {
public TrackOutput track(int id, @C.TrackType int type) {
for (int i = 0; i < trackTypes.length; i++) {
if (type == trackTypes[i]) {
return sampleQueues[i];
......
......@@ -83,7 +83,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
private static final PositionHolder POSITION_HOLDER = new PositionHolder();
private final Extractor extractor;
private final int primaryTrackType;
private final @C.TrackType int primaryTrackType;
private final Format primaryTrackManifestFormat;
private final SparseArray<BindingTrackOutput> bindingTrackOutputs;
......@@ -97,13 +97,12 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
* Creates an instance.
*
* @param extractor The extractor to wrap.
* @param primaryTrackType The type of the primary track. Typically one of the {@link
* com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
* @param primaryTrackType The {@link C.TrackType type} of the primary track.
* @param primaryTrackManifestFormat A manifest defined {@link Format} whose data should be merged
* into any sample {@link Format} output from the {@link Extractor} for the primary track.
*/
public BundledChunkExtractor(
Extractor extractor, int primaryTrackType, Format primaryTrackManifestFormat) {
Extractor extractor, @C.TrackType int primaryTrackType, Format primaryTrackManifestFormat) {
this.extractor = extractor;
this.primaryTrackType = primaryTrackType;
this.primaryTrackManifestFormat = primaryTrackManifestFormat;
......
......@@ -38,7 +38,7 @@ public interface ChunkExtractor {
/**
* Returns a new {@link ChunkExtractor} instance.
*
* @param primaryTrackType The type of the primary track. One of {@link C C.TRACK_TYPE_*}.
* @param primaryTrackType The {@link C.TrackType type} of the primary track.
* @param representationFormat The format of the representation to extract from.
* @param enableEventMessageTrack Whether to enable the event message track.
* @param closedCaptionFormats The {@link Format Formats} of the Closed-Caption tracks.
......@@ -46,7 +46,7 @@ public interface ChunkExtractor {
*/
@Nullable
ChunkExtractor createProgressiveMediaExtractor(
int primaryTrackType,
@C.TrackType int primaryTrackType,
Format representationFormat,
boolean enableEventMessageTrack,
List<Format> closedCaptionFormats,
......@@ -63,11 +63,10 @@ public interface ChunkExtractor {
* id}.
*
* @param id A track identifier.
* @param type The type of the track. Typically one of the {@link C} {@code TRACK_TYPE_*}
* constants.
* @param type The {@link C.TrackType type} of the track.
* @return The {@link TrackOutput} for the given track identifier.
*/
TrackOutput track(int id, int type);
TrackOutput track(int id, @C.TrackType int type);
}
/**
......
......@@ -69,7 +69,7 @@ public class ChunkSampleStream<T extends ChunkSource>
private static final String TAG = "ChunkSampleStream";
@C.TrackType public final int primaryTrackType;
public final @C.TrackType int primaryTrackType;
private final int[] embeddedTrackTypes;
private final Format[] embeddedTrackFormats;
......
......@@ -81,15 +81,15 @@ public final class MediaParserChunkExtractor implements ChunkExtractor {
/**
* Creates a new instance.
*
* @param primaryTrackType The type of the primary track, or {@link C#TRACK_TYPE_NONE} if there is
* no primary track. Must be one of the {@link C C.TRACK_TYPE_*} constants.
* @param primaryTrackType The {@link C.TrackType type} of the primary track. {@link
* C#TRACK_TYPE_NONE} if there is no primary track.
* @param manifestFormat The chunks {@link Format} as obtained from the manifest.
* @param closedCaptionFormats A list containing the {@link Format Formats} of the closed-caption
* tracks in the chunks.
*/
@SuppressLint("WrongConstant")
public MediaParserChunkExtractor(
int primaryTrackType, Format manifestFormat, List<Format> closedCaptionFormats) {
@C.TrackType int primaryTrackType, Format manifestFormat, List<Format> closedCaptionFormats) {
outputConsumerAdapter =
new OutputConsumerAdapterV30(
manifestFormat, primaryTrackType, /* expectDummySeekMap= */ true);
......
......@@ -29,7 +29,7 @@ import java.io.IOException;
/** A {@link BaseMediaChunk} for chunks consisting of a single raw sample. */
public final class SingleSampleMediaChunk extends BaseMediaChunk {
private final int trackType;
private final @C.TrackType int trackType;
private final Format sampleFormat;
private long nextLoadPosition;
......@@ -44,8 +44,7 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk {
* @param startTimeUs The start time of the media contained by the chunk, in microseconds.
* @param endTimeUs The end time of the media contained by the chunk, in microseconds.
* @param chunkIndex The index of the chunk, or {@link C#INDEX_UNSET} if it is not known.
* @param trackType The type of the chunk. Typically one of the {@link C} {@code TRACK_TYPE_*}
* constants.
* @param trackType The {@link C.TrackType track type} of the chunk.
* @param sampleFormat The {@link Format} of the sample in the chunk.
*/
public SingleSampleMediaChunk(
......@@ -57,7 +56,7 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk {
long startTimeUs,
long endTimeUs,
long chunkIndex,
int trackType,
@C.TrackType int trackType,
Format sampleFormat) {
super(
dataSource,
......
......@@ -97,7 +97,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
private final ArrayList<@NullableType CryptoData> lastOutputCryptoDatas;
private final DataReaderAdapter scratchDataReaderAdapter;
private final boolean expectDummySeekMap;
private final int primaryTrackType;
private final @C.TrackType int primaryTrackType;
@Nullable private final Format primaryTrackManifestFormat;
private ExtractorOutput extractorOutput;
......@@ -130,14 +130,14 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
*
* @param primaryTrackManifestFormat The manifest-obtained format of the primary track, or null if
* not applicable.
* @param primaryTrackType The type of the primary track, or {@link C#TRACK_TYPE_NONE} if there is
* no primary track. Must be one of the {@link C C.TRACK_TYPE_*} constants.
* @param primaryTrackType The {@link C.TrackType type} of the primary track. {@link
* C#TRACK_TYPE_NONE} if there is no primary track.
* @param expectDummySeekMap Whether the output consumer should expect an initial dummy seek map
* which should be exposed through {@link #getDummySeekMap()}.
*/
public OutputConsumerAdapterV30(
@Nullable Format primaryTrackManifestFormat,
int primaryTrackType,
@C.TrackType int primaryTrackType,
boolean expectDummySeekMap) {
this.expectDummySeekMap = expectDummySeekMap;
this.primaryTrackManifestFormat = primaryTrackManifestFormat;
......@@ -429,8 +429,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
tracksEnded = true;
}
@C.TrackType
private static int toTrackTypeConstant(@Nullable String string) {
private static @C.TrackType int toTrackTypeConstant(@Nullable String string) {
if (string == null) {
return C.TRACK_TYPE_UNKNOWN;
}
......
......@@ -90,7 +90,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
private final int rendererCount;
private final String[] rendererNames;
private final int[] rendererTrackTypes;
private final @C.TrackType int[] rendererTrackTypes;
private final TrackGroupArray[] rendererTrackGroups;
@AdaptiveSupport private final int[] rendererMixedMimeTypeAdaptiveSupports;
@Capabilities private final int[][][] rendererFormatSupports;
......@@ -98,7 +98,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
/**
* @param rendererNames The name of each renderer.
* @param rendererTrackTypes The track type handled by each renderer.
* @param rendererTrackTypes The {@link C.TrackType track type} handled by each renderer.
* @param rendererTrackGroups The {@link TrackGroup}s mapped to each renderer.
* @param rendererMixedMimeTypeAdaptiveSupports The {@link AdaptiveSupport} for mixed MIME type
* adaptation for the renderer.
......@@ -109,7 +109,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
@SuppressWarnings("deprecation")
/* package */ MappedTrackInfo(
String[] rendererNames,
int[] rendererTrackTypes,
@C.TrackType int[] rendererTrackTypes,
TrackGroupArray[] rendererTrackGroups,
@AdaptiveSupport int[] rendererMixedMimeTypeAdaptiveSupports,
@Capabilities int[][][] rendererFormatSupports,
......@@ -146,7 +146,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
* @param rendererIndex The renderer index.
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
*/
public int getRendererType(int rendererIndex) {
public @C.TrackType int getRendererType(int rendererIndex) {
return rendererTrackTypes[rendererIndex];
}
......@@ -199,11 +199,11 @@ public abstract class MappingTrackSelector extends TrackSelector {
* specified type. If no such renderers exist then {@link #RENDERER_SUPPORT_NO_TRACKS} is
* returned.
*
* @param trackType The track type. One of the {@link C} {@code TRACK_TYPE_*} constants.
* @param trackType The {@link C.TrackType track type}.
* @return The {@link RendererSupport}.
*/
@RendererSupport
public int getTypeSupport(int trackType) {
public int getTypeSupport(@C.TrackType int trackType) {
@RendererSupport int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
for (int i = 0; i < rendererCount; i++) {
if (rendererTrackTypes[i] == trackType) {
......
......@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.dash;
import android.os.SystemClock;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.chunk.ChunkSource;
import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler;
......@@ -39,10 +40,11 @@ public interface DashChunkSource extends ChunkSource {
* @param periodIndex The index of the corresponding period in the manifest.
* @param adaptationSetIndices The indices of the corresponding adaptation sets in the period.
* @param trackSelection The track selection.
* @param type The {@link C.TrackType track type}.
* @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
* server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds,
* specified as the server's unix time minus the local elapsed time. Or {@link
* com.google.android.exoplayer2.C#TIME_UNSET} if unknown.
* specified as the server's unix time minus the local elapsed time. Or {@link C#TIME_UNSET}
* if unknown.
* @param enableEventMessageTrack Whether to output an event message track.
* @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
* @param transferListener The transfer listener which should be informed of any data transfers.
......@@ -56,7 +58,7 @@ public interface DashChunkSource extends ChunkSource {
int periodIndex,
int[] adaptationSetIndices,
ExoTrackSelection trackSelection,
int type,
@C.TrackType int type,
long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack,
List<Format> closedCaptionFormats,
......
......@@ -921,7 +921,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
private static final int CATEGORY_MANIFEST_EVENTS = 2;
public final int[] adaptationSetIndices;
@C.TrackType public final int trackType;
public final @C.TrackType int trackType;
@TrackGroupCategory public final int trackGroupCategory;
public final int eventStreamGroupIndex;
......
......@@ -103,7 +103,7 @@ public final class DashUtil {
@Nullable
public static Format loadFormatWithDrmInitData(DataSource dataSource, Period period)
throws IOException {
int primaryTrackType = C.TRACK_TYPE_VIDEO;
@C.TrackType int primaryTrackType = C.TRACK_TYPE_VIDEO;
Representation representation = getFirstRepresentation(period, primaryTrackType);
if (representation == null) {
primaryTrackType = C.TRACK_TYPE_AUDIO;
......@@ -329,7 +329,7 @@ public final class DashUtil {
}
@Nullable
private static Representation getFirstRepresentation(Period period, int type) {
private static Representation getFirstRepresentation(Period period, @C.TrackType int type) {
int index = period.getAdaptationSetIndex(type);
if (index == C.INDEX_UNSET) {
return null;
......
......@@ -105,7 +105,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
int periodIndex,
int[] adaptationSetIndices,
ExoTrackSelection trackSelection,
int trackType,
@C.TrackType int trackType,
long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack,
List<Format> closedCaptionFormats,
......@@ -136,7 +136,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
private final LoaderErrorThrower manifestLoaderErrorThrower;
private final BaseUrlExclusionList baseUrlExclusionList;
private final int[] adaptationSetIndices;
private final int trackType;
private final @C.TrackType int trackType;
private final DataSource dataSource;
private final long elapsedRealtimeOffsetMs;
private final int maxSegmentsPerLoad;
......@@ -159,7 +159,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
* @param periodIndex The index of the period in the manifest.
* @param adaptationSetIndices The indices of the adaptation sets in the period.
* @param trackSelection The track selection.
* @param trackType The type of the tracks in the selection.
* @param trackType The {@link C.TrackType type} of the tracks in the selection.
* @param dataSource A {@link DataSource} suitable for loading the media data.
* @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
* server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
......@@ -180,7 +180,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
int periodIndex,
int[] adaptationSetIndices,
ExoTrackSelection trackSelection,
int trackType,
@C.TrackType int trackType,
DataSource dataSource,
long elapsedRealtimeOffsetMs,
int maxSegmentsPerLoad,
......
......@@ -32,7 +32,7 @@ public class AdaptationSet {
public final int id;
/** The {@link C.TrackType track type} of the adaptation set. */
@C.TrackType public final int type;
public final @C.TrackType int type;
/** {@link Representation}s in the adaptation set. */
public final List<Representation> representations;
......
......@@ -528,8 +528,7 @@ public class DashManifestParser extends DefaultHandler
supplementalProperties);
}
@C.TrackType
protected int parseContentType(XmlPullParser xpp) {
protected @C.TrackType int parseContentType(XmlPullParser xpp) {
String contentType = xpp.getAttributeValue(null, "contentType");
return TextUtils.isEmpty(contentType)
? C.TRACK_TYPE_UNKNOWN
......
......@@ -280,6 +280,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
boolean isQuickTime)
throws ParserException {
Atom.ContainerAtom mdia = checkNotNull(trak.getContainerAtomOfType(Atom.TYPE_mdia));
@C.TrackType
int trackType =
getTrackTypeForHdlr(parseHdlr(checkNotNull(mdia.getLeafAtomOfType(Atom.TYPE_hdlr)).data));
if (trackType == C.TRACK_TYPE_UNKNOWN) {
......@@ -866,8 +867,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) {
private static @C.TrackType int getTrackTypeForHdlr(int hdlr) {
if (hdlr == TYPE_soun) {
return C.TRACK_TYPE_AUDIO;
} else if (hdlr == TYPE_vide) {
......
......@@ -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}.
*/
@C.TrackType public final int type;
public final @C.TrackType int type;
/** The track timescale, defined as the number of time units that pass in one second. */
public final long timescale;
......
......@@ -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)));
@C.TrackType private final int trackType;
private final @C.TrackType int trackType;
private final Callback callback;
private final HlsChunkSource chunkSource;
private final Allocator allocator;
......
......@@ -60,7 +60,7 @@ public class SsManifest implements FilterableManifest<SsManifest> {
private static final String URL_PLACEHOLDER_BITRATE_1 = "{bitrate}";
private static final String URL_PLACEHOLDER_BITRATE_2 = "{Bitrate}";
@C.TrackType public final int type;
public final @C.TrackType int type;
public final String subType;
public final long timescale;
public final String name;
......
......@@ -51,7 +51,7 @@ import java.nio.ByteBuffer;
private int trackCount;
private int trackFormatCount;
private boolean isReady;
private int previousTrackType;
private @C.TrackType int previousTrackType;
private long minTrackTimeUs;
public MuxerWrapper(Muxer muxer) {
......@@ -99,7 +99,7 @@ import java.nio.ByteBuffer;
boolean isAudio = MimeTypes.isAudio(sampleMimeType);
boolean isVideo = MimeTypes.isVideo(sampleMimeType);
checkState(isAudio || isVideo, "Unsupported track format: " + sampleMimeType);
int trackType = MimeTypes.getTrackType(sampleMimeType);
@C.TrackType int trackType = MimeTypes.getTrackType(sampleMimeType);
checkState(
trackTypeToIndex.get(trackType, /* valueIfKeyNotFound= */ C.INDEX_UNSET) == C.INDEX_UNSET,
"There is already a track of type " + trackType);
......@@ -116,8 +116,7 @@ import java.nio.ByteBuffer;
/**
* Attempts to write a sample to the muxer.
*
* @param trackType The track type of the sample, defined by the {@code TRACK_TYPE_*} constants in
* {@link C}.
* @param trackType The {@link C.TrackType track type} of the sample.
* @param data The sample to write, or {@code null} if the sample is empty.
* @param isKeyFrame Whether the sample is a key frame.
* @param presentationTimeUs The presentation time of the sample in microseconds.
......@@ -129,7 +128,10 @@ import java.nio.ByteBuffer;
* track of the given track type.
*/
public boolean writeSample(
int trackType, @Nullable ByteBuffer data, boolean isKeyFrame, long presentationTimeUs) {
@C.TrackType int trackType,
@Nullable ByteBuffer data,
boolean isKeyFrame,
long presentationTimeUs) {
int trackIndex = trackTypeToIndex.get(trackType, /* valueIfKeyNotFound= */ C.INDEX_UNSET);
checkState(
trackIndex != C.INDEX_UNSET,
......@@ -151,9 +153,9 @@ import java.nio.ByteBuffer;
* Notifies the muxer that all the samples have been {@link #writeSample(int, ByteBuffer, boolean,
* long) written} for a given track.
*
* @param trackType The track type, defined by the {@code TRACK_TYPE_*} constants in {@link C}.
* @param trackType The {@link C.TrackType track type}.
*/
public void endTrack(int trackType) {
public void endTrack(@C.TrackType int trackType) {
trackTypeToIndex.delete(trackType);
trackTypeToTimeUs.delete(trackType);
}
......
......@@ -37,7 +37,7 @@ import com.google.android.exoplayer2.util.MediaClock;
* Updates the time for a given track type. The clock time is computed based on the different
* track times.
*/
public void updateTimeForTrackType(int trackType, long timeUs) {
public void updateTimeForTrackType(@C.TrackType int trackType, long timeUs) {
long previousTimeUs = trackTypeToTimeUs.get(trackType, /* valueIfKeyNotFound= */ C.TIME_UNSET);
if (previousTimeUs != C.TIME_UNSET && timeUs <= previousTimeUs) {
// Make sure that the track times are increasing and therefore that the clock time is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment