mirror of
https://github.com/androidx/media.git
synced 2025-05-12 10:09:55 +08:00
Move FormatSupport in common
#player-to-common PiperOrigin-RevId: 344558028
This commit is contained in:
parent
50bbfb57c0
commit
538445572d
@ -130,12 +130,13 @@ public class Libgav1VideoRenderer extends DecoderVideoRenderer {
|
|||||||
public final int supportsFormat(Format format) {
|
public final int supportsFormat(Format format) {
|
||||||
if (!MimeTypes.VIDEO_AV1.equalsIgnoreCase(format.sampleMimeType)
|
if (!MimeTypes.VIDEO_AV1.equalsIgnoreCase(format.sampleMimeType)
|
||||||
|| !Gav1Library.isAvailable()) {
|
|| !Gav1Library.isAvailable()) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
if (format.exoMediaCryptoType != null) {
|
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
|
@Override
|
||||||
|
@ -91,19 +91,19 @@ public final class FfmpegAudioRenderer extends DecoderAudioRenderer<FfmpegAudioD
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
protected int supportsFormatInternal(Format format) {
|
protected int supportsFormatInternal(Format format) {
|
||||||
String mimeType = Assertions.checkNotNull(format.sampleMimeType);
|
String mimeType = Assertions.checkNotNull(format.sampleMimeType);
|
||||||
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isAudio(mimeType)) {
|
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isAudio(mimeType)) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return C.FORMAT_UNSUPPORTED_TYPE;
|
||||||
} else if (!FfmpegLibrary.supportsFormat(mimeType)
|
} else if (!FfmpegLibrary.supportsFormat(mimeType)
|
||||||
|| (!sinkSupportsFormat(format, C.ENCODING_PCM_16BIT)
|
|| (!sinkSupportsFormat(format, C.ENCODING_PCM_16BIT)
|
||||||
&& !sinkSupportsFormat(format, C.ENCODING_PCM_FLOAT))) {
|
&& !sinkSupportsFormat(format, C.ENCODING_PCM_FLOAT))) {
|
||||||
return FORMAT_UNSUPPORTED_SUBTYPE;
|
return C.FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
} else if (format.exoMediaCryptoType != null) {
|
} else if (format.exoMediaCryptoType != null) {
|
||||||
return FORMAT_UNSUPPORTED_DRM;
|
return C.FORMAT_UNSUPPORTED_DRM;
|
||||||
} else {
|
} else {
|
||||||
return FORMAT_HANDLED;
|
return C.FORMAT_HANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public final class FfmpegVideoRenderer extends DecoderVideoRenderer {
|
|||||||
@RendererCapabilities.Capabilities
|
@RendererCapabilities.Capabilities
|
||||||
public final int supportsFormat(Format format) {
|
public final int supportsFormat(Format format) {
|
||||||
// TODO: Remove this line and uncomment the implementation below.
|
// TODO: Remove this line and uncomment the implementation below.
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return C.FORMAT_UNSUPPORTED_TYPE;
|
||||||
/*
|
/*
|
||||||
String mimeType = Assertions.checkNotNull(format.sampleMimeType);
|
String mimeType = Assertions.checkNotNull(format.sampleMimeType);
|
||||||
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isVideo(mimeType)) {
|
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isVideo(mimeType)) {
|
||||||
|
@ -79,11 +79,11 @@ public final class LibflacAudioRenderer extends DecoderAudioRenderer<FlacDecoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
protected int supportsFormatInternal(Format format) {
|
protected int supportsFormatInternal(Format format) {
|
||||||
if (!FlacLibrary.isAvailable()
|
if (!FlacLibrary.isAvailable()
|
||||||
|| !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
|
|| !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return C.FORMAT_UNSUPPORTED_TYPE;
|
||||||
}
|
}
|
||||||
// Compute the format that the FLAC decoder will output.
|
// Compute the format that the FLAC decoder will output.
|
||||||
Format outputFormat;
|
Format outputFormat;
|
||||||
@ -102,11 +102,11 @@ public final class LibflacAudioRenderer extends DecoderAudioRenderer<FlacDecoder
|
|||||||
outputFormat = getOutputFormat(streamMetadata);
|
outputFormat = getOutputFormat(streamMetadata);
|
||||||
}
|
}
|
||||||
if (!sinkSupportsFormat(outputFormat)) {
|
if (!sinkSupportsFormat(outputFormat)) {
|
||||||
return FORMAT_UNSUPPORTED_SUBTYPE;
|
return C.FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
} else if (format.exoMediaCryptoType != null) {
|
} else if (format.exoMediaCryptoType != null) {
|
||||||
return FORMAT_UNSUPPORTED_DRM;
|
return C.FORMAT_UNSUPPORTED_DRM;
|
||||||
} else {
|
} else {
|
||||||
return FORMAT_HANDLED;
|
return C.FORMAT_HANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,21 +79,21 @@ public class LibopusAudioRenderer extends DecoderAudioRenderer<OpusDecoder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
protected int supportsFormatInternal(Format format) {
|
protected int supportsFormatInternal(Format format) {
|
||||||
boolean drmIsSupported =
|
boolean drmIsSupported =
|
||||||
format.exoMediaCryptoType == null
|
format.exoMediaCryptoType == null
|
||||||
|| OpusLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType);
|
|| OpusLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType);
|
||||||
if (!OpusLibrary.isAvailable()
|
if (!OpusLibrary.isAvailable()
|
||||||
|| !MimeTypes.AUDIO_OPUS.equalsIgnoreCase(format.sampleMimeType)) {
|
|| !MimeTypes.AUDIO_OPUS.equalsIgnoreCase(format.sampleMimeType)) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return C.FORMAT_UNSUPPORTED_TYPE;
|
||||||
} else if (!sinkSupportsFormat(
|
} else if (!sinkSupportsFormat(
|
||||||
Util.getPcmFormat(C.ENCODING_PCM_16BIT, format.channelCount, format.sampleRate))) {
|
Util.getPcmFormat(C.ENCODING_PCM_16BIT, format.channelCount, format.sampleRate))) {
|
||||||
return FORMAT_UNSUPPORTED_SUBTYPE;
|
return C.FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
} else if (!drmIsSupported) {
|
} else if (!drmIsSupported) {
|
||||||
return FORMAT_UNSUPPORTED_DRM;
|
return C.FORMAT_UNSUPPORTED_DRM;
|
||||||
} else {
|
} else {
|
||||||
return FORMAT_HANDLED;
|
return C.FORMAT_HANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,15 +127,16 @@ public class LibvpxVideoRenderer extends DecoderVideoRenderer {
|
|||||||
@Capabilities
|
@Capabilities
|
||||||
public final int supportsFormat(Format format) {
|
public final int supportsFormat(Format format) {
|
||||||
if (!VpxLibrary.isAvailable() || !MimeTypes.VIDEO_VP9.equalsIgnoreCase(format.sampleMimeType)) {
|
if (!VpxLibrary.isAvailable() || !MimeTypes.VIDEO_VP9.equalsIgnoreCase(format.sampleMimeType)) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
boolean drmIsSupported =
|
boolean drmIsSupported =
|
||||||
format.exoMediaCryptoType == null
|
format.exoMediaCryptoType == null
|
||||||
|| VpxLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType);
|
|| VpxLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType);
|
||||||
if (!drmIsSupported) {
|
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
|
@Override
|
||||||
|
@ -24,6 +24,7 @@ import android.media.MediaFormat;
|
|||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -1100,8 +1101,63 @@ public final class C {
|
|||||||
/* package */ static final int REPEAT_MODE_ALL = 2;
|
/* package */ static final int REPEAT_MODE_ALL = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a time in microseconds to the corresponding time in milliseconds, preserving
|
* Level of renderer support for a format. One of {@link #FORMAT_HANDLED}, {@link
|
||||||
* {@link #TIME_UNSET} and {@link #TIME_END_OF_SOURCE} values.
|
* #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.
|
* @param timeUs The time in microseconds.
|
||||||
* @return The corresponding time in milliseconds.
|
* @return The corresponding time in milliseconds.
|
||||||
@ -1134,4 +1190,26 @@ public final class C {
|
|||||||
return audioManager == null ? AudioManager.ERROR : audioManager.generateAudioSessionId();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
|
|||||||
*/
|
*/
|
||||||
protected final ExoPlaybackException createRendererException(
|
protected final ExoPlaybackException createRendererException(
|
||||||
Exception cause, @Nullable Format format, boolean isRecoverable) {
|
Exception cause, @Nullable Format format, boolean isRecoverable) {
|
||||||
@FormatSupport int formatSupport = RendererCapabilities.FORMAT_HANDLED;
|
@C.FormatSupport int formatSupport = C.FORMAT_HANDLED;
|
||||||
if (format != null && !throwRendererExceptionIsExecuting) {
|
if (format != null && !throwRendererExceptionIsExecuting) {
|
||||||
// Prevent recursive re-entry from subclass supportsFormat implementations.
|
// Prevent recursive re-entry from subclass supportsFormat implementations.
|
||||||
throwRendererExceptionIsExecuting = true;
|
throwRendererExceptionIsExecuting = true;
|
||||||
|
@ -20,7 +20,7 @@ import android.text.TextUtils;
|
|||||||
import androidx.annotation.CheckResult;
|
import androidx.annotation.CheckResult;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
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.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import java.io.IOException;
|
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
|
* 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
|
* renderer for {@link #rendererFormat}. If {@link #rendererFormat} is null, this is {@link
|
||||||
* RendererCapabilities#FORMAT_HANDLED}.
|
* C#FORMAT_HANDLED}.
|
||||||
*/
|
*/
|
||||||
@FormatSupport public final int rendererFormatSupport;
|
@FormatSupport public final int rendererFormatSupport;
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ public final class ExoPlaybackException extends Exception {
|
|||||||
rendererName,
|
rendererName,
|
||||||
rendererIndex,
|
rendererIndex,
|
||||||
rendererFormat,
|
rendererFormat,
|
||||||
rendererFormat == null ? RendererCapabilities.FORMAT_HANDLED : rendererFormatSupport,
|
rendererFormat == null ? C.FORMAT_HANDLED : rendererFormatSupport,
|
||||||
TIMEOUT_OPERATION_UNDEFINED,
|
TIMEOUT_OPERATION_UNDEFINED,
|
||||||
isRecoverable);
|
isRecoverable);
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ public final class ExoPlaybackException extends Exception {
|
|||||||
/* rendererName= */ null,
|
/* rendererName= */ null,
|
||||||
/* rendererIndex= */ C.INDEX_UNSET,
|
/* rendererIndex= */ C.INDEX_UNSET,
|
||||||
/* rendererFormat= */ null,
|
/* rendererFormat= */ null,
|
||||||
/* rendererFormatSupport= */ RendererCapabilities.FORMAT_HANDLED,
|
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
|
||||||
timeoutOperation,
|
timeoutOperation,
|
||||||
/* isRecoverable= */ false);
|
/* isRecoverable= */ false);
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ public final class ExoPlaybackException extends Exception {
|
|||||||
/* rendererName= */ null,
|
/* rendererName= */ null,
|
||||||
/* rendererIndex= */ C.INDEX_UNSET,
|
/* rendererIndex= */ C.INDEX_UNSET,
|
||||||
/* rendererFormat= */ null,
|
/* rendererFormat= */ null,
|
||||||
/* rendererFormatSupport= */ RendererCapabilities.FORMAT_HANDLED,
|
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
|
||||||
TIMEOUT_OPERATION_UNDEFINED,
|
TIMEOUT_OPERATION_UNDEFINED,
|
||||||
/* isRecoverable= */ false);
|
/* isRecoverable= */ false);
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ public final class ExoPlaybackException extends Exception {
|
|||||||
/* rendererName= */ null,
|
/* rendererName= */ null,
|
||||||
/* rendererIndex= */ C.INDEX_UNSET,
|
/* rendererIndex= */ C.INDEX_UNSET,
|
||||||
/* rendererFormat= */ null,
|
/* rendererFormat= */ null,
|
||||||
/* rendererFormatSupport= */ RendererCapabilities.FORMAT_HANDLED,
|
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
|
||||||
/* timeoutOperation= */ TIMEOUT_OPERATION_UNDEFINED,
|
/* timeoutOperation= */ TIMEOUT_OPERATION_UNDEFINED,
|
||||||
/* isRecoverable= */ false);
|
/* isRecoverable= */ false);
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ public final class ExoPlaybackException extends Exception {
|
|||||||
+ ", format="
|
+ ", format="
|
||||||
+ rendererFormat
|
+ rendererFormat
|
||||||
+ ", format_supported="
|
+ ", format_supported="
|
||||||
+ RendererCapabilities.getFormatSupportString(rendererFormatSupport);
|
+ C.getFormatSupportString(rendererFormatSupport);
|
||||||
break;
|
break;
|
||||||
case TYPE_REMOTE:
|
case TYPE_REMOTE:
|
||||||
message = "Remote error";
|
message = "Remote error";
|
||||||
|
@ -168,7 +168,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities
|
|||||||
@Override
|
@Override
|
||||||
@Capabilities
|
@Capabilities
|
||||||
public int supportsFormat(Format format) throws ExoPlaybackException {
|
public int supportsFormat(Format format) throws ExoPlaybackException {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,6 @@ package com.google.android.exoplayer2;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -27,11 +26,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
*/
|
*/
|
||||||
public interface RendererCapabilities {
|
public interface RendererCapabilities {
|
||||||
|
|
||||||
/**
|
/** @deprecated Use {@link C.FormatSupport} instead. */
|
||||||
* Level of renderer support for a format. One of {@link #FORMAT_HANDLED}, {@link
|
@SuppressWarnings("Deprecation")
|
||||||
* #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_DRM}, {@link
|
|
||||||
* #FORMAT_UNSUPPORTED_SUBTYPE} or {@link #FORMAT_UNSUPPORTED_TYPE}.
|
|
||||||
*/
|
|
||||||
@Documented
|
@Documented
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef({
|
@IntDef({
|
||||||
@ -41,52 +37,20 @@ public interface RendererCapabilities {
|
|||||||
FORMAT_UNSUPPORTED_SUBTYPE,
|
FORMAT_UNSUPPORTED_SUBTYPE,
|
||||||
FORMAT_UNSUPPORTED_TYPE
|
FORMAT_UNSUPPORTED_TYPE
|
||||||
})
|
})
|
||||||
|
@Deprecated
|
||||||
@interface FormatSupport {}
|
@interface FormatSupport {}
|
||||||
|
/** A mask to apply to {@link Capabilities} to obtain the {@link C.FormatSupport} only. */
|
||||||
/** A mask to apply to {@link Capabilities} to obtain the {@link FormatSupport} only. */
|
|
||||||
int FORMAT_SUPPORT_MASK = 0b111;
|
int FORMAT_SUPPORT_MASK = 0b111;
|
||||||
/**
|
/** @deprecated Use {@link C#FORMAT_HANDLED} instead. */
|
||||||
* The {@link Renderer} is capable of rendering the format.
|
@Deprecated int FORMAT_HANDLED = 0b100;
|
||||||
*/
|
/** @deprecated Use {@link C#FORMAT_EXCEEDS_CAPABILITIES} instead. */
|
||||||
int FORMAT_HANDLED = 0b100;
|
@Deprecated int FORMAT_EXCEEDS_CAPABILITIES = 0b011;
|
||||||
/**
|
/** @deprecated Use {@link C#FORMAT_UNSUPPORTED_DRM} instead. */
|
||||||
* The {@link Renderer} is capable of rendering formats with the same mime type, but the
|
@Deprecated int FORMAT_UNSUPPORTED_DRM = 0b010;
|
||||||
* properties of the format exceed the renderer's capabilities. There is a chance the renderer
|
/** @deprecated Use {@link C#FORMAT_UNSUPPORTED_SUBTYPE} instead. */
|
||||||
* will be able to play the format in practice because some renderers report their capabilities
|
@Deprecated int FORMAT_UNSUPPORTED_SUBTYPE = 0b001;
|
||||||
* conservatively, but the expected outcome is that playback will fail.
|
/** @deprecated Use {@link C#FORMAT_UNSUPPORTED_TYPE} instead. */
|
||||||
* <p>
|
@Deprecated int FORMAT_UNSUPPORTED_TYPE = 0b000;
|
||||||
* 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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Level of renderer support for adaptive format switches. One of {@link #ADAPTIVE_SEAMLESS},
|
* Level of renderer support for adaptive format switches. One of {@link #ADAPTIVE_SEAMLESS},
|
||||||
@ -136,7 +100,7 @@ public interface RendererCapabilities {
|
|||||||
/**
|
/**
|
||||||
* Combined renderer capabilities.
|
* 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
|
* TunnelingSupport}. Use {@link #getFormatSupport(int)}, {@link #getAdaptiveSupport(int)} or
|
||||||
* {@link #getTunnelingSupport(int)} to obtain the individual flags. And use {@link #create(int)}
|
* {@link #getTunnelingSupport(int)} to obtain the individual flags. And use {@link #create(int)}
|
||||||
* or {@link #create(int, int, int)} to create the combined capabilities.
|
* or {@link #create(int, int, int)} to create the combined capabilities.
|
||||||
@ -144,18 +108,19 @@ public interface RendererCapabilities {
|
|||||||
* <p>Possible values:
|
* <p>Possible values:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link FormatSupport}: The level of support for the format itself. One of {@link
|
* <li>{@link C.FormatSupport}: The level of support for the format itself. One of {@link
|
||||||
* #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_DRM},
|
* C#FORMAT_HANDLED}, {@link C#FORMAT_EXCEEDS_CAPABILITIES}, {@link
|
||||||
* {@link #FORMAT_UNSUPPORTED_SUBTYPE} and {@link #FORMAT_UNSUPPORTED_TYPE}.
|
* 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
|
* <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
|
* 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
|
* #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
|
* support for the format itself is {@link C#FORMAT_HANDLED} or {@link
|
||||||
* #FORMAT_EXCEEDS_CAPABILITIES}.
|
* C#FORMAT_EXCEEDS_CAPABILITIES}.
|
||||||
* <li>{@link TunnelingSupport}: The level of support for tunneling. One of {@link
|
* <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
|
* #TUNNELING_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}. Only set if the level of
|
||||||
* support for the format itself is {@link #FORMAT_HANDLED} or {@link
|
* support for the format itself is {@link C#FORMAT_HANDLED} or {@link
|
||||||
* #FORMAT_EXCEEDS_CAPABILITIES}.
|
* C#FORMAT_EXCEEDS_CAPABILITIES}.
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
@ -165,25 +130,25 @@ public interface RendererCapabilities {
|
|||||||
@interface Capabilities {}
|
@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
|
* <p>The {@link AdaptiveSupport} is set to {@link #ADAPTIVE_NOT_SUPPORTED} and {{@link
|
||||||
* TunnelingSupport} is set to {@link #TUNNELING_NOT_SUPPORTED}.
|
* TunnelingSupport} is set to {@link #TUNNELING_NOT_SUPPORTED}.
|
||||||
*
|
*
|
||||||
* @param formatSupport The {@link FormatSupport}.
|
* @param formatSupport The {@link C.FormatSupport}.
|
||||||
* @return The combined {@link Capabilities} of the given {@link FormatSupport}, {@link
|
* @return The combined {@link Capabilities} of the given {@link C.FormatSupport}, {@link
|
||||||
* #ADAPTIVE_NOT_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}.
|
* #ADAPTIVE_NOT_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}.
|
||||||
*/
|
*/
|
||||||
@Capabilities
|
@Capabilities
|
||||||
static int create(@FormatSupport int formatSupport) {
|
static int create(@C.FormatSupport int formatSupport) {
|
||||||
return create(formatSupport, ADAPTIVE_NOT_SUPPORTED, TUNNELING_NOT_SUPPORTED);
|
return create(formatSupport, ADAPTIVE_NOT_SUPPORTED, TUNNELING_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Capabilities} combining the given {@link FormatSupport}, {@link AdaptiveSupport}
|
* Returns {@link Capabilities} combining the given {@link C.FormatSupport}, {@link
|
||||||
* and {@link TunnelingSupport}.
|
* AdaptiveSupport} and {@link TunnelingSupport}.
|
||||||
*
|
*
|
||||||
* @param formatSupport The {@link FormatSupport}.
|
* @param formatSupport The {@link C.FormatSupport}.
|
||||||
* @param adaptiveSupport The {@link AdaptiveSupport}.
|
* @param adaptiveSupport The {@link AdaptiveSupport}.
|
||||||
* @param tunnelingSupport The {@link TunnelingSupport}.
|
* @param tunnelingSupport The {@link TunnelingSupport}.
|
||||||
* @return The combined {@link Capabilities}.
|
* @return The combined {@link Capabilities}.
|
||||||
@ -192,21 +157,21 @@ public interface RendererCapabilities {
|
|||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
@Capabilities
|
@Capabilities
|
||||||
static int create(
|
static int create(
|
||||||
@FormatSupport int formatSupport,
|
@C.FormatSupport int formatSupport,
|
||||||
@AdaptiveSupport int adaptiveSupport,
|
@AdaptiveSupport int adaptiveSupport,
|
||||||
@TunnelingSupport int tunnelingSupport) {
|
@TunnelingSupport int tunnelingSupport) {
|
||||||
return formatSupport | adaptiveSupport | 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}.
|
* @param supportFlags The combined {@link Capabilities}.
|
||||||
* @return The {@link FormatSupport} only.
|
* @return The {@link C.FormatSupport} only.
|
||||||
*/
|
*/
|
||||||
// Suppression needed for IntDef casting.
|
// Suppression needed for IntDef casting.
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
static int getFormatSupport(@Capabilities int supportFlags) {
|
static int getFormatSupport(@Capabilities int supportFlags) {
|
||||||
return supportFlags & FORMAT_SUPPORT_MASK;
|
return supportFlags & FORMAT_SUPPORT_MASK;
|
||||||
}
|
}
|
||||||
@ -237,29 +202,6 @@ public interface RendererCapabilities {
|
|||||||
return supportFlags & TUNNELING_SUPPORT_MASK;
|
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}. */
|
/** Returns the name of the {@link Renderer}. */
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
@ -215,10 +215,10 @@ public abstract class DecoderAudioRenderer<
|
|||||||
@Capabilities
|
@Capabilities
|
||||||
public final int supportsFormat(Format format) {
|
public final int supportsFormat(Format format) {
|
||||||
if (!MimeTypes.isAudio(format.sampleMimeType)) {
|
if (!MimeTypes.isAudio(format.sampleMimeType)) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
@FormatSupport int formatSupport = supportsFormatInternal(format);
|
@C.FormatSupport int formatSupport = supportsFormatInternal(format);
|
||||||
if (formatSupport <= FORMAT_UNSUPPORTED_DRM) {
|
if (formatSupport <= C.FORMAT_UNSUPPORTED_DRM) {
|
||||||
return RendererCapabilities.create(formatSupport);
|
return RendererCapabilities.create(formatSupport);
|
||||||
}
|
}
|
||||||
@TunnelingSupport
|
@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}.
|
* @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);
|
protected abstract int supportsFormatInternal(Format format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,7 +232,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
|
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
|
||||||
throws DecoderQueryException {
|
throws DecoderQueryException {
|
||||||
if (!MimeTypes.isAudio(format.sampleMimeType)) {
|
if (!MimeTypes.isAudio(format.sampleMimeType)) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
@TunnelingSupport
|
@TunnelingSupport
|
||||||
int tunnelingSupport = Util.SDK_INT >= 21 ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
|
int tunnelingSupport = Util.SDK_INT >= 21 ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
|
||||||
@ -243,25 +243,25 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
if (supportsFormatDrm
|
if (supportsFormatDrm
|
||||||
&& audioSink.supportsFormat(format)
|
&& audioSink.supportsFormat(format)
|
||||||
&& (!formatHasDrm || MediaCodecUtil.getDecryptOnlyDecoderInfo() != null)) {
|
&& (!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
|
// If the input is PCM then it will be passed directly to the sink. Hence the sink must support
|
||||||
// the input format directly.
|
// the input format directly.
|
||||||
if (MimeTypes.AUDIO_RAW.equals(format.sampleMimeType) && !audioSink.supportsFormat(format)) {
|
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.
|
// For all other input formats, we expect the decoder to output 16-bit PCM.
|
||||||
if (!audioSink.supportsFormat(
|
if (!audioSink.supportsFormat(
|
||||||
Util.getPcmFormat(C.ENCODING_PCM_16BIT, format.channelCount, format.sampleRate))) {
|
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 =
|
List<MediaCodecInfo> decoderInfos =
|
||||||
getDecoderInfos(mediaCodecSelector, format, /* requiresSecureDecoder= */ false);
|
getDecoderInfos(mediaCodecSelector, format, /* requiresSecureDecoder= */ false);
|
||||||
if (decoderInfos.isEmpty()) {
|
if (decoderInfos.isEmpty()) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
|
||||||
}
|
}
|
||||||
if (!supportsFormatDrm) {
|
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.
|
// Check capabilities for the first decoder in the list, which takes priority.
|
||||||
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
||||||
@ -271,8 +271,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
isFormatSupported && decoderInfo.isSeamlessAdaptationSupported(format)
|
isFormatSupported && decoderInfo.isSeamlessAdaptationSupported(format)
|
||||||
? ADAPTIVE_SEAMLESS
|
? ADAPTIVE_SEAMLESS
|
||||||
: ADAPTIVE_NOT_SEAMLESS;
|
: ADAPTIVE_NOT_SEAMLESS;
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
int formatSupport = isFormatSupported ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
|
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
|
||||||
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
|
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +103,9 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
|
|||||||
public int supportsFormat(Format format) {
|
public int supportsFormat(Format format) {
|
||||||
if (decoderFactory.supportsFormat(format)) {
|
if (decoderFactory.supportsFormat(format)) {
|
||||||
return RendererCapabilities.create(
|
return RendererCapabilities.create(
|
||||||
format.exoMediaCryptoType == null ? FORMAT_HANDLED : FORMAT_UNSUPPORTED_DRM);
|
format.exoMediaCryptoType == null ? C.FORMAT_HANDLED : C.FORMAT_UNSUPPORTED_DRM);
|
||||||
} else {
|
} else {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +133,11 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
|||||||
public int supportsFormat(Format format) {
|
public int supportsFormat(Format format) {
|
||||||
if (decoderFactory.supportsFormat(format)) {
|
if (decoderFactory.supportsFormat(format)) {
|
||||||
return RendererCapabilities.create(
|
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)) {
|
} else if (MimeTypes.isText(format.sampleMimeType)) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
|
||||||
} else {
|
} else {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import android.util.SparseArray;
|
|||||||
import android.util.SparseBooleanArray;
|
import android.util.SparseBooleanArray;
|
||||||
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.FormatSupport;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.Player;
|
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;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
|
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
|
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.RendererConfiguration;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
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
|
* Returns true if the {@link FormatSupport} in the given {@link Capabilities} is {@link
|
||||||
* RendererCapabilities#FORMAT_HANDLED} or if {@code allowExceedsCapabilities} is set and the
|
* C#FORMAT_HANDLED} or if {@code allowExceedsCapabilities} is set and the format support is
|
||||||
* format support is {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}.
|
* {@link C#FORMAT_EXCEEDS_CAPABILITIES}.
|
||||||
*
|
*
|
||||||
* @param formatSupport {@link Capabilities}.
|
* @param formatSupport {@link Capabilities}.
|
||||||
* @param allowExceedsCapabilities Whether to return true if {@link FormatSupport} is {@link
|
* @param allowExceedsCapabilities Whether to return true if {@link FormatSupport} is {@link
|
||||||
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}.
|
* C#FORMAT_EXCEEDS_CAPABILITIES}.
|
||||||
* @return True if {@link FormatSupport} is {@link RendererCapabilities#FORMAT_HANDLED}, or if
|
* @return True if {@link FormatSupport} is {@link C#FORMAT_HANDLED}, or if {@code
|
||||||
* {@code allowExceedsCapabilities} is set and the format support is {@link
|
* allowExceedsCapabilities} is set and the format support is {@link
|
||||||
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}.
|
* C#FORMAT_EXCEEDS_CAPABILITIES}.
|
||||||
*/
|
*/
|
||||||
protected static boolean isSupported(
|
protected static boolean isSupported(
|
||||||
@Capabilities int formatSupport, boolean allowExceedsCapabilities) {
|
@Capabilities int formatSupport, boolean allowExceedsCapabilities) {
|
||||||
@FormatSupport int maskedSupport = RendererCapabilities.getFormatSupport(formatSupport);
|
@FormatSupport int maskedSupport = RendererCapabilities.getFormatSupport(formatSupport);
|
||||||
return maskedSupport == RendererCapabilities.FORMAT_HANDLED || (allowExceedsCapabilities
|
return maskedSupport == C.FORMAT_HANDLED
|
||||||
&& maskedSupport == RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES);
|
|| (allowExceedsCapabilities && maskedSupport == C.FORMAT_EXCEEDS_CAPABILITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,12 +22,12 @@ import android.util.Pair;
|
|||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
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.FormatSupport;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities;
|
import com.google.android.exoplayer2.RendererCapabilities;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
|
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
|
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.RendererConfiguration;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
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;
|
public static final int RENDERER_SUPPORT_NO_TRACKS = 0;
|
||||||
/**
|
/**
|
||||||
* The renderer has tracks mapped to it, but all are unsupported. In other words, {@link
|
* 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},
|
* #getTrackSupport(int, int, int)} returns {@link C#FORMAT_UNSUPPORTED_DRM}, {@link
|
||||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} or {@link
|
* C#FORMAT_UNSUPPORTED_SUBTYPE} or {@link C#FORMAT_UNSUPPORTED_TYPE} for all tracks mapped to
|
||||||
* RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all tracks mapped to the renderer.
|
* the renderer.
|
||||||
*/
|
*/
|
||||||
public static final int RENDERER_SUPPORT_UNSUPPORTED_TRACKS = 1;
|
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
|
* 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,
|
* tracks exceed the renderer's capabilities. In other words, {@link #getTrackSupport(int, int,
|
||||||
* int)} returns {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} for at least one
|
* int)} returns {@link C#FORMAT_EXCEEDS_CAPABILITIES} for at least one track mapped to the
|
||||||
* track mapped to the renderer, but does not return {@link
|
* renderer, but does not return {@link C#FORMAT_HANDLED} for any tracks mapped to the renderer.
|
||||||
* RendererCapabilities#FORMAT_HANDLED} for any tracks mapped to the renderer.
|
|
||||||
*/
|
*/
|
||||||
public static final int RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS = 2;
|
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
|
* 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
|
* words, {@link #getTrackSupport(int, int, int)} returns {@link C#FORMAT_HANDLED} for at least
|
||||||
* RendererCapabilities#FORMAT_HANDLED} for at least one track mapped to the renderer.
|
* one track mapped to the renderer.
|
||||||
*/
|
*/
|
||||||
public static final int RENDERER_SUPPORT_PLAYABLE_TRACKS = 3;
|
public static final int RENDERER_SUPPORT_PLAYABLE_TRACKS = 3;
|
||||||
|
|
||||||
@ -181,14 +180,14 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||||||
for (@Capabilities int trackFormatSupport : trackGroupFormatSupport) {
|
for (@Capabilities int trackFormatSupport : trackGroupFormatSupport) {
|
||||||
int trackRendererSupport;
|
int trackRendererSupport;
|
||||||
switch (RendererCapabilities.getFormatSupport(trackFormatSupport)) {
|
switch (RendererCapabilities.getFormatSupport(trackFormatSupport)) {
|
||||||
case RendererCapabilities.FORMAT_HANDLED:
|
case C.FORMAT_HANDLED:
|
||||||
return RENDERER_SUPPORT_PLAYABLE_TRACKS;
|
return RENDERER_SUPPORT_PLAYABLE_TRACKS;
|
||||||
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
|
case C.FORMAT_EXCEEDS_CAPABILITIES:
|
||||||
trackRendererSupport = RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS;
|
trackRendererSupport = RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS;
|
||||||
break;
|
break;
|
||||||
case RendererCapabilities.FORMAT_UNSUPPORTED_TYPE:
|
case C.FORMAT_UNSUPPORTED_TYPE:
|
||||||
case RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE:
|
case C.FORMAT_UNSUPPORTED_SUBTYPE:
|
||||||
case RendererCapabilities.FORMAT_UNSUPPORTED_DRM:
|
case C.FORMAT_UNSUPPORTED_DRM:
|
||||||
trackRendererSupport = RENDERER_SUPPORT_UNSUPPORTED_TRACKS;
|
trackRendererSupport = RENDERER_SUPPORT_UNSUPPORTED_TRACKS;
|
||||||
break;
|
break;
|
||||||
default:
|
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
|
* Returns the extent to which a renderer supports adaptation between supported tracks in a
|
||||||
* specified {@link TrackGroup}.
|
* specified {@link TrackGroup}.
|
||||||
*
|
*
|
||||||
* <p>Tracks for which {@link #getTrackSupport(int, int, int)} returns {@link
|
* <p>Tracks for which {@link #getTrackSupport(int, int, int)} returns {@link C#FORMAT_HANDLED}
|
||||||
* RendererCapabilities#FORMAT_HANDLED} are always considered. Tracks for which {@link
|
* are always considered. Tracks for which {@link #getTrackSupport(int, int, int)} returns
|
||||||
* #getTrackSupport(int, int, int)} returns {@link
|
* {@link C#FORMAT_EXCEEDS_CAPABILITIES} are also considered if {@code
|
||||||
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} are also considered if {@code
|
|
||||||
* includeCapabilitiesExceededTracks} is set to {@code true}. Tracks for which {@link
|
* includeCapabilitiesExceededTracks} is set to {@code true}. Tracks for which {@link
|
||||||
* #getTrackSupport(int, int, int)} returns {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM},
|
* #getTrackSupport(int, int, int)} returns {@link C#FORMAT_UNSUPPORTED_DRM}, {@link
|
||||||
* {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} or {@link
|
* C#FORMAT_UNSUPPORTED_TYPE} or {@link C#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
|
||||||
* RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} are never considered.
|
|
||||||
*
|
*
|
||||||
* @param rendererIndex The renderer index.
|
* @param rendererIndex The renderer index.
|
||||||
* @param groupIndex The index of the track group.
|
* @param groupIndex The index of the track group.
|
||||||
@ -276,9 +273,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||||||
int trackIndexCount = 0;
|
int trackIndexCount = 0;
|
||||||
for (int i = 0; i < trackCount; i++) {
|
for (int i = 0; i < trackCount; i++) {
|
||||||
@FormatSupport int fixedSupport = getTrackSupport(rendererIndex, groupIndex, i);
|
@FormatSupport int fixedSupport = getTrackSupport(rendererIndex, groupIndex, i);
|
||||||
if (fixedSupport == RendererCapabilities.FORMAT_HANDLED
|
if (fixedSupport == C.FORMAT_HANDLED
|
||||||
|| (includeCapabilitiesExceededTracks
|
|| (includeCapabilitiesExceededTracks
|
||||||
&& fixedSupport == RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES)) {
|
&& fixedSupport == C.FORMAT_EXCEEDS_CAPABILITIES)) {
|
||||||
trackIndices[trackIndexCount++] = i;
|
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.
|
* 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
|
* <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
|
* decreasing order of support) {@link C#FORMAT_HANDLED}, {@link C#FORMAT_EXCEEDS_CAPABILITIES},
|
||||||
* RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES}, {@link
|
* {@link C#FORMAT_UNSUPPORTED_DRM} and {@link C#FORMAT_UNSUPPORTED_SUBTYPE}.
|
||||||
* RendererCapabilities#FORMAT_UNSUPPORTED_DRM} and {@link
|
|
||||||
* RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE}.
|
|
||||||
*
|
*
|
||||||
* <p>In the case that two or more renderers report the same level of support, the assignment
|
* <p>In the case that two or more renderers report the same level of support, the assignment
|
||||||
* depends on {@code preferUnassociatedRenderer}.
|
* depends on {@code preferUnassociatedRenderer}.
|
||||||
@ -485,9 +480,9 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||||||
* available renderers have already mapped track groups.
|
* available renderers have already mapped track groups.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
|
* <p>If all renderers report {@link C#FORMAT_UNSUPPORTED_TYPE} for all of the tracks in the
|
||||||
* tracks in the group, then {@code renderers.length} is returned to indicate that the group was
|
* group, then {@code renderers.length} is returned to indicate that the group was not mapped to
|
||||||
* not mapped to any renderer.
|
* any renderer.
|
||||||
*
|
*
|
||||||
* @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
|
* @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
|
||||||
* @param group The track group to map to a renderer.
|
* @param group The track group to map to a renderer.
|
||||||
@ -505,11 +500,11 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
|||||||
boolean preferUnassociatedRenderer)
|
boolean preferUnassociatedRenderer)
|
||||||
throws ExoPlaybackException {
|
throws ExoPlaybackException {
|
||||||
int bestRendererIndex = rendererCapabilities.length;
|
int bestRendererIndex = rendererCapabilities.length;
|
||||||
@FormatSupport int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
|
@FormatSupport int bestFormatSupportLevel = C.FORMAT_UNSUPPORTED_TYPE;
|
||||||
boolean bestRendererIsUnassociated = true;
|
boolean bestRendererIsUnassociated = true;
|
||||||
for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
|
for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
|
||||||
RendererCapabilities rendererCapability = rendererCapabilities[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++) {
|
for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
|
||||||
@FormatSupport
|
@FormatSupport
|
||||||
int trackFormatSupportLevel =
|
int trackFormatSupportLevel =
|
||||||
|
@ -239,7 +239,7 @@ public class EventLogger implements AnalyticsListener {
|
|||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
||||||
String formatSupport =
|
String formatSupport =
|
||||||
RendererCapabilities.getFormatSupportString(
|
C.getFormatSupportString(
|
||||||
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
|
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
|
||||||
logd(
|
logd(
|
||||||
" "
|
" "
|
||||||
@ -277,9 +277,7 @@ public class EventLogger implements AnalyticsListener {
|
|||||||
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
|
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
|
||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
String status = getTrackStatusString(false);
|
String status = getTrackStatusString(false);
|
||||||
String formatSupport =
|
String formatSupport = C.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
RendererCapabilities.getFormatSupportString(
|
|
||||||
RendererCapabilities.FORMAT_UNSUPPORTED_TYPE);
|
|
||||||
logd(
|
logd(
|
||||||
" "
|
" "
|
||||||
+ status
|
+ status
|
||||||
|
@ -260,7 +260,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
throws DecoderQueryException {
|
throws DecoderQueryException {
|
||||||
String mimeType = format.sampleMimeType;
|
String mimeType = format.sampleMimeType;
|
||||||
if (!MimeTypes.isVideo(mimeType)) {
|
if (!MimeTypes.isVideo(mimeType)) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
@Nullable DrmInitData drmInitData = format.drmInitData;
|
@Nullable DrmInitData drmInitData = format.drmInitData;
|
||||||
// Assume encrypted content requires secure decoders.
|
// Assume encrypted content requires secure decoders.
|
||||||
@ -281,10 +281,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
/* requiresTunnelingDecoder= */ false);
|
/* requiresTunnelingDecoder= */ false);
|
||||||
}
|
}
|
||||||
if (decoderInfos.isEmpty()) {
|
if (decoderInfos.isEmpty()) {
|
||||||
return RendererCapabilities.create(FORMAT_UNSUPPORTED_SUBTYPE);
|
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);
|
||||||
}
|
}
|
||||||
if (!supportsFormatDrm(format)) {
|
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.
|
// Check capabilities for the first decoder in the list, which takes priority.
|
||||||
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
||||||
@ -310,8 +310,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
int formatSupport = isFormatSupported ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
|
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
|
||||||
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
|
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ public final class CameraMotionRenderer extends BaseRenderer {
|
|||||||
@Capabilities
|
@Capabilities
|
||||||
public int supportsFormat(Format format) {
|
public int supportsFormat(Format format) {
|
||||||
return MimeTypes.APPLICATION_CAMERA_MOTION.equals(format.sampleMimeType)
|
return MimeTypes.APPLICATION_CAMERA_MOTION.equals(format.sampleMimeType)
|
||||||
? RendererCapabilities.create(FORMAT_HANDLED)
|
? RendererCapabilities.create(C.FORMAT_HANDLED)
|
||||||
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.audio;
|
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.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_NOT_SUPPORTED;
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_SUPPORTED;
|
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_SUPPORTED;
|
||||||
import static com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM;
|
import static com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM;
|
||||||
@ -68,7 +68,7 @@ public class DecoderAudioRendererTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@FormatSupport
|
@C.FormatSupport
|
||||||
protected int supportsFormatInternal(Format format) {
|
protected int supportsFormatInternal(Format format) {
|
||||||
return FORMAT_HANDLED;
|
return FORMAT_HANDLED;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ public class MediaCodecAudioRendererTest {
|
|||||||
"rendererName",
|
"rendererName",
|
||||||
/* rendererIndex= */ 0,
|
/* rendererIndex= */ 0,
|
||||||
format,
|
format,
|
||||||
FORMAT_HANDLED));
|
C.FORMAT_HANDLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.trackselection;
|
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.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.RendererCapabilities.TUNNELING_NOT_SUPPORTED;
|
||||||
import static com.google.android.exoplayer2.RendererConfiguration.DEFAULT;
|
import static com.google.android.exoplayer2.RendererConfiguration.DEFAULT;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
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.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities;
|
import com.google.android.exoplayer2.RendererCapabilities;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
|
|
||||||
import com.google.android.exoplayer2.RendererConfiguration;
|
import com.google.android.exoplayer2.RendererConfiguration;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
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 {@link RendererCapabilities} that advertises support for all formats of a given type using a
|
||||||
* a provided support value. For any format that does not have the given track type,
|
* provided support value. For any format that does not have the given track type, {@link
|
||||||
* {@link #supportsFormat(Format)} will return {@link #FORMAT_UNSUPPORTED_TYPE}.
|
* #supportsFormat(Format)} will return {@link C#FORMAT_UNSUPPORTED_TYPE}.
|
||||||
*/
|
*/
|
||||||
private static final class FakeRendererCapabilities implements RendererCapabilities {
|
private static final class FakeRendererCapabilities implements RendererCapabilities {
|
||||||
|
|
||||||
@ -1589,7 +1588,7 @@ public final class DefaultTrackSelectorTest {
|
|||||||
public int supportsFormat(Format format) {
|
public int supportsFormat(Format format) {
|
||||||
return MimeTypes.getTrackType(format.sampleMimeType) == trackType
|
return MimeTypes.getTrackType(format.sampleMimeType) == trackType
|
||||||
? supportValue
|
? supportValue
|
||||||
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1615,8 +1614,8 @@ public final class DefaultTrackSelectorTest {
|
|||||||
*
|
*
|
||||||
* @param trackType the track type to be returned for {@link #getTrackType()}
|
* @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
|
* @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,
|
* support level for any given format. For any format that's not in the map, {@link
|
||||||
* {@link #supportsFormat(Format)} will return {@link #FORMAT_UNSUPPORTED_TYPE}.
|
* #supportsFormat(Format)} will return {@link C#FORMAT_UNSUPPORTED_TYPE}.
|
||||||
*/
|
*/
|
||||||
FakeMappedRendererCapabilities(int trackType, Map<String, Integer> formatToCapability) {
|
FakeMappedRendererCapabilities(int trackType, Map<String, Integer> formatToCapability) {
|
||||||
this.trackType = trackType;
|
this.trackType = trackType;
|
||||||
@ -1638,7 +1637,7 @@ public final class DefaultTrackSelectorTest {
|
|||||||
public int supportsFormat(Format format) {
|
public int supportsFormat(Format format) {
|
||||||
return format.id != null && formatToCapability.containsKey(format.id)
|
return format.id != null && formatToCapability.containsKey(format.id)
|
||||||
? formatToCapability.get(format.id)
|
? formatToCapability.get(format.id)
|
||||||
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -184,8 +184,9 @@ public final class MappingTrackSelectorTest {
|
|||||||
@Capabilities
|
@Capabilities
|
||||||
public int supportsFormat(Format format) throws ExoPlaybackException {
|
public int supportsFormat(Format format) throws ExoPlaybackException {
|
||||||
return MimeTypes.getTrackType(format.sampleMimeType) == trackType
|
return MimeTypes.getTrackType(format.sampleMimeType) == trackType
|
||||||
? RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
|
? RendererCapabilities.create(
|
||||||
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
C.FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
|
||||||
|
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,7 +89,7 @@ public final class DecoderVideoRendererTest {
|
|||||||
@Override
|
@Override
|
||||||
@Capabilities
|
@Capabilities
|
||||||
public int supportsFormat(Format format) {
|
public int supportsFormat(Format format) {
|
||||||
return RendererCapabilities.create(FORMAT_HANDLED);
|
return RendererCapabilities.create(C.FORMAT_HANDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,7 +107,7 @@ public class MediaCodecVideoRendererTest {
|
|||||||
@Override
|
@Override
|
||||||
@Capabilities
|
@Capabilities
|
||||||
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format) {
|
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format) {
|
||||||
return RendererCapabilities.create(FORMAT_HANDLED);
|
return RendererCapabilities.create(C.FORMAT_HANDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +56,6 @@ import com.google.android.exoplayer2.PlaybackPreparer;
|
|||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Player.Events;
|
import com.google.android.exoplayer2.Player.Events;
|
||||||
import com.google.android.exoplayer2.Player.State;
|
import com.google.android.exoplayer2.Player.State;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities;
|
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
@ -1307,7 +1306,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
|||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
Format format = trackGroup.getFormat(trackIndex);
|
Format format = trackGroup.getFormat(trackIndex);
|
||||||
if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
|
if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
|
||||||
== RendererCapabilities.FORMAT_HANDLED) {
|
== C.FORMAT_HANDLED) {
|
||||||
boolean trackIsSelected =
|
boolean trackIsSelected =
|
||||||
trackSelection != null && trackSelection.indexOf(format) != C.INDEX_UNSET;
|
trackSelection != null && trackSelection.indexOf(format) != C.INDEX_UNSET;
|
||||||
tracks.add(
|
tracks.add(
|
||||||
|
@ -25,6 +25,7 @@ import android.widget.CheckedTextView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import androidx.annotation.AttrRes;
|
import androidx.annotation.AttrRes;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities;
|
import com.google.android.exoplayer2.RendererCapabilities;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
@ -291,7 +292,7 @@ public class TrackSelectionView extends LinearLayout {
|
|||||||
trackView.setText(trackNameProvider.getTrackName(trackInfos[trackIndex].format));
|
trackView.setText(trackNameProvider.getTrackName(trackInfos[trackIndex].format));
|
||||||
trackView.setTag(trackInfos[trackIndex]);
|
trackView.setTag(trackInfos[trackIndex]);
|
||||||
if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
|
if (mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)
|
||||||
== RendererCapabilities.FORMAT_HANDLED) {
|
== C.FORMAT_HANDLED) {
|
||||||
trackView.setFocusable(true);
|
trackView.setFocusable(true);
|
||||||
trackView.setOnClickListener(componentListener);
|
trackView.setOnClickListener(componentListener);
|
||||||
} else {
|
} else {
|
||||||
|
@ -458,8 +458,7 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isFormatHandled(int formatSupport) {
|
private static boolean isFormatHandled(int formatSupport) {
|
||||||
return RendererCapabilities.getFormatSupport(formatSupport)
|
return RendererCapabilities.getFormatSupport(formatSupport) == C.FORMAT_HANDLED;
|
||||||
== RendererCapabilities.FORMAT_HANDLED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class FakeRenderer extends BaseRenderer {
|
|||||||
getName(),
|
getName(),
|
||||||
getIndex(),
|
getIndex(),
|
||||||
format,
|
format,
|
||||||
FORMAT_UNSUPPORTED_TYPE);
|
C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
formatsRead.add(format);
|
formatsRead.add(format);
|
||||||
onFormatChanged(format);
|
onFormatChanged(format);
|
||||||
@ -149,8 +149,8 @@ public class FakeRenderer extends BaseRenderer {
|
|||||||
public int supportsFormat(Format format) throws ExoPlaybackException {
|
public int supportsFormat(Format format) throws ExoPlaybackException {
|
||||||
int trackType = MimeTypes.getTrackType(format.sampleMimeType);
|
int trackType = MimeTypes.getTrackType(format.sampleMimeType);
|
||||||
return trackType != C.TRACK_TYPE_UNKNOWN && trackType == getTrackType()
|
return trackType != C.TRACK_TYPE_UNKNOWN && trackType == getTrackType()
|
||||||
? RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
|
? RendererCapabilities.create(C.FORMAT_HANDLED, ADAPTIVE_SEAMLESS, TUNNELING_NOT_SUPPORTED)
|
||||||
: RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
|
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user