Add open @IntDef for track types
Also add handling of `C.TRACK_TYPE_IMAGE` in a couple of places where it was missing. #exofixit PiperOrigin-RevId: 395078312
This commit is contained in:
parent
00dda049ea
commit
d05c15dee0
@ -649,6 +649,29 @@ public final class C {
|
|||||||
*/
|
*/
|
||||||
public static final int DATA_TYPE_CUSTOM_BASE = 10000;
|
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. */
|
/** A type constant for tracks of unknown type. */
|
||||||
public static final int TRACK_TYPE_UNKNOWN = -1;
|
public static final int TRACK_TYPE_UNKNOWN = -1;
|
||||||
/** A type constant for tracks of some default type, where the type itself is unknown. */
|
/** A type constant for tracks of some default type, where the type itself is unknown. */
|
||||||
|
@ -1008,7 +1008,7 @@ public final class Format implements Bundleable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int trackType = MimeTypes.getTrackType(sampleMimeType);
|
@C.TrackType int trackType = MimeTypes.getTrackType(sampleMimeType);
|
||||||
|
|
||||||
// Use manifest value only.
|
// Use manifest value only.
|
||||||
@Nullable String id = manifestFormat.id;
|
@Nullable String id = manifestFormat.id;
|
||||||
|
@ -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
|
* Sets a list of {@link C.TrackType track types} for which to use a DRM session even when the
|
||||||
* when the tracks are in the clear.
|
* tracks are in the clear.
|
||||||
*
|
*
|
||||||
* <p>For the common case of using a DRM session for {@link C#TRACK_TYPE_VIDEO} and {@link
|
* <p>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.
|
* C#TRACK_TYPE_AUDIO} the {@link #setDrmSessionForClearPeriods(boolean)} can be used.
|
||||||
|
@ -486,13 +486,14 @@ public final class MimeTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link C}{@code .TRACK_TYPE_*} constant corresponding to a specified MIME type, or
|
* Returns the {@link C.TrackType track type} constant corresponding to a specified MIME type,
|
||||||
* {@link C#TRACK_TYPE_UNKNOWN} if it could not be determined.
|
* which may be {@link C#TRACK_TYPE_UNKNOWN} if it could not be determined.
|
||||||
*
|
*
|
||||||
* @param mimeType A MIME type.
|
* @param mimeType A MIME type.
|
||||||
* @return The corresponding {@link C}{@code .TRACK_TYPE_*}, or {@link C#TRACK_TYPE_UNKNOWN} if it
|
* @return The corresponding {@link C.TrackType track type}, which may be {@link
|
||||||
* could not be determined.
|
* C#TRACK_TYPE_UNKNOWN} if it could not be determined.
|
||||||
*/
|
*/
|
||||||
|
@C.TrackType
|
||||||
public static int getTrackType(@Nullable String mimeType) {
|
public static int getTrackType(@Nullable String mimeType) {
|
||||||
if (TextUtils.isEmpty(mimeType)) {
|
if (TextUtils.isEmpty(mimeType)) {
|
||||||
return C.TRACK_TYPE_UNKNOWN;
|
return C.TRACK_TYPE_UNKNOWN;
|
||||||
@ -559,9 +560,10 @@ public final class MimeTypes {
|
|||||||
* Equivalent to {@code getTrackType(getMediaMimeType(codec))}.
|
* Equivalent to {@code getTrackType(getMediaMimeType(codec))}.
|
||||||
*
|
*
|
||||||
* @param codec An RFC 6381 codec string.
|
* @param codec An RFC 6381 codec string.
|
||||||
* @return The corresponding {@link C}{@code .TRACK_TYPE_*}, or {@link C#TRACK_TYPE_UNKNOWN} if it
|
* @return The corresponding {@link C.TrackType track type}, which may be {@link
|
||||||
* could not be determined.
|
* C#TRACK_TYPE_UNKNOWN} if it could not be determined.
|
||||||
*/
|
*/
|
||||||
|
@C.TrackType
|
||||||
public static int getTrackTypeOfCodec(String codec) {
|
public static int getTrackTypeOfCodec(String codec) {
|
||||||
return getTrackType(getMediaMimeType(codec));
|
return getTrackType(getMediaMimeType(codec));
|
||||||
}
|
}
|
||||||
|
@ -1498,7 +1498,7 @@ public final class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of codec strings in {@code codecs} whose type matches {@code trackType}. */
|
/** 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);
|
String[] codecArray = splitCodecs(codecs);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (String codec : codecArray) {
|
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.
|
* @return A string representation of this constant.
|
||||||
*/
|
*/
|
||||||
public static String getTrackTypeString(int trackType) {
|
public static String getTrackTypeString(@C.TrackType int trackType) {
|
||||||
switch (trackType) {
|
switch (trackType) {
|
||||||
case C.TRACK_TYPE_AUDIO:
|
|
||||||
return "audio";
|
|
||||||
case C.TRACK_TYPE_DEFAULT:
|
case C.TRACK_TYPE_DEFAULT:
|
||||||
return "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:
|
case C.TRACK_TYPE_METADATA:
|
||||||
return "metadata";
|
return "metadata";
|
||||||
case C.TRACK_TYPE_CAMERA_MOTION:
|
case C.TRACK_TYPE_CAMERA_MOTION:
|
||||||
return "camera motion";
|
return "camera motion";
|
||||||
case C.TRACK_TYPE_NONE:
|
case C.TRACK_TYPE_NONE:
|
||||||
return "none";
|
return "none";
|
||||||
case C.TRACK_TYPE_TEXT:
|
|
||||||
return "text";
|
|
||||||
case C.TRACK_TYPE_VIDEO:
|
|
||||||
return "video";
|
|
||||||
default:
|
default:
|
||||||
return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?";
|
return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?";
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,9 @@ public class DefaultLoadControl implements LoadControl {
|
|||||||
/** A default size in bytes for a camera motion buffer. */
|
/** 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;
|
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). */
|
/** A default size in bytes for a muxed buffer (e.g. containing video, audio and text). */
|
||||||
public static final int DEFAULT_MUXED_BUFFER_SIZE =
|
public static final int DEFAULT_MUXED_BUFFER_SIZE =
|
||||||
DEFAULT_VIDEO_BUFFER_SIZE + DEFAULT_AUDIO_BUFFER_SIZE + DEFAULT_TEXT_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) {
|
switch (trackType) {
|
||||||
case C.TRACK_TYPE_DEFAULT:
|
case C.TRACK_TYPE_DEFAULT:
|
||||||
return DEFAULT_MUXED_BUFFER_SIZE;
|
return DEFAULT_MUXED_BUFFER_SIZE;
|
||||||
@ -435,8 +438,11 @@ public class DefaultLoadControl implements LoadControl {
|
|||||||
return DEFAULT_METADATA_BUFFER_SIZE;
|
return DEFAULT_METADATA_BUFFER_SIZE;
|
||||||
case C.TRACK_TYPE_CAMERA_MOTION:
|
case C.TRACK_TYPE_CAMERA_MOTION:
|
||||||
return DEFAULT_CAMERA_MOTION_BUFFER_SIZE;
|
return DEFAULT_CAMERA_MOTION_BUFFER_SIZE;
|
||||||
|
case C.TRACK_TYPE_IMAGE:
|
||||||
|
return DEFAULT_IMAGE_BUFFER_SIZE;
|
||||||
case C.TRACK_TYPE_NONE:
|
case C.TRACK_TYPE_NONE:
|
||||||
return 0;
|
return 0;
|
||||||
|
case C.TRACK_TYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
@ -208,8 +208,9 @@ public interface Renderer extends PlayerMessage.Target {
|
|||||||
* Returns the track type that the renderer handles.
|
* Returns the track type that the renderer handles.
|
||||||
*
|
*
|
||||||
* @see ExoPlayer#getRendererType(int)
|
* @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();
|
int getTrackType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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) {
|
for (Renderer renderer : renderers) {
|
||||||
if (renderer.getTrackType() == trackType) {
|
if (renderer.getTrackType() == trackType) {
|
||||||
player.createMessage(renderer).setType(messageType).setPayload(payload).send();
|
player.createMessage(renderer).setType(messageType).setPayload(payload).send();
|
||||||
|
@ -73,7 +73,7 @@ import java.nio.ByteBuffer;
|
|||||||
* {@link MediaCodec}.
|
* {@link MediaCodec}.
|
||||||
*/
|
*/
|
||||||
public Factory(
|
public Factory(
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
boolean forceQueueingSynchronizationWorkaround,
|
boolean forceQueueingSynchronizationWorkaround,
|
||||||
boolean synchronizeCodecInteractionsWithQueueing) {
|
boolean synchronizeCodecInteractionsWithQueueing) {
|
||||||
this(
|
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:");
|
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:");
|
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);
|
StringBuilder labelBuilder = new StringBuilder(prefix);
|
||||||
if (trackType == C.TRACK_TYPE_AUDIO) {
|
if (trackType == C.TRACK_TYPE_AUDIO) {
|
||||||
labelBuilder.append("Audio");
|
labelBuilder.append("Audio");
|
||||||
|
@ -360,8 +360,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
private int pendingOutputStreamOffsetCount;
|
private int pendingOutputStreamOffsetCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
|
* @param trackType The {@link C.TrackType track type} that the renderer handles.
|
||||||
* constants defined in {@link C}.
|
|
||||||
* @param mediaCodecSelector A decoder selector.
|
* @param mediaCodecSelector A decoder selector.
|
||||||
* @param enableDecoderFallback Whether to enable fallback to lower-priority decoders if decoder
|
* @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
|
* 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}).
|
* explicitly using {@link MediaFormat#KEY_OPERATING_RATE}).
|
||||||
*/
|
*/
|
||||||
public MediaCodecRenderer(
|
public MediaCodecRenderer(
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
MediaCodecAdapter.Factory codecAdapterFactory,
|
MediaCodecAdapter.Factory codecAdapterFactory,
|
||||||
MediaCodecSelector mediaCodecSelector,
|
MediaCodecSelector mediaCodecSelector,
|
||||||
boolean enableDecoderFallback,
|
boolean enableDecoderFallback,
|
||||||
|
@ -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.TrackType;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
|
||||||
/** Descriptor for data being loaded or selected by a {@link MediaSource}. */
|
/** Descriptor for data being loaded or selected by a {@link MediaSource}. */
|
||||||
@ -26,10 +27,10 @@ public final class MediaLoadData {
|
|||||||
/** The {@link DataType data type}. */
|
/** The {@link DataType data type}. */
|
||||||
@DataType public final int dataType;
|
@DataType public final int dataType;
|
||||||
/**
|
/**
|
||||||
* One of the {@link C} {@code TRACK_TYPE_*} constants if the data corresponds to media of a
|
* One of the {@link TrackType track type}, which is a media track type if the data corresponds to
|
||||||
* specific type. {@link C#TRACK_TYPE_UNKNOWN} otherwise.
|
* 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
|
* The format of the track to which the data belongs. Null if the data does not belong to a
|
||||||
* specific track.
|
* specific track.
|
||||||
|
@ -69,7 +69,7 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
|
|
||||||
private static final String TAG = "ChunkSampleStream";
|
private static final String TAG = "ChunkSampleStream";
|
||||||
|
|
||||||
public final int primaryTrackType;
|
@C.TrackType public final int primaryTrackType;
|
||||||
|
|
||||||
private final int[] embeddedTrackTypes;
|
private final int[] embeddedTrackTypes;
|
||||||
private final Format[] embeddedTrackFormats;
|
private final Format[] embeddedTrackFormats;
|
||||||
@ -99,8 +99,7 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
/**
|
/**
|
||||||
* Constructs an instance.
|
* Constructs an instance.
|
||||||
*
|
*
|
||||||
* @param primaryTrackType The type of the primary track. One of the {@link C} {@code
|
* @param primaryTrackType The {@link C.TrackType type} of the primary track.
|
||||||
* TRACK_TYPE_*} constants.
|
|
||||||
* @param embeddedTrackTypes The types of any embedded tracks, or null.
|
* @param embeddedTrackTypes The types of any embedded tracks, or null.
|
||||||
* @param embeddedTrackFormats The formats of the 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.
|
* @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
|
||||||
@ -115,7 +114,7 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
public ChunkSampleStream(
|
public ChunkSampleStream(
|
||||||
int primaryTrackType,
|
@C.TrackType int primaryTrackType,
|
||||||
@Nullable int[] embeddedTrackTypes,
|
@Nullable int[] embeddedTrackTypes,
|
||||||
@Nullable Format[] embeddedTrackFormats,
|
@Nullable Format[] embeddedTrackFormats,
|
||||||
T chunkSource,
|
T chunkSource,
|
||||||
|
@ -429,6 +429,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
|
|||||||
tracksEnded = true;
|
tracksEnded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@C.TrackType
|
||||||
private static int toTrackTypeConstant(@Nullable String string) {
|
private static int toTrackTypeConstant(@Nullable String string) {
|
||||||
if (string == null) {
|
if (string == null) {
|
||||||
return C.TRACK_TYPE_UNKNOWN;
|
return C.TRACK_TYPE_UNKNOWN;
|
||||||
|
@ -921,7 +921,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
private static final int CATEGORY_MANIFEST_EVENTS = 2;
|
private static final int CATEGORY_MANIFEST_EVENTS = 2;
|
||||||
|
|
||||||
public final int[] adaptationSetIndices;
|
public final int[] adaptationSetIndices;
|
||||||
public final int trackType;
|
@C.TrackType public final int trackType;
|
||||||
@TrackGroupCategory public final int trackGroupCategory;
|
@TrackGroupCategory public final int trackGroupCategory;
|
||||||
|
|
||||||
public final int eventStreamGroupIndex;
|
public final int eventStreamGroupIndex;
|
||||||
@ -981,7 +981,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TrackGroupInfo(
|
private TrackGroupInfo(
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
@TrackGroupCategory int trackGroupCategory,
|
@TrackGroupCategory int trackGroupCategory,
|
||||||
int[] adaptationSetIndices,
|
int[] adaptationSetIndices,
|
||||||
int primaryTrackGroupIndex,
|
int primaryTrackGroupIndex,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.source.dash.manifest;
|
package com.google.android.exoplayer2.source.dash.manifest;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -30,11 +31,8 @@ public class AdaptationSet {
|
|||||||
*/
|
*/
|
||||||
public final int id;
|
public final int id;
|
||||||
|
|
||||||
/**
|
/** The {@link C.TrackType track type} of the adaptation set. */
|
||||||
* The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C} {@code
|
@C.TrackType public final int type;
|
||||||
* TRACK_TYPE_*} constants.
|
|
||||||
*/
|
|
||||||
public final int type;
|
|
||||||
|
|
||||||
/** {@link Representation}s in the adaptation set. */
|
/** {@link Representation}s in the adaptation set. */
|
||||||
public final List<Representation> representations;
|
public final List<Representation> 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
|
* @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.
|
* 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}
|
* @param type The {@link C.TrackType track type} of the adaptation set.
|
||||||
* {@code TRACK_TYPE_*} constants.
|
|
||||||
* @param representations {@link Representation}s in the adaptation set.
|
* @param representations {@link Representation}s in the adaptation set.
|
||||||
* @param accessibilityDescriptors Accessibility descriptors in the adaptation set.
|
* @param accessibilityDescriptors Accessibility descriptors in the adaptation set.
|
||||||
* @param essentialProperties Essential properties in the adaptation set.
|
* @param essentialProperties Essential properties in the adaptation set.
|
||||||
@ -60,7 +57,7 @@ public class AdaptationSet {
|
|||||||
*/
|
*/
|
||||||
public AdaptationSet(
|
public AdaptationSet(
|
||||||
int id,
|
int id,
|
||||||
int type,
|
@C.TrackType int type,
|
||||||
List<Representation> representations,
|
List<Representation> representations,
|
||||||
List<Descriptor> accessibilityDescriptors,
|
List<Descriptor> accessibilityDescriptors,
|
||||||
List<Descriptor> essentialProperties,
|
List<Descriptor> essentialProperties,
|
||||||
|
@ -376,7 +376,7 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
long timeShiftBufferDepthMs)
|
long timeShiftBufferDepthMs)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET);
|
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 mimeType = xpp.getAttributeValue(null, "mimeType");
|
||||||
String codecs = xpp.getAttributeValue(null, "codecs");
|
String codecs = xpp.getAttributeValue(null, "codecs");
|
||||||
@ -514,7 +514,7 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
|
|
||||||
protected AdaptationSet buildAdaptationSet(
|
protected AdaptationSet buildAdaptationSet(
|
||||||
int id,
|
int id,
|
||||||
int contentType,
|
@C.TrackType int contentType,
|
||||||
List<Representation> representations,
|
List<Representation> representations,
|
||||||
List<Descriptor> accessibilityDescriptors,
|
List<Descriptor> accessibilityDescriptors,
|
||||||
List<Descriptor> essentialProperties,
|
List<Descriptor> essentialProperties,
|
||||||
@ -528,6 +528,7 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
supplementalProperties);
|
supplementalProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@C.TrackType
|
||||||
protected int parseContentType(XmlPullParser xpp) {
|
protected int parseContentType(XmlPullParser xpp) {
|
||||||
String contentType = xpp.getAttributeValue(null, "contentType");
|
String contentType = xpp.getAttributeValue(null, "contentType");
|
||||||
return TextUtils.isEmpty(contentType)
|
return TextUtils.isEmpty(contentType)
|
||||||
@ -1676,7 +1677,8 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
* @param secondType The second type.
|
* @param secondType The second type.
|
||||||
* @return The consistent 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) {
|
if (firstType == C.TRACK_TYPE_UNKNOWN) {
|
||||||
return secondType;
|
return secondType;
|
||||||
} else if (secondType == C.TRACK_TYPE_UNKNOWN) {
|
} else if (secondType == C.TRACK_TYPE_UNKNOWN) {
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.extractor;
|
package com.google.android.exoplayer2.extractor;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
|
|
||||||
/** Receives stream level data extracted by an {@link Extractor}. */
|
/** Receives stream level data extracted by an {@link Extractor}. */
|
||||||
public interface ExtractorOutput {
|
public interface ExtractorOutput {
|
||||||
|
|
||||||
@ -48,11 +50,10 @@ public interface ExtractorOutput {
|
|||||||
* id}.
|
* id}.
|
||||||
*
|
*
|
||||||
* @param id A track identifier.
|
* @param id A track identifier.
|
||||||
* @param type The type of the track. Typically one of the {@link com.google.android.exoplayer2.C}
|
* @param type The {@link C.TrackType track type}.
|
||||||
* {@code TRACK_TYPE_*} constants.
|
|
||||||
* @return The {@link TrackOutput} for the given track identifier.
|
* @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
|
* Called when all tracks have been identified, meaning no new {@code trackId} values will be
|
||||||
|
@ -866,6 +866,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the track type for a given handler value. */
|
/** Returns the track type for a given handler value. */
|
||||||
|
@C.TrackType
|
||||||
private static int getTrackTypeForHdlr(int hdlr) {
|
private static int getTrackTypeForHdlr(int hdlr) {
|
||||||
if (hdlr == TYPE_soun) {
|
if (hdlr == TYPE_soun) {
|
||||||
return C.TRACK_TYPE_AUDIO;
|
return C.TRACK_TYPE_AUDIO;
|
||||||
|
@ -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}.
|
* 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. */
|
/** The track timescale, defined as the number of time units that pass in one second. */
|
||||||
public final long timescale;
|
public final long timescale;
|
||||||
@ -81,7 +81,7 @@ public final class Track {
|
|||||||
|
|
||||||
public Track(
|
public Track(
|
||||||
int id,
|
int id,
|
||||||
int type,
|
@C.TrackType int type,
|
||||||
long timescale,
|
long timescale,
|
||||||
long movieTimescale,
|
long movieTimescale,
|
||||||
long durationUs,
|
long durationUs,
|
||||||
|
@ -628,6 +628,7 @@ public final class HlsMediaPeriod
|
|||||||
numberOfAudioCodecs <= 1
|
numberOfAudioCodecs <= 1
|
||||||
&& numberOfVideoCodecs <= 1
|
&& numberOfVideoCodecs <= 1
|
||||||
&& numberOfAudioCodecs + numberOfVideoCodecs > 0;
|
&& numberOfAudioCodecs + numberOfVideoCodecs > 0;
|
||||||
|
@C.TrackType
|
||||||
int trackType =
|
int trackType =
|
||||||
!useVideoVariantsOnly && numberOfAudioCodecs > 0
|
!useVideoVariantsOnly && numberOfAudioCodecs > 0
|
||||||
? C.TRACK_TYPE_AUDIO
|
? C.TRACK_TYPE_AUDIO
|
||||||
@ -754,7 +755,7 @@ public final class HlsMediaPeriod
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HlsSampleStreamWrapper buildSampleStreamWrapper(
|
private HlsSampleStreamWrapper buildSampleStreamWrapper(
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
Uri[] playlistUrls,
|
Uri[] playlistUrls,
|
||||||
Format[] playlistFormats,
|
Format[] playlistFormats,
|
||||||
@Nullable Format muxedAudioFormat,
|
@Nullable Format muxedAudioFormat,
|
||||||
|
@ -125,7 +125,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
new HashSet<>(
|
new HashSet<>(
|
||||||
Arrays.asList(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO, C.TRACK_TYPE_METADATA)));
|
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 Callback callback;
|
||||||
private final HlsChunkSource chunkSource;
|
private final HlsChunkSource chunkSource;
|
||||||
private final Allocator allocator;
|
private final Allocator allocator;
|
||||||
@ -135,7 +135,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private final Loader loader;
|
private final Loader loader;
|
||||||
private final MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher;
|
private final MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher;
|
||||||
private final @HlsMediaSource.MetadataType int metadataType;
|
@HlsMediaSource.MetadataType private final int metadataType;
|
||||||
private final HlsChunkSource.HlsChunkHolder nextChunkHolder;
|
private final HlsChunkSource.HlsChunkHolder nextChunkHolder;
|
||||||
private final ArrayList<HlsMediaChunk> mediaChunks;
|
private final ArrayList<HlsMediaChunk> mediaChunks;
|
||||||
private final List<HlsMediaChunk> readOnlyMediaChunks;
|
private final List<HlsMediaChunk> readOnlyMediaChunks;
|
||||||
@ -185,7 +185,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
@Nullable private HlsMediaChunk sourceChunk;
|
@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 callback A callback for the wrapper.
|
||||||
* @param chunkSource A {@link HlsChunkSource} from which chunks to load are obtained.
|
* @param chunkSource A {@link HlsChunkSource} from which chunks to load are obtained.
|
||||||
* @param overridingDrmInitData Overriding {@link DrmInitData}, keyed by protection scheme type
|
* @param overridingDrmInitData Overriding {@link DrmInitData}, keyed by protection scheme type
|
||||||
@ -203,7 +203,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
* events.
|
* events.
|
||||||
*/
|
*/
|
||||||
public HlsSampleStreamWrapper(
|
public HlsSampleStreamWrapper(
|
||||||
int trackType,
|
@C.TrackType int trackType,
|
||||||
Callback callback,
|
Callback callback,
|
||||||
HlsChunkSource chunkSource,
|
HlsChunkSource chunkSource,
|
||||||
Map<String, DrmInitData> overridingDrmInitData,
|
Map<String, DrmInitData> overridingDrmInitData,
|
||||||
|
@ -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_1 = "{bitrate}";
|
||||||
private static final String URL_PLACEHOLDER_BITRATE_2 = "{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 String subType;
|
||||||
public final long timescale;
|
public final long timescale;
|
||||||
public final String name;
|
public final String name;
|
||||||
@ -82,7 +82,7 @@ public class SsManifest implements FilterableManifest<SsManifest> {
|
|||||||
public StreamElement(
|
public StreamElement(
|
||||||
String baseUri,
|
String baseUri,
|
||||||
String chunkTemplate,
|
String chunkTemplate,
|
||||||
int type,
|
@C.TrackType int type,
|
||||||
String subType,
|
String subType,
|
||||||
long timescale,
|
long timescale,
|
||||||
String name,
|
String name,
|
||||||
@ -115,7 +115,7 @@ public class SsManifest implements FilterableManifest<SsManifest> {
|
|||||||
private StreamElement(
|
private StreamElement(
|
||||||
String baseUri,
|
String baseUri,
|
||||||
String chunkTemplate,
|
String chunkTemplate,
|
||||||
int type,
|
@C.TrackType int type,
|
||||||
String subType,
|
String subType,
|
||||||
long timescale,
|
long timescale,
|
||||||
String name,
|
String name,
|
||||||
|
@ -59,7 +59,8 @@ public class SsTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Creates test video stream element with the given name, track type and formats. */
|
/** 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(
|
return new StreamElement(
|
||||||
TEST_BASE_URI,
|
TEST_BASE_URI,
|
||||||
TEST_CHUNK_TEMPLATE,
|
TEST_CHUNK_TEMPLATE,
|
||||||
|
@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
@ -45,7 +46,8 @@ public final class DefaultRenderersFactoryAsserts {
|
|||||||
* @param clazz The extension renderer class.
|
* @param clazz The extension renderer class.
|
||||||
* @param type The type of the renderer.
|
* @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.
|
// In EXTENSION_RENDERER_MODE_OFF the renderer should not be created.
|
||||||
Renderer[] renderers = createRenderers(EXTENSION_RENDERER_MODE_OFF);
|
Renderer[] renderers = createRenderers(EXTENSION_RENDERER_MODE_OFF);
|
||||||
for (Renderer renderer : renderers) {
|
for (Renderer renderer : renderers) {
|
||||||
|
@ -62,7 +62,7 @@ public class FakeRenderer extends BaseRenderer {
|
|||||||
public int positionResetCount;
|
public int positionResetCount;
|
||||||
public int sampleBufferReadCount;
|
public int sampleBufferReadCount;
|
||||||
|
|
||||||
public FakeRenderer(int trackType) {
|
public FakeRenderer(@C.TrackType int trackType) {
|
||||||
super(trackType);
|
super(trackType);
|
||||||
buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
|
buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
|
||||||
lastSamplePositionUs = Long.MIN_VALUE;
|
lastSamplePositionUs = Long.MIN_VALUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user