mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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
This commit is contained in:
parent
6ba4fa3b51
commit
1208d8ec75
4 changed files with 24 additions and 11 deletions
|
|
@ -196,7 +196,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
|
||||||
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
||||||
format.requiresSecureDecryption);
|
format.requiresSecureDecryption);
|
||||||
if (decoderInfo == null) {
|
if (decoderInfo == null) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
}
|
}
|
||||||
// Note: We assume support for unknown sampleRate and channelCount.
|
// Note: We assume support for unknown sampleRate and channelCount.
|
||||||
boolean decoderCapable = Util.SDK_INT < 21
|
boolean decoderCapable = Util.SDK_INT < 21
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
|
||||||
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
||||||
format.requiresSecureDecryption);
|
format.requiresSecureDecryption);
|
||||||
if (decoderInfo == null) {
|
if (decoderInfo == null) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean decoderCapable;
|
boolean decoderCapable;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES},
|
||||||
* {@link #FORMAT_UNSUPPORTED_TYPE}.
|
* {@link #FORMAT_UNSUPPORTED_SUBTYPE} and {@link #FORMAT_UNSUPPORTED_TYPE}.
|
||||||
*/
|
*/
|
||||||
public static final int FORMAT_SUPPORT_MASK = 0b11;
|
public static final int FORMAT_SUPPORT_MASK = 0b11;
|
||||||
/**
|
/**
|
||||||
* The {@link TrackRenderer} is capable of rendering the format.
|
* 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
|
* The {@link TrackRenderer} is capable of rendering formats with the same mimeType, but the
|
||||||
* properties of the format exceed the renderer's capability.
|
* 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
|
* {@link MimeTypes#VIDEO_H264}, but the format's resolution exceeds the maximum limit supported
|
||||||
* by the underlying H264 decoder.
|
* 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
|
* The {@link TrackRenderer} is a general purpose renderer for formats of the same top-level type,
|
||||||
* same mimeType.
|
* but is not capable of rendering the format or any other format with the same mimeType because
|
||||||
|
* the sub-type is not supported.
|
||||||
* <p>
|
* <p>
|
||||||
* 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.
|
||||||
|
* <p>
|
||||||
|
* Example: The {@link TrackRenderer} is a general purpose video renderer, but the format has an
|
||||||
* audio mimeType.
|
* audio mimeType.
|
||||||
*/
|
*/
|
||||||
public static final int FORMAT_UNSUPPORTED_TYPE = 0b00;
|
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:
|
* The returned value is the bitwise OR of two properties:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>The level of support for the format itself. One of {@code}link #FORMAT_HANDLED},
|
* <li>The level of support for the format itself. One of {@code}link #FORMAT_HANDLED},
|
||||||
* {@link #FORMAT_EXCEEDS_CAPABILITIES} and {@link #FORMAT_UNSUPPORTED_TYPE}.</li>
|
* {@link #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_SUBTYPE} and
|
||||||
|
* {@link #FORMAT_UNSUPPORTED_TYPE}.</li>
|
||||||
* <li>The level of support for adapting from the format to another format of the same mimeType.
|
* <li>The level of support for adapting from the format to another format of the same mimeType.
|
||||||
* One of {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
|
* One of {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
|
||||||
* {@link #ADAPTIVE_NOT_SUPPORTED}.</li>
|
* {@link #ADAPTIVE_NOT_SUPPORTED}.</li>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.google.android.exoplayer.SampleSourceTrackRenderer;
|
||||||
import com.google.android.exoplayer.TrackRenderer;
|
import com.google.android.exoplayer.TrackRenderer;
|
||||||
import com.google.android.exoplayer.TrackStream;
|
import com.google.android.exoplayer.TrackStream;
|
||||||
import com.google.android.exoplayer.util.Assertions;
|
import com.google.android.exoplayer.util.Assertions;
|
||||||
|
import com.google.android.exoplayer.util.MimeTypes;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
@ -157,7 +158,8 @@ public final class TextTrackRenderer extends SampleSourceTrackRenderer implement
|
||||||
@Override
|
@Override
|
||||||
protected int supportsFormat(Format format) {
|
protected int supportsFormat(Format format) {
|
||||||
return getParserIndex(format.sampleMimeType) != -1 ? TrackRenderer.FORMAT_HANDLED
|
return getParserIndex(format.sampleMimeType) != -1 ? TrackRenderer.FORMAT_HANDLED
|
||||||
: TrackRenderer.FORMAT_UNSUPPORTED_TYPE;
|
: (MimeTypes.isText(format.sampleMimeType) ? FORMAT_UNSUPPORTED_SUBTYPE
|
||||||
|
: FORMAT_UNSUPPORTED_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue