Move FormatSupport in common

#player-to-common

PiperOrigin-RevId: 344558028
This commit is contained in:
krocard 2020-11-27 22:03:49 +00:00 committed by Ian Baker
parent 50bbfb57c0
commit 538445572d
30 changed files with 236 additions and 222 deletions

View File

@ -130,12 +130,13 @@ public class Libgav1VideoRenderer extends DecoderVideoRenderer {
public final int supportsFormat(Format format) {
if (!MimeTypes.VIDEO_AV1.equalsIgnoreCase(format.sampleMimeType)
|| !Gav1Library.isAvailable()) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
if (format.exoMediaCryptoType != null) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_DRM);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_DRM);
}
return RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED);
return RendererCapabilities.create(
C.FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED);
}
@Override

View File

@ -91,19 +91,19 @@ public final class FfmpegAudioRenderer extends DecoderAudioRenderer<FfmpegAudioD
}
@Override
@FormatSupport
@C.FormatSupport
protected int supportsFormatInternal(Format format) {
String mimeType = Assertions.checkNotNull(format.sampleMimeType);
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isAudio(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
return C.FORMAT_UNSUPPORTED_TYPE;
} else if (!FfmpegLibrary.supportsFormat(mimeType)
|| (!sinkSupportsFormat(format, C.ENCODING_PCM_16BIT)
&& !sinkSupportsFormat(format, C.ENCODING_PCM_FLOAT))) {
return FORMAT_UNSUPPORTED_SUBTYPE;
return C.FORMAT_UNSUPPORTED_SUBTYPE;
} else if (format.exoMediaCryptoType != null) {
return FORMAT_UNSUPPORTED_DRM;
return C.FORMAT_UNSUPPORTED_DRM;
} else {
return FORMAT_HANDLED;
return C.FORMAT_HANDLED;
}
}

View File

@ -74,7 +74,7 @@ public final class FfmpegVideoRenderer extends DecoderVideoRenderer {
@RendererCapabilities.Capabilities
public final int supportsFormat(Format format) {
// TODO: Remove this line and uncomment the implementation below.
return FORMAT_UNSUPPORTED_TYPE;
return C.FORMAT_UNSUPPORTED_TYPE;
/*
String mimeType = Assertions.checkNotNull(format.sampleMimeType);
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isVideo(mimeType)) {

View File

@ -79,11 +79,11 @@ public final class LibflacAudioRenderer extends DecoderAudioRenderer<FlacDecoder
}
@Override
@FormatSupport
@C.FormatSupport
protected int supportsFormatInternal(Format format) {
if (!FlacLibrary.isAvailable()
|| !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
return C.FORMAT_UNSUPPORTED_TYPE;
}
// Compute the format that the FLAC decoder will output.
Format outputFormat;
@ -102,11 +102,11 @@ public final class LibflacAudioRenderer extends DecoderAudioRenderer<FlacDecoder
outputFormat = getOutputFormat(streamMetadata);
}
if (!sinkSupportsFormat(outputFormat)) {
return FORMAT_UNSUPPORTED_SUBTYPE;
return C.FORMAT_UNSUPPORTED_SUBTYPE;
} else if (format.exoMediaCryptoType != null) {
return FORMAT_UNSUPPORTED_DRM;
return C.FORMAT_UNSUPPORTED_DRM;
} else {
return FORMAT_HANDLED;
return C.FORMAT_HANDLED;
}
}

View File

@ -79,21 +79,21 @@ public class LibopusAudioRenderer extends DecoderAudioRenderer<OpusDecoder> {
}
@Override
@FormatSupport
@C.FormatSupport
protected int supportsFormatInternal(Format format) {
boolean drmIsSupported =
format.exoMediaCryptoType == null
|| OpusLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType);
if (!OpusLibrary.isAvailable()
|| !MimeTypes.AUDIO_OPUS.equalsIgnoreCase(format.sampleMimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
return C.FORMAT_UNSUPPORTED_TYPE;
} else if (!sinkSupportsFormat(
Util.getPcmFormat(C.ENCODING_PCM_16BIT, format.channelCount, format.sampleRate))) {
return FORMAT_UNSUPPORTED_SUBTYPE;
return C.FORMAT_UNSUPPORTED_SUBTYPE;
} else if (!drmIsSupported) {
return FORMAT_UNSUPPORTED_DRM;
return C.FORMAT_UNSUPPORTED_DRM;
} else {
return FORMAT_HANDLED;
return C.FORMAT_HANDLED;
}
}

View File

@ -127,15 +127,16 @@ public class LibvpxVideoRenderer extends DecoderVideoRenderer {
@Capabilities
public final int supportsFormat(Format format) {
if (!VpxLibrary.isAvailable() || !MimeTypes.VIDEO_VP9.equalsIgnoreCase(format.sampleMimeType)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
boolean drmIsSupported =
format.exoMediaCryptoType == null
|| VpxLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType);
if (!drmIsSupported) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_DRM);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_DRM);
}
return RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED);
return RendererCapabilities.create(
C.FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED);
}
@Override

View File

@ -24,6 +24,7 @@ import android.media.MediaFormat;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@ -1100,8 +1101,63 @@ public final class C {
/* package */ static final int REPEAT_MODE_ALL = 2;
/**
* Converts a time in microseconds to the corresponding time in milliseconds, preserving
* {@link #TIME_UNSET} and {@link #TIME_END_OF_SOURCE} values.
* Level of renderer support for a format. One of {@link #FORMAT_HANDLED}, {@link
* #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_DRM}, {@link
* #FORMAT_UNSUPPORTED_SUBTYPE} or {@link #FORMAT_UNSUPPORTED_TYPE}.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({
FORMAT_HANDLED,
FORMAT_EXCEEDS_CAPABILITIES,
FORMAT_UNSUPPORTED_DRM,
FORMAT_UNSUPPORTED_SUBTYPE,
FORMAT_UNSUPPORTED_TYPE
})
public static @interface FormatSupport {}
// TODO(b/172315872) Renderer was a link. Link to equivalent concept or remove @code.
/** The {@code Renderer} is capable of rendering the format. */
public static final int FORMAT_HANDLED = 0b100;
/**
* The {@code Renderer} is capable of rendering formats with the same MIME type, but the
* properties of the format exceed the renderer's capabilities. There is a chance the renderer
* will be able to play the format in practice because some renderers report their capabilities
* conservatively, but the expected outcome is that playback will fail.
*
* <p>Example: The {@code Renderer} is capable of rendering H264 and the format's MIME type is
* {@code MimeTypes#VIDEO_H264}, but the format's resolution exceeds the maximum limit supported
* by the underlying H264 decoder.
*/
public static final int FORMAT_EXCEEDS_CAPABILITIES = 0b011;
/**
* The {@code Renderer} is capable of rendering formats with the same MIME type, but is not
* capable of rendering the format because the format's drm protection is not supported.
*
* <p>Example: The {@code Renderer} is capable of rendering H264 and the format's MIME type is
* {@link MimeTypes#VIDEO_H264}, but the format indicates PlayReady drm protection whereas the
* renderer only supports Widevine.
*/
public static final int FORMAT_UNSUPPORTED_DRM = 0b010;
/**
* The {@code Renderer} is a general purpose renderer for formats of the same top-level type, but
* is not capable of rendering the format or any other format with the same MIME type because the
* sub-type is not supported.
*
* <p>Example: The {@code Renderer} is a general purpose audio renderer and the format's MIME type
* matches audio/[subtype], but there does not exist a suitable decoder for [subtype].
*/
public static final int FORMAT_UNSUPPORTED_SUBTYPE = 0b001;
/**
* The {@code Renderer} is not capable of rendering the format, either because it does not support
* the format's top-level type, or because it's a specialized renderer for a different MIME type.
*
* <p>Example: The {@code Renderer} is a general purpose video renderer, but the format has an
* audio MIME type.
*/
public static final int FORMAT_UNSUPPORTED_TYPE = 0b000;
/**
* Converts a time in microseconds to the corresponding time in milliseconds, preserving {@link
* #TIME_UNSET} and {@link #TIME_END_OF_SOURCE} values.
*
* @param timeUs The time in microseconds.
* @return The corresponding time in milliseconds.
@ -1134,4 +1190,26 @@ public final class C {
return audioManager == null ? AudioManager.ERROR : audioManager.generateAudioSessionId();
}
/**
* Returns string representation of a {@link FormatSupport} flag.
*
* @param formatSupport A {@link FormatSupport} flag.
* @return A string representation of the flag.
*/
public static String getFormatSupportString(@FormatSupport int formatSupport) {
switch (formatSupport) {
case FORMAT_HANDLED:
return "YES";
case FORMAT_EXCEEDS_CAPABILITIES:
return "NO_EXCEEDS_CAPABILITIES";
case FORMAT_UNSUPPORTED_DRM:
return "NO_UNSUPPORTED_DRM";
case FORMAT_UNSUPPORTED_SUBTYPE:
return "NO_UNSUPPORTED_TYPE";
case FORMAT_UNSUPPORTED_TYPE:
return "NO";
default:
throw new IllegalStateException();
}
}
}

View File

@ -354,7 +354,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
*/
protected final ExoPlaybackException createRendererException(
Exception cause, @Nullable Format format, boolean isRecoverable) {
@FormatSupport int formatSupport = RendererCapabilities.FORMAT_HANDLED;
@C.FormatSupport int formatSupport = C.FORMAT_HANDLED;
if (format != null && !throwRendererExceptionIsExecuting) {
// Prevent recursive re-entry from subclass supportsFormat implementations.
throwRendererExceptionIsExecuting = true;

View File

@ -20,7 +20,7 @@ import android.text.TextUtils;
import androidx.annotation.CheckResult;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.RendererCapabilities.FormatSupport;
import com.google.android.exoplayer2.C.FormatSupport;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException;
@ -121,7 +121,7 @@ public final class ExoPlaybackException extends Exception {
/**
* If {@link #type} is {@link #TYPE_RENDERER}, this is the level of {@link FormatSupport} of the
* renderer for {@link #rendererFormat}. If {@link #rendererFormat} is null, this is {@link
* RendererCapabilities#FORMAT_HANDLED}.
* C#FORMAT_HANDLED}.
*/
@FormatSupport public final int rendererFormatSupport;
@ -214,7 +214,7 @@ public final class ExoPlaybackException extends Exception {
rendererName,
rendererIndex,
rendererFormat,
rendererFormat == null ? RendererCapabilities.FORMAT_HANDLED : rendererFormatSupport,
rendererFormat == null ? C.FORMAT_HANDLED : rendererFormatSupport,
TIMEOUT_OPERATION_UNDEFINED,
isRecoverable);
}
@ -265,7 +265,7 @@ public final class ExoPlaybackException extends Exception {
/* rendererName= */ null,
/* rendererIndex= */ C.INDEX_UNSET,
/* rendererFormat= */ null,
/* rendererFormatSupport= */ RendererCapabilities.FORMAT_HANDLED,
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
timeoutOperation,
/* isRecoverable= */ false);
}
@ -278,7 +278,7 @@ public final class ExoPlaybackException extends Exception {
/* rendererName= */ null,
/* rendererIndex= */ C.INDEX_UNSET,
/* rendererFormat= */ null,
/* rendererFormatSupport= */ RendererCapabilities.FORMAT_HANDLED,
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
TIMEOUT_OPERATION_UNDEFINED,
/* isRecoverable= */ false);
}
@ -291,7 +291,7 @@ public final class ExoPlaybackException extends Exception {
/* rendererName= */ null,
/* rendererIndex= */ C.INDEX_UNSET,
/* rendererFormat= */ null,
/* rendererFormatSupport= */ RendererCapabilities.FORMAT_HANDLED,
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
/* timeoutOperation= */ TIMEOUT_OPERATION_UNDEFINED,
/* isRecoverable= */ false);
}
@ -446,7 +446,7 @@ public final class ExoPlaybackException extends Exception {
+ ", format="
+ rendererFormat
+ ", format_supported="
+ RendererCapabilities.getFormatSupportString(rendererFormatSupport);
+ C.getFormatSupportString(rendererFormatSupport);
break;
case TYPE_REMOTE:
message = "Remote error";

View File

@ -168,7 +168,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities
@Override
@Capabilities
public int supportsFormat(Format format) throws ExoPlaybackException {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Override

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2;
import android.annotation.SuppressLint;
import androidx.annotation.IntDef;
import com.google.android.exoplayer2.util.MimeTypes;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -27,11 +26,8 @@ import java.lang.annotation.RetentionPolicy;
*/
public interface RendererCapabilities {
/**
* Level of renderer support for a format. One of {@link #FORMAT_HANDLED}, {@link
* #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_DRM}, {@link
* #FORMAT_UNSUPPORTED_SUBTYPE} or {@link #FORMAT_UNSUPPORTED_TYPE}.
*/
/** @deprecated Use {@link C.FormatSupport} instead. */
@SuppressWarnings("Deprecation")
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({
@ -41,52 +37,20 @@ public interface RendererCapabilities {
FORMAT_UNSUPPORTED_SUBTYPE,
FORMAT_UNSUPPORTED_TYPE
})
@Deprecated
@interface FormatSupport {}
/** A mask to apply to {@link Capabilities} to obtain the {@link FormatSupport} only. */
/** A mask to apply to {@link Capabilities} to obtain the {@link C.FormatSupport} only. */
int FORMAT_SUPPORT_MASK = 0b111;
/**
* The {@link Renderer} is capable of rendering the format.
*/
int FORMAT_HANDLED = 0b100;
/**
* The {@link Renderer} is capable of rendering formats with the same mime type, but the
* properties of the format exceed the renderer's capabilities. There is a chance the renderer
* will be able to play the format in practice because some renderers report their capabilities
* conservatively, but the expected outcome is that playback will fail.
* <p>
* Example: The {@link Renderer} is capable of rendering H264 and the format's mime type is
* {@link MimeTypes#VIDEO_H264}, but the format's resolution exceeds the maximum limit supported
* by the underlying H264 decoder.
*/
int FORMAT_EXCEEDS_CAPABILITIES = 0b011;
/**
* The {@link Renderer} is capable of rendering formats with the same mime type, but is not
* capable of rendering the format because the format's drm protection is not supported.
* <p>
* Example: The {@link Renderer} is capable of rendering H264 and the format's mime type is
* {@link MimeTypes#VIDEO_H264}, but the format indicates PlayReady drm protection where-as the
* renderer only supports Widevine.
*/
int FORMAT_UNSUPPORTED_DRM = 0b010;
/**
* The {@link Renderer} is a general purpose renderer for formats of the same top-level type,
* but is not capable of rendering the format or any other format with the same mime type because
* the sub-type is not supported.
* <p>
* Example: The {@link Renderer} is a general purpose audio renderer and the format's
* mime type matches audio/[subtype], but there does not exist a suitable decoder for [subtype].
*/
int FORMAT_UNSUPPORTED_SUBTYPE = 0b001;
/**
* The {@link Renderer} is not capable of rendering the format, either because it does not
* support the format's top-level type, or because it's a specialized renderer for a different
* mime type.
* <p>
* Example: The {@link Renderer} is a general purpose video renderer, but the format has an
* audio mime type.
*/
int FORMAT_UNSUPPORTED_TYPE = 0b000;
/** @deprecated Use {@link C#FORMAT_HANDLED} instead. */
@Deprecated int FORMAT_HANDLED = 0b100;
/** @deprecated Use {@link C#FORMAT_EXCEEDS_CAPABILITIES} instead. */
@Deprecated int FORMAT_EXCEEDS_CAPABILITIES = 0b011;
/** @deprecated Use {@link C#FORMAT_UNSUPPORTED_DRM} instead. */
@Deprecated int FORMAT_UNSUPPORTED_DRM = 0b010;
/** @deprecated Use {@link C#FORMAT_UNSUPPORTED_SUBTYPE} instead. */
@Deprecated int FORMAT_UNSUPPORTED_SUBTYPE = 0b001;
/** @deprecated Use {@link C#FORMAT_UNSUPPORTED_TYPE} instead. */
@Deprecated int FORMAT_UNSUPPORTED_TYPE = 0b000;
/**
* Level of renderer support for adaptive format switches. One of {@link #ADAPTIVE_SEAMLESS},
@ -136,7 +100,7 @@ public interface RendererCapabilities {
/**
* Combined renderer capabilities.
*
* <p>This is a bitwise OR of {@link FormatSupport}, {@link AdaptiveSupport} and {@link
* <p>This is a bitwise OR of {@link C.FormatSupport}, {@link AdaptiveSupport} and {@link
* TunnelingSupport}. Use {@link #getFormatSupport(int)}, {@link #getAdaptiveSupport(int)} or
* {@link #getTunnelingSupport(int)} to obtain the individual flags. And use {@link #create(int)}
* or {@link #create(int, int, int)} to create the combined capabilities.
@ -144,18 +108,19 @@ public interface RendererCapabilities {
* <p>Possible values:
*
* <ul>
* <li>{@link FormatSupport}: The level of support for the format itself. One of {@link
* #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_DRM},
* {@link #FORMAT_UNSUPPORTED_SUBTYPE} and {@link #FORMAT_UNSUPPORTED_TYPE}.
* <li>{@link C.FormatSupport}: The level of support for the format itself. One of {@link
* C#FORMAT_HANDLED}, {@link C#FORMAT_EXCEEDS_CAPABILITIES}, {@link
* C#FORMAT_UNSUPPORTED_DRM}, {@link C#FORMAT_UNSUPPORTED_SUBTYPE} and {@link
* C#FORMAT_UNSUPPORTED_TYPE}.
* <li>{@link AdaptiveSupport}: The level of support for adapting from the format to another
* format of the same mime type. One of {@link #ADAPTIVE_SEAMLESS}, {@link
* #ADAPTIVE_NOT_SEAMLESS} and {@link #ADAPTIVE_NOT_SUPPORTED}. Only set if the level of
* support for the format itself is {@link #FORMAT_HANDLED} or {@link
* #FORMAT_EXCEEDS_CAPABILITIES}.
* support for the format itself is {@link C#FORMAT_HANDLED} or {@link
* C#FORMAT_EXCEEDS_CAPABILITIES}.
* <li>{@link TunnelingSupport}: The level of support for tunneling. One of {@link
* #TUNNELING_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}. Only set if the level of
* support for the format itself is {@link #FORMAT_HANDLED} or {@link
* #FORMAT_EXCEEDS_CAPABILITIES}.
* support for the format itself is {@link C#FORMAT_HANDLED} or {@link
* C#FORMAT_EXCEEDS_CAPABILITIES}.
* </ul>
*/
@Documented
@ -165,25 +130,25 @@ public interface RendererCapabilities {
@interface Capabilities {}
/**
* Returns {@link Capabilities} for the given {@link FormatSupport}.
* Returns {@link Capabilities} for the given {@link C.FormatSupport}.
*
* <p>The {@link AdaptiveSupport} is set to {@link #ADAPTIVE_NOT_SUPPORTED} and {{@link
* TunnelingSupport} is set to {@link #TUNNELING_NOT_SUPPORTED}.
*
* @param formatSupport The {@link FormatSupport}.
* @return The combined {@link Capabilities} of the given {@link FormatSupport}, {@link
* @param formatSupport The {@link C.FormatSupport}.
* @return The combined {@link Capabilities} of the given {@link C.FormatSupport}, {@link
* #ADAPTIVE_NOT_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}.
*/
@Capabilities
static int create(@FormatSupport int formatSupport) {
static int create(@C.FormatSupport int formatSupport) {
return create(formatSupport, ADAPTIVE_NOT_SUPPORTED, TUNNELING_NOT_SUPPORTED);
}
/**
* Returns {@link Capabilities} combining the given {@link FormatSupport}, {@link AdaptiveSupport}
* and {@link TunnelingSupport}.
* Returns {@link Capabilities} combining the given {@link C.FormatSupport}, {@link
* AdaptiveSupport} and {@link TunnelingSupport}.
*
* @param formatSupport The {@link FormatSupport}.
* @param formatSupport The {@link C.FormatSupport}.
* @param adaptiveSupport The {@link AdaptiveSupport}.
* @param tunnelingSupport The {@link TunnelingSupport}.
* @return The combined {@link Capabilities}.
@ -192,21 +157,21 @@ public interface RendererCapabilities {
@SuppressLint("WrongConstant")
@Capabilities
static int create(
@FormatSupport int formatSupport,
@C.FormatSupport int formatSupport,
@AdaptiveSupport int adaptiveSupport,
@TunnelingSupport int tunnelingSupport) {
return formatSupport | adaptiveSupport | tunnelingSupport;
}
/**
* Returns the {@link FormatSupport} from the combined {@link Capabilities}.
* Returns the {@link C.FormatSupport} from the combined {@link Capabilities}.
*
* @param supportFlags The combined {@link Capabilities}.
* @return The {@link FormatSupport} only.
* @return The {@link C.FormatSupport} only.
*/
// Suppression needed for IntDef casting.
@SuppressLint("WrongConstant")
@FormatSupport
@C.FormatSupport
static int getFormatSupport(@Capabilities int supportFlags) {
return supportFlags & FORMAT_SUPPORT_MASK;
}
@ -237,29 +202,6 @@ public interface RendererCapabilities {
return supportFlags & TUNNELING_SUPPORT_MASK;
}
/**
* Returns string representation of a {@link FormatSupport} flag.
*
* @param formatSupport A {@link FormatSupport} flag.
* @return A string representation of the flag.
*/
static String getFormatSupportString(@FormatSupport int formatSupport) {
switch (formatSupport) {
case RendererCapabilities.FORMAT_HANDLED:
return "YES";
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
return "NO_EXCEEDS_CAPABILITIES";
case RendererCapabilities.FORMAT_UNSUPPORTED_DRM:
return "NO_UNSUPPORTED_DRM";
case RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE:
return "NO_UNSUPPORTED_TYPE";
case RendererCapabilities.FORMAT_UNSUPPORTED_TYPE:
return "NO";
default:
throw new IllegalStateException();
}
}
/** Returns the name of the {@link Renderer}. */
String getName();

View File

@ -215,10 +215,10 @@ public abstract class DecoderAudioRenderer<
@Capabilities
public final int supportsFormat(Format format) {
if (!MimeTypes.isAudio(format.sampleMimeType)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@FormatSupport int formatSupport = supportsFormatInternal(format);
if (formatSupport <= FORMAT_UNSUPPORTED_DRM) {
@C.FormatSupport int formatSupport = supportsFormatInternal(format);
if (formatSupport <= C.FORMAT_UNSUPPORTED_DRM) {
return RendererCapabilities.create(formatSupport);
}
@TunnelingSupport
@ -227,12 +227,12 @@ public abstract class DecoderAudioRenderer<
}
/**
* Returns the {@link FormatSupport} for the given {@link Format}.
* Returns the {@link C.FormatSupport} for the given {@link Format}.
*
* @param format The format, which has an audio {@link Format#sampleMimeType}.
* @return The {@link FormatSupport} for this {@link Format}.
* @return The {@link C.FormatSupport} for this {@link Format}.
*/
@FormatSupport
@C.FormatSupport
protected abstract int supportsFormatInternal(Format format);
/**

View File

@ -232,7 +232,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
throws DecoderQueryException {
if (!MimeTypes.isAudio(format.sampleMimeType)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@TunnelingSupport
int tunnelingSupport = Util.SDK_INT >= 21 ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
@ -243,25 +243,25 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
if (supportsFormatDrm
&& audioSink.supportsFormat(format)
&& (!formatHasDrm || MediaCodecUtil.getDecryptOnlyDecoderInfo() != null)) {
return RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, tunnelingSupport);
return RendererCapabilities.create(C.FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, tunnelingSupport);
}
// If the input is PCM then it will be passed directly to the sink. Hence the sink must support
// the input format directly.
if (MimeTypes.AUDIO_RAW.equals(format.sampleMimeType) && !audioSink.supportsFormat(format)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
}
// For all other input formats, we expect the decoder to output 16-bit PCM.
if (!audioSink.supportsFormat(
Util.getPcmFormat(C.ENCODING_PCM_16BIT, format.channelCount, format.sampleRate))) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
}
List<MediaCodecInfo> decoderInfos =
getDecoderInfos(mediaCodecSelector, format, /* requiresSecureDecoder= */ false);
if (decoderInfos.isEmpty()) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
}
if (!supportsFormatDrm) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_DRM);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_DRM);
}
// Check capabilities for the first decoder in the list, which takes priority.
MediaCodecInfo decoderInfo = decoderInfos.get(0);
@ -271,8 +271,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
isFormatSupported && decoderInfo.isSeamlessAdaptationSupported(format)
? ADAPTIVE_SEAMLESS
: ADAPTIVE_NOT_SEAMLESS;
@FormatSupport
int formatSupport = isFormatSupported ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
@C.FormatSupport
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
}

View File

@ -103,9 +103,9 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
public int supportsFormat(Format format) {
if (decoderFactory.supportsFormat(format)) {
return RendererCapabilities.create(
format.exoMediaCryptoType == null ? FORMAT_HANDLED : FORMAT_UNSUPPORTED_DRM);
format.exoMediaCryptoType == null ? C.FORMAT_HANDLED : C.FORMAT_UNSUPPORTED_DRM);
} else {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
}

View File

@ -133,11 +133,11 @@ public final class TextRenderer extends BaseRenderer implements Callback {
public int supportsFormat(Format format) {
if (decoderFactory.supportsFormat(format)) {
return RendererCapabilities.create(
format.exoMediaCryptoType == null ? FORMAT_HANDLED : FORMAT_UNSUPPORTED_DRM);
format.exoMediaCryptoType == null ? C.FORMAT_HANDLED : C.FORMAT_UNSUPPORTED_DRM);
} else if (MimeTypes.isText(format.sampleMimeType)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
} else {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
}

View File

@ -25,6 +25,7 @@ import android.util.SparseArray;
import android.util.SparseBooleanArray;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.C.FormatSupport;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.Player;
@ -32,7 +33,6 @@ import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
import com.google.android.exoplayer2.RendererCapabilities.FormatSupport;
import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
@ -2405,21 +2405,21 @@ public class DefaultTrackSelector extends MappingTrackSelector {
/**
* Returns true if the {@link FormatSupport} in the given {@link Capabilities} is {@link
* RendererCapabilities#FORMAT_HANDLED} or if {@code allowExceedsCapabilities} is set and the
* format support is {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}.
* C#FORMAT_HANDLED} or if {@code allowExceedsCapabilities} is set and the format support is
* {@link C#FORMAT_EXCEEDS_CAPABILITIES}.
*
* @param formatSupport {@link Capabilities}.
* @param allowExceedsCapabilities Whether to return true if {@link FormatSupport} is {@link
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}.
* @return True if {@link FormatSupport} is {@link RendererCapabilities#FORMAT_HANDLED}, or if
* {@code allowExceedsCapabilities} is set and the format support is {@link
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}.
* C#FORMAT_EXCEEDS_CAPABILITIES}.
* @return True if {@link FormatSupport} is {@link C#FORMAT_HANDLED}, or if {@code
* allowExceedsCapabilities} is set and the format support is {@link
* C#FORMAT_EXCEEDS_CAPABILITIES}.
*/
protected static boolean isSupported(
@Capabilities int formatSupport, boolean allowExceedsCapabilities) {
@FormatSupport int maskedSupport = RendererCapabilities.getFormatSupport(formatSupport);
return maskedSupport == RendererCapabilities.FORMAT_HANDLED || (allowExceedsCapabilities
&& maskedSupport == RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES);
return maskedSupport == C.FORMAT_HANDLED
|| (allowExceedsCapabilities && maskedSupport == C.FORMAT_EXCEEDS_CAPABILITIES);
}
/**

View File

@ -22,12 +22,12 @@ import android.util.Pair;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.C.FormatSupport;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
import com.google.android.exoplayer2.RendererCapabilities.FormatSupport;
import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
@ -71,23 +71,22 @@ public abstract class MappingTrackSelector extends TrackSelector {
public static final int RENDERER_SUPPORT_NO_TRACKS = 0;
/**
* The renderer has tracks mapped to it, but all are unsupported. In other words, {@link
* #getTrackSupport(int, int, int)} returns {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} or {@link
* RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all tracks mapped to the renderer.
* #getTrackSupport(int, int, int)} returns {@link C#FORMAT_UNSUPPORTED_DRM}, {@link
* C#FORMAT_UNSUPPORTED_SUBTYPE} or {@link C#FORMAT_UNSUPPORTED_TYPE} for all tracks mapped to
* the renderer.
*/
public static final int RENDERER_SUPPORT_UNSUPPORTED_TRACKS = 1;
/**
* The renderer has tracks mapped to it and at least one is of a supported type, but all such
* tracks exceed the renderer's capabilities. In other words, {@link #getTrackSupport(int, int,
* int)} returns {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} for at least one
* track mapped to the renderer, but does not return {@link
* RendererCapabilities#FORMAT_HANDLED} for any tracks mapped to the renderer.
* int)} returns {@link C#FORMAT_EXCEEDS_CAPABILITIES} for at least one track mapped to the
* renderer, but does not return {@link C#FORMAT_HANDLED} for any tracks mapped to the renderer.
*/
public static final int RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS = 2;
/**
* The renderer has tracks mapped to it, and at least one such track is playable. In other
* words, {@link #getTrackSupport(int, int, int)} returns {@link
* RendererCapabilities#FORMAT_HANDLED} for at least one track mapped to the renderer.
* words, {@link #getTrackSupport(int, int, int)} returns {@link C#FORMAT_HANDLED} for at least
* one track mapped to the renderer.
*/
public static final int RENDERER_SUPPORT_PLAYABLE_TRACKS = 3;
@ -181,14 +180,14 @@ public abstract class MappingTrackSelector extends TrackSelector {
for (@Capabilities int trackFormatSupport : trackGroupFormatSupport) {
int trackRendererSupport;
switch (RendererCapabilities.getFormatSupport(trackFormatSupport)) {
case RendererCapabilities.FORMAT_HANDLED:
case C.FORMAT_HANDLED:
return RENDERER_SUPPORT_PLAYABLE_TRACKS;
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
case C.FORMAT_EXCEEDS_CAPABILITIES:
trackRendererSupport = RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS;
break;
case RendererCapabilities.FORMAT_UNSUPPORTED_TYPE:
case RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE:
case RendererCapabilities.FORMAT_UNSUPPORTED_DRM:
case C.FORMAT_UNSUPPORTED_TYPE:
case C.FORMAT_UNSUPPORTED_SUBTYPE:
case C.FORMAT_UNSUPPORTED_DRM:
trackRendererSupport = RENDERER_SUPPORT_UNSUPPORTED_TRACKS;
break;
default:
@ -252,14 +251,12 @@ public abstract class MappingTrackSelector extends TrackSelector {
* Returns the extent to which a renderer supports adaptation between supported tracks in a
* specified {@link TrackGroup}.
*
* <p>Tracks for which {@link #getTrackSupport(int, int, int)} returns {@link
* RendererCapabilities#FORMAT_HANDLED} are always considered. Tracks for which {@link
* #getTrackSupport(int, int, int)} returns {@link
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} are also considered if {@code
* <p>Tracks for which {@link #getTrackSupport(int, int, int)} returns {@link C#FORMAT_HANDLED}
* are always considered. Tracks for which {@link #getTrackSupport(int, int, int)} returns
* {@link C#FORMAT_EXCEEDS_CAPABILITIES} are also considered if {@code
* includeCapabilitiesExceededTracks} is set to {@code true}. Tracks for which {@link
* #getTrackSupport(int, int, int)} returns {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} or {@link
* RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
* #getTrackSupport(int, int, int)} returns {@link C#FORMAT_UNSUPPORTED_DRM}, {@link
* C#FORMAT_UNSUPPORTED_TYPE} or {@link C#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
*
* @param rendererIndex The renderer index.
* @param groupIndex The index of the track group.
@ -276,9 +273,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
int trackIndexCount = 0;
for (int i = 0; i < trackCount; i++) {
@FormatSupport int fixedSupport = getTrackSupport(rendererIndex, groupIndex, i);
if (fixedSupport == RendererCapabilities.FORMAT_HANDLED
if (fixedSupport == C.FORMAT_HANDLED
|| (includeCapabilitiesExceededTracks
&& fixedSupport == RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES)) {
&& fixedSupport == C.FORMAT_EXCEEDS_CAPABILITIES)) {
trackIndices[trackIndexCount++] = i;
}
}
@ -469,10 +466,8 @@ public abstract class MappingTrackSelector extends TrackSelector {
* Finds the renderer to which the provided {@link TrackGroup} should be mapped.
*
* <p>A {@link TrackGroup} is mapped to the renderer that reports the highest of (listed in
* decreasing order of support) {@link RendererCapabilities#FORMAT_HANDLED}, {@link
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}, {@link
* RendererCapabilities#FORMAT_UNSUPPORTED_DRM} and {@link
* RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE}.
* decreasing order of support) {@link C#FORMAT_HANDLED}, {@link C#FORMAT_EXCEEDS_CAPABILITIES},
* {@link C#FORMAT_UNSUPPORTED_DRM} and {@link C#FORMAT_UNSUPPORTED_SUBTYPE}.
*
* <p>In the case that two or more renderers report the same level of support, the assignment
* depends on {@code preferUnassociatedRenderer}.
@ -485,9 +480,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
* available renderers have already mapped track groups.
* </ul>
*
* <p>If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
* tracks in the group, then {@code renderers.length} is returned to indicate that the group was
* not mapped to any renderer.
* <p>If all renderers report {@link C#FORMAT_UNSUPPORTED_TYPE} for all of the tracks in the
* group, then {@code renderers.length} is returned to indicate that the group was not mapped to
* any renderer.
*
* @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
* @param group The track group to map to a renderer.
@ -505,11 +500,11 @@ public abstract class MappingTrackSelector extends TrackSelector {
boolean preferUnassociatedRenderer)
throws ExoPlaybackException {
int bestRendererIndex = rendererCapabilities.length;
@FormatSupport int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
@FormatSupport int bestFormatSupportLevel = C.FORMAT_UNSUPPORTED_TYPE;
boolean bestRendererIsUnassociated = true;
for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
@FormatSupport int formatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
@FormatSupport int formatSupportLevel = C.FORMAT_UNSUPPORTED_TYPE;
for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
@FormatSupport
int trackFormatSupportLevel =

View File

@ -239,7 +239,7 @@ public class EventLogger implements AnalyticsListener {
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
String formatSupport =
RendererCapabilities.getFormatSupportString(
C.getFormatSupportString(
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
logd(
" "
@ -277,9 +277,7 @@ public class EventLogger implements AnalyticsListener {
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(false);
String formatSupport =
RendererCapabilities.getFormatSupportString(
RendererCapabilities.FORMAT_UNSUPPORTED_TYPE);
String formatSupport = C.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
logd(
" "
+ status

View File

@ -260,7 +260,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
throws DecoderQueryException {
String mimeType = format.sampleMimeType;
if (!MimeTypes.isVideo(mimeType)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Nullable DrmInitData drmInitData = format.drmInitData;
// Assume encrypted content requires secure decoders.
@ -281,10 +281,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/* requiresTunnelingDecoder= */ false);
}
if (decoderInfos.isEmpty()) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
}
if (!supportsFormatDrm(format)) {
return RendererCapabilities.create(FORMAT_UNSUPPORTED_DRM);
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_DRM);
}
// Check capabilities for the first decoder in the list, which takes priority.
MediaCodecInfo decoderInfo = decoderInfos.get(0);
@ -310,8 +310,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
}
}
@FormatSupport
int formatSupport = isFormatSupported ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
@C.FormatSupport
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
}

View File

@ -59,8 +59,8 @@ public final class CameraMotionRenderer extends BaseRenderer {
@Capabilities
public int supportsFormat(Format format) {
return MimeTypes.APPLICATION_CAMERA_MOTION.equals(format.sampleMimeType)
? RendererCapabilities.create(FORMAT_HANDLED)
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
? RendererCapabilities.create(C.FORMAT_HANDLED)
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Override

View File

@ -15,8 +15,8 @@
*/
package com.google.android.exoplayer2.audio;
import static com.google.android.exoplayer2.C.FORMAT_HANDLED;
import static com.google.android.exoplayer2.RendererCapabilities.ADAPTIVE_NOT_SEAMLESS;
import static com.google.android.exoplayer2.RendererCapabilities.FORMAT_HANDLED;
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_NOT_SUPPORTED;
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_SUPPORTED;
import static com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM;
@ -68,7 +68,7 @@ public class DecoderAudioRendererTest {
}
@Override
@FormatSupport
@C.FormatSupport
protected int supportsFormatInternal(Format format) {
return FORMAT_HANDLED;
}

View File

@ -240,7 +240,7 @@ public class MediaCodecAudioRendererTest {
"rendererName",
/* rendererIndex= */ 0,
format,
FORMAT_HANDLED));
C.FORMAT_HANDLED));
}
}
};

View File

@ -15,10 +15,10 @@
*/
package com.google.android.exoplayer2.trackselection;
import static com.google.android.exoplayer2.C.FORMAT_EXCEEDS_CAPABILITIES;
import static com.google.android.exoplayer2.C.FORMAT_HANDLED;
import static com.google.android.exoplayer2.C.FORMAT_UNSUPPORTED_SUBTYPE;
import static com.google.android.exoplayer2.RendererCapabilities.ADAPTIVE_NOT_SEAMLESS;
import static com.google.android.exoplayer2.RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES;
import static com.google.android.exoplayer2.RendererCapabilities.FORMAT_HANDLED;
import static com.google.android.exoplayer2.RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE;
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_NOT_SUPPORTED;
import static com.google.android.exoplayer2.RendererConfiguration.DEFAULT;
import static com.google.common.truth.Truth.assertThat;
@ -38,7 +38,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
@ -1538,9 +1537,9 @@ public final class DefaultTrackSelectorTest {
}
/**
* A {@link RendererCapabilities} that advertises support for all formats of a given type using
* a provided support value. For any format that does not have the given track type,
* {@link #supportsFormat(Format)} will return {@link #FORMAT_UNSUPPORTED_TYPE}.
* A {@link RendererCapabilities} that advertises support for all formats of a given type using a
* provided support value. For any format that does not have the given track type, {@link
* #supportsFormat(Format)} will return {@link C#FORMAT_UNSUPPORTED_TYPE}.
*/
private static final class FakeRendererCapabilities implements RendererCapabilities {
@ -1589,7 +1588,7 @@ public final class DefaultTrackSelectorTest {
public int supportsFormat(Format format) {
return MimeTypes.getTrackType(format.sampleMimeType) == trackType
? supportValue
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Override
@ -1615,8 +1614,8 @@ public final class DefaultTrackSelectorTest {
*
* @param trackType the track type to be returned for {@link #getTrackType()}
* @param formatToCapability a map of (format id, support level) that will be used to return
* support level for any given format. For any format that's not in the map,
* {@link #supportsFormat(Format)} will return {@link #FORMAT_UNSUPPORTED_TYPE}.
* support level for any given format. For any format that's not in the map, {@link
* #supportsFormat(Format)} will return {@link C#FORMAT_UNSUPPORTED_TYPE}.
*/
FakeMappedRendererCapabilities(int trackType, Map<String, Integer> formatToCapability) {
this.trackType = trackType;
@ -1638,7 +1637,7 @@ public final class DefaultTrackSelectorTest {
public int supportsFormat(Format format) {
return format.id != null && formatToCapability.containsKey(format.id)
? formatToCapability.get(format.id)
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Override

View File

@ -184,8 +184,9 @@ public final class MappingTrackSelectorTest {
@Capabilities
public int supportsFormat(Format format) throws ExoPlaybackException {
return MimeTypes.getTrackType(format.sampleMimeType) == trackType
? RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
? RendererCapabilities.create(
C.FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Override

View File

@ -89,7 +89,7 @@ public final class DecoderVideoRendererTest {
@Override
@Capabilities
public int supportsFormat(Format format) {
return RendererCapabilities.create(FORMAT_HANDLED);
return RendererCapabilities.create(C.FORMAT_HANDLED);
}
@Override

View File

@ -107,7 +107,7 @@ public class MediaCodecVideoRendererTest {
@Override
@Capabilities
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format) {
return RendererCapabilities.create(FORMAT_HANDLED);
return RendererCapabilities.create(C.FORMAT_HANDLED);
}
@Override

View File

@ -56,7 +56,6 @@ import com.google.android.exoplayer2.PlaybackPreparer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.Events;
import com.google.android.exoplayer2.Player.State;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
@ -1307,7 +1306,7 @@ public class StyledPlayerControlView extends FrameLayout {
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
Format format = trackGroup.getFormat(trackIndex);
if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
== RendererCapabilities.FORMAT_HANDLED) {
== C.FORMAT_HANDLED) {
boolean trackIsSelected =
trackSelection != null && trackSelection.indexOf(format) != C.INDEX_UNSET;
tracks.add(

View File

@ -25,6 +25,7 @@ import android.widget.CheckedTextView;
import android.widget.LinearLayout;
import androidx.annotation.AttrRes;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.source.TrackGroup;
@ -291,7 +292,7 @@ public class TrackSelectionView extends LinearLayout {
trackView.setText(trackNameProvider.getTrackName(trackInfos[trackIndex].format));
trackView.setTag(trackInfos[trackIndex]);
if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
== RendererCapabilities.FORMAT_HANDLED) {
== C.FORMAT_HANDLED) {
trackView.setFocusable(true);
trackView.setOnClickListener(componentListener);
} else {

View File

@ -458,8 +458,7 @@ import java.util.List;
}
private static boolean isFormatHandled(int formatSupport) {
return RendererCapabilities.getFormatSupport(formatSupport)
== RendererCapabilities.FORMAT_HANDLED;
return RendererCapabilities.getFormatSupport(formatSupport) == C.FORMAT_HANDLED;
}
}

View File

@ -108,7 +108,7 @@ public class FakeRenderer extends BaseRenderer {
getName(),
getIndex(),
format,
FORMAT_UNSUPPORTED_TYPE);
C.FORMAT_UNSUPPORTED_TYPE);
}
formatsRead.add(format);
onFormatChanged(format);
@ -149,8 +149,8 @@ public class FakeRenderer extends BaseRenderer {
public int supportsFormat(Format format) throws ExoPlaybackException {
int trackType = MimeTypes.getTrackType(format.sampleMimeType);
return trackType != C.TRACK_TYPE_UNKNOWN && trackType == getTrackType()
? RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
? RendererCapabilities.create(C.FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
@Override