From 1208d8ec75b611c210c540b2b1cd95b4e30487b5 Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 24 Feb 2016 08:32:59 -0800 Subject: [PATCH] Allow more precise reporting of format support. This change allows a TrackRenderer to distinguish between the "I don't support this type at all" case and the "I am a general purpose renderer of this type, but cannot support the specific subtype" case. Bug=26622675 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115454950 --- .../MediaCodecAudioTrackRenderer.java | 2 +- .../MediaCodecVideoTrackRenderer.java | 2 +- .../android/exoplayer/TrackRenderer.java | 27 +++++++++++++------ .../exoplayer/text/TextTrackRenderer.java | 4 ++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java index 80dc551f38..4c86e9c898 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java @@ -196,7 +196,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType, format.requiresSecureDecryption); if (decoderInfo == null) { - return FORMAT_UNSUPPORTED_TYPE; + return FORMAT_UNSUPPORTED_SUBTYPE; } // Note: We assume support for unknown sampleRate and channelCount. boolean decoderCapable = Util.SDK_INT < 21 diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java index 2d47682938..8355d8f114 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java @@ -230,7 +230,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType, format.requiresSecureDecryption); if (decoderInfo == null) { - return FORMAT_UNSUPPORTED_TYPE; + return FORMAT_UNSUPPORTED_SUBTYPE; } boolean decoderCapable; diff --git a/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java index 0a0c9856bb..f8b15567ab 100644 --- a/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java +++ b/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java @@ -36,14 +36,14 @@ public abstract class TrackRenderer implements ExoPlayerComponent { /** * A mask to apply to the result of {@link #supportsFormat(Format)} to obtain one of - * {@link #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES} and - * {@link #FORMAT_UNSUPPORTED_TYPE}. + * {@link #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES}, + * {@link #FORMAT_UNSUPPORTED_SUBTYPE} and {@link #FORMAT_UNSUPPORTED_TYPE}. */ public static final int FORMAT_SUPPORT_MASK = 0b11; /** * The {@link TrackRenderer} is capable of rendering the format. */ - public static final int FORMAT_HANDLED = 0b10; + public static final int FORMAT_HANDLED = 0b11; /** * The {@link TrackRenderer} is capable of rendering formats with the same mimeType, but the * properties of the format exceed the renderer's capability. @@ -52,12 +52,22 @@ public abstract class TrackRenderer implements ExoPlayerComponent { * {@link 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 = 0b01; + public static final int FORMAT_EXCEEDS_CAPABILITIES = 0b10; /** - * The {@link TrackRenderer} is not capable of rendering the format, or any other format with the - * same mimeType. + * The {@link TrackRenderer} 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 mimeType because + * the sub-type is not supported. *

- * Example: The {@link TrackRenderer} is only capable of rendering video and the track has an + * Example: The {@link TrackRenderer} is a general purpose audio renderer and the format's + * mimeType matches audio/[subtype], but there does not exist a suitable decoder for [subtype]. + */ + public static final int FORMAT_UNSUPPORTED_SUBTYPE = 0b01; + /** + * The {@link TrackRenderer} 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 + * mimeType. + *

+ * Example: The {@link TrackRenderer} is a general purpose video renderer, but the format has an * audio mimeType. */ public static final int FORMAT_UNSUPPORTED_TYPE = 0b00; @@ -159,7 +169,8 @@ public abstract class TrackRenderer implements ExoPlayerComponent { * The returned value is the bitwise OR of two properties: *