Rename DecoderInfo -> MediaCodecDecoderInfo
All other MediaCodec specific classes are prefixed MediaCodec, and we now have other decoders that aren't not related to MediaCodec. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127093330
This commit is contained in:
parent
fdf26d6a1f
commit
bcca373f5b
@ -148,7 +148,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderInfo() != null) {
|
if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderInfo() != null) {
|
||||||
return ADAPTIVE_NOT_SEAMLESS | FORMAT_HANDLED;
|
return ADAPTIVE_NOT_SEAMLESS | FORMAT_HANDLED;
|
||||||
}
|
}
|
||||||
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
MediaCodecDecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
||||||
format.requiresSecureDecryption);
|
format.requiresSecureDecryption);
|
||||||
if (decoderInfo == null) {
|
if (decoderInfo == null) {
|
||||||
return FORMAT_UNSUPPORTED_SUBTYPE;
|
return FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
@ -164,10 +164,10 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, Format format,
|
protected MediaCodecDecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector,
|
||||||
boolean requiresSecureDecoder) throws DecoderQueryException {
|
Format format, boolean requiresSecureDecoder) throws DecoderQueryException {
|
||||||
if (allowPassthrough(format.sampleMimeType)) {
|
if (allowPassthrough(format.sampleMimeType)) {
|
||||||
DecoderInfo passthroughDecoderInfo = mediaCodecSelector.getPassthroughDecoderInfo();
|
MediaCodecDecoderInfo passthroughDecoderInfo = mediaCodecSelector.getPassthroughDecoderInfo();
|
||||||
if (passthroughDecoderInfo != null) {
|
if (passthroughDecoderInfo != null) {
|
||||||
passthroughEnabled = true;
|
passthroughEnabled = true;
|
||||||
return passthroughDecoderInfo;
|
return passthroughDecoderInfo;
|
||||||
|
@ -29,7 +29,7 @@ import android.util.Pair;
|
|||||||
* Contains information about a media decoder.
|
* Contains information about a media decoder.
|
||||||
*/
|
*/
|
||||||
@TargetApi(16)
|
@TargetApi(16)
|
||||||
public final class DecoderInfo {
|
public final class MediaCodecDecoderInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the decoder.
|
* The name of the decoder.
|
||||||
@ -42,28 +42,28 @@ public final class DecoderInfo {
|
|||||||
/**
|
/**
|
||||||
* Whether the decoder supports seamless resolution switches.
|
* Whether the decoder supports seamless resolution switches.
|
||||||
*
|
*
|
||||||
* @see android.media.MediaCodecInfo.CodecCapabilities#isFeatureSupported(String)
|
* @see MediaCodecInfo.CodecCapabilities#isFeatureSupported(String)
|
||||||
* @see android.media.MediaCodecInfo.CodecCapabilities#FEATURE_AdaptivePlayback
|
* @see MediaCodecInfo.CodecCapabilities#FEATURE_AdaptivePlayback
|
||||||
*/
|
*/
|
||||||
public final boolean adaptive;
|
public final boolean adaptive;
|
||||||
|
|
||||||
private final String mimeType;
|
private final String mimeType;
|
||||||
private final CodecCapabilities capabilities;
|
private final CodecCapabilities capabilities;
|
||||||
|
|
||||||
public static DecoderInfo newPassthroughInstance(String name) {
|
public static MediaCodecDecoderInfo newPassthroughInstance(String name) {
|
||||||
return new DecoderInfo(name, null, null);
|
return new MediaCodecDecoderInfo(name, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DecoderInfo newInstance(String name, String mimeType,
|
public static MediaCodecDecoderInfo newInstance(String name, String mimeType,
|
||||||
CodecCapabilities capabilities) {
|
CodecCapabilities capabilities) {
|
||||||
return new DecoderInfo(name, mimeType, capabilities);
|
return new MediaCodecDecoderInfo(name, mimeType, capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name of the decoder.
|
* @param name The name of the decoder.
|
||||||
* @param capabilities The capabilities of the decoder.
|
* @param capabilities The capabilities of the decoder.
|
||||||
*/
|
*/
|
||||||
private DecoderInfo(String name, String mimeType, CodecCapabilities capabilities) {
|
private MediaCodecDecoderInfo(String name, String mimeType, CodecCapabilities capabilities) {
|
||||||
this.name = Assertions.checkNotNull(name);
|
this.name = Assertions.checkNotNull(name);
|
||||||
this.mimeType = mimeType;
|
this.mimeType = mimeType;
|
||||||
this.capabilities = capabilities;
|
this.capabilities = capabilities;
|
@ -248,17 +248,17 @@ public abstract class MediaCodecRenderer extends Renderer {
|
|||||||
throws DecoderQueryException;
|
throws DecoderQueryException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link DecoderInfo} for a given format.
|
* Returns a {@link MediaCodecDecoderInfo} for a given format.
|
||||||
*
|
*
|
||||||
* @param mediaCodecSelector The decoder selector.
|
* @param mediaCodecSelector The decoder selector.
|
||||||
* @param format The format for which a decoder is required.
|
* @param format The format for which a decoder is required.
|
||||||
* @param requiresSecureDecoder Whether a secure decoder is required.
|
* @param requiresSecureDecoder Whether a secure decoder is required.
|
||||||
* @return A {@link DecoderInfo} describing the decoder to instantiate, or null if no suitable
|
* @return A {@link MediaCodecDecoderInfo} describing the decoder to instantiate, or null if no
|
||||||
* decoder exists.
|
* suitable decoder exists.
|
||||||
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
||||||
*/
|
*/
|
||||||
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, Format format,
|
protected MediaCodecDecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector,
|
||||||
boolean requiresSecureDecoder) throws DecoderQueryException {
|
Format format, boolean requiresSecureDecoder) throws DecoderQueryException {
|
||||||
return mediaCodecSelector.getDecoderInfo(format.sampleMimeType, requiresSecureDecoder);
|
return mediaCodecSelector.getDecoderInfo(format.sampleMimeType, requiresSecureDecoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ public abstract class MediaCodecRenderer extends Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DecoderInfo decoderInfo = null;
|
MediaCodecDecoderInfo decoderInfo = null;
|
||||||
try {
|
try {
|
||||||
decoderInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
|
decoderInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
|
||||||
if (decoderInfo == null && drmSessionRequiresSecureDecoder) {
|
if (decoderInfo == null && drmSessionRequiresSecureDecoder) {
|
||||||
|
@ -30,13 +30,13 @@ public interface MediaCodecSelector {
|
|||||||
MediaCodecSelector DEFAULT = new MediaCodecSelector() {
|
MediaCodecSelector DEFAULT = new MediaCodecSelector() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
|
public MediaCodecDecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
|
||||||
throws DecoderQueryException {
|
throws DecoderQueryException {
|
||||||
return MediaCodecUtil.getDecoderInfo(mimeType, requiresSecureDecoder);
|
return MediaCodecUtil.getDecoderInfo(mimeType, requiresSecureDecoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException {
|
public MediaCodecDecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException {
|
||||||
return MediaCodecUtil.getPassthroughDecoderInfo();
|
return MediaCodecUtil.getPassthroughDecoderInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,18 +47,20 @@ public interface MediaCodecSelector {
|
|||||||
*
|
*
|
||||||
* @param mimeType The mime type for which a decoder is required.
|
* @param mimeType The mime type for which a decoder is required.
|
||||||
* @param requiresSecureDecoder Whether a secure decoder is required.
|
* @param requiresSecureDecoder Whether a secure decoder is required.
|
||||||
* @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
|
* @return A {@link MediaCodecDecoderInfo} describing the decoder, or null if no suitable decoder
|
||||||
|
* exists.
|
||||||
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
||||||
*/
|
*/
|
||||||
DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
|
MediaCodecDecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
|
||||||
throws DecoderQueryException;
|
throws DecoderQueryException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects a decoder to instantiate for audio passthrough.
|
* Selects a decoder to instantiate for audio passthrough.
|
||||||
*
|
*
|
||||||
* @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
|
* @return A {@link MediaCodecDecoderInfo} describing the decoder, or null if no suitable decoder
|
||||||
|
* exists.
|
||||||
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
||||||
*/
|
*/
|
||||||
DecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException;
|
MediaCodecDecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,14 +58,15 @@ public final class MediaCodecUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String TAG = "MediaCodecUtil";
|
private static final String TAG = "MediaCodecUtil";
|
||||||
private static final DecoderInfo PASSTHROUGH_DECODER_INFO =
|
private static final MediaCodecDecoderInfo PASSTHROUGH_DECODER_INFO =
|
||||||
DecoderInfo.newPassthroughInstance("OMX.google.raw.decoder");
|
MediaCodecDecoderInfo.newPassthroughInstance("OMX.google.raw.decoder");
|
||||||
private static final Map<String, Integer> HEVC_CODEC_STRING_TO_PROFILE_LEVEL;
|
private static final Map<String, Integer> HEVC_CODEC_STRING_TO_PROFILE_LEVEL;
|
||||||
private static final String CODEC_ID_HEV1 = "hev1";
|
private static final String CODEC_ID_HEV1 = "hev1";
|
||||||
private static final String CODEC_ID_HVC1 = "hvc1";
|
private static final String CODEC_ID_HVC1 = "hvc1";
|
||||||
private static final Pattern PROFILE_PATTERN = Pattern.compile("^\\D?(\\d+)$");
|
private static final Pattern PROFILE_PATTERN = Pattern.compile("^\\D?(\\d+)$");
|
||||||
|
|
||||||
private static final HashMap<CodecKey, List<DecoderInfo>> decoderInfosCache = new HashMap<>();
|
private static final HashMap<CodecKey, List<MediaCodecDecoderInfo>> decoderInfosCache =
|
||||||
|
new HashMap<>();
|
||||||
|
|
||||||
// Lazily initialized.
|
// Lazily initialized.
|
||||||
private static int maxH264DecodableFrameSize = -1;
|
private static int maxH264DecodableFrameSize = -1;
|
||||||
@ -93,9 +94,10 @@ public final class MediaCodecUtil {
|
|||||||
/**
|
/**
|
||||||
* Returns information about a decoder suitable for audio passthrough.
|
* Returns information about a decoder suitable for audio passthrough.
|
||||||
**
|
**
|
||||||
* @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
|
* @return A {@link MediaCodecDecoderInfo} describing the decoder, or null if no suitable decoder
|
||||||
|
* exists.
|
||||||
*/
|
*/
|
||||||
public static DecoderInfo getPassthroughDecoderInfo() {
|
public static MediaCodecDecoderInfo getPassthroughDecoderInfo() {
|
||||||
// TODO: Return null if the raw decoder doesn't exist.
|
// TODO: Return null if the raw decoder doesn't exist.
|
||||||
return PASSTHROUGH_DECODER_INFO;
|
return PASSTHROUGH_DECODER_INFO;
|
||||||
}
|
}
|
||||||
@ -106,28 +108,29 @@ public final class MediaCodecUtil {
|
|||||||
* @param mimeType The mime type.
|
* @param mimeType The mime type.
|
||||||
* @param secure Whether the decoder is required to support secure decryption. Always pass false
|
* @param secure Whether the decoder is required to support secure decryption. Always pass false
|
||||||
* unless secure decryption really is required.
|
* unless secure decryption really is required.
|
||||||
* @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
|
* @return A {@link MediaCodecDecoderInfo} describing the decoder, or null if no suitable decoder
|
||||||
|
* exists.
|
||||||
*/
|
*/
|
||||||
public static DecoderInfo getDecoderInfo(String mimeType, boolean secure)
|
public static MediaCodecDecoderInfo getDecoderInfo(String mimeType, boolean secure)
|
||||||
throws DecoderQueryException {
|
throws DecoderQueryException {
|
||||||
List<DecoderInfo> decoderInfos = getDecoderInfos(mimeType, secure);
|
List<MediaCodecDecoderInfo> decoderInfos = getDecoderInfos(mimeType, secure);
|
||||||
return decoderInfos.isEmpty() ? null : decoderInfos.get(0);
|
return decoderInfos.isEmpty() ? null : decoderInfos.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all {@link DecoderInfo}s for the given mime type, in the order given by
|
* Returns all {@link MediaCodecDecoderInfo}s for the given mime type, in the order given by
|
||||||
* {@link MediaCodecList}.
|
* {@link MediaCodecList}.
|
||||||
*
|
*
|
||||||
* @param mimeType The mime type.
|
* @param mimeType The mime type.
|
||||||
* @param secure Whether the decoder is required to support secure decryption. Always pass false
|
* @param secure Whether the decoder is required to support secure decryption. Always pass false
|
||||||
* unless secure decryption really is required.
|
* unless secure decryption really is required.
|
||||||
* @return A list of all @{link DecoderInfo}s for the given mime type, in the order given by
|
* @return A list of all @{link MediaCodecDecoderInfo}s for the given mime type, in the order
|
||||||
* {@link MediaCodecList}.
|
* given by {@link MediaCodecList}.
|
||||||
*/
|
*/
|
||||||
public static synchronized List<DecoderInfo> getDecoderInfos(String mimeType, boolean secure)
|
public static synchronized List<MediaCodecDecoderInfo> getDecoderInfos(String mimeType,
|
||||||
throws DecoderQueryException {
|
boolean secure) throws DecoderQueryException {
|
||||||
CodecKey key = new CodecKey(mimeType, secure);
|
CodecKey key = new CodecKey(mimeType, secure);
|
||||||
List<DecoderInfo> decoderInfos = decoderInfosCache.get(key);
|
List<MediaCodecDecoderInfo> decoderInfos = decoderInfosCache.get(key);
|
||||||
if (decoderInfos != null) {
|
if (decoderInfos != null) {
|
||||||
return decoderInfos;
|
return decoderInfos;
|
||||||
}
|
}
|
||||||
@ -149,10 +152,10 @@ public final class MediaCodecUtil {
|
|||||||
return decoderInfos;
|
return decoderInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<DecoderInfo> getDecoderInfosInternal(
|
private static List<MediaCodecDecoderInfo> getDecoderInfosInternal(
|
||||||
CodecKey key, MediaCodecListCompat mediaCodecList) throws DecoderQueryException {
|
CodecKey key, MediaCodecListCompat mediaCodecList) throws DecoderQueryException {
|
||||||
try {
|
try {
|
||||||
List<DecoderInfo> decoderInfos = new ArrayList<>();
|
List<MediaCodecDecoderInfo> decoderInfos = new ArrayList<>();
|
||||||
String mimeType = key.mimeType;
|
String mimeType = key.mimeType;
|
||||||
int numberOfCodecs = mediaCodecList.getCodecCount();
|
int numberOfCodecs = mediaCodecList.getCodecCount();
|
||||||
boolean secureDecodersExplicit = mediaCodecList.secureDecodersExplicit();
|
boolean secureDecodersExplicit = mediaCodecList.secureDecodersExplicit();
|
||||||
@ -168,10 +171,11 @@ public final class MediaCodecUtil {
|
|||||||
boolean secure = mediaCodecList.isSecurePlaybackSupported(mimeType, capabilities);
|
boolean secure = mediaCodecList.isSecurePlaybackSupported(mimeType, capabilities);
|
||||||
if ((secureDecodersExplicit && key.secure == secure)
|
if ((secureDecodersExplicit && key.secure == secure)
|
||||||
|| (!secureDecodersExplicit && !key.secure)) {
|
|| (!secureDecodersExplicit && !key.secure)) {
|
||||||
decoderInfos.add(DecoderInfo.newInstance(codecName, mimeType, capabilities));
|
decoderInfos.add(
|
||||||
|
MediaCodecDecoderInfo.newInstance(codecName, mimeType, capabilities));
|
||||||
} else if (!secureDecodersExplicit && secure) {
|
} else if (!secureDecodersExplicit && secure) {
|
||||||
decoderInfos.add(DecoderInfo.newInstance(codecName + ".secure", mimeType,
|
decoderInfos.add(MediaCodecDecoderInfo.newInstance(codecName + ".secure",
|
||||||
capabilities));
|
mimeType, capabilities));
|
||||||
// It only makes sense to have one synthesized secure decoder, return immediately.
|
// It only makes sense to have one synthesized secure decoder, return immediately.
|
||||||
return decoderInfos;
|
return decoderInfos;
|
||||||
}
|
}
|
||||||
@ -273,7 +277,7 @@ public final class MediaCodecUtil {
|
|||||||
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
|
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
|
||||||
if (maxH264DecodableFrameSize == -1) {
|
if (maxH264DecodableFrameSize == -1) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
DecoderInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
|
MediaCodecDecoderInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
|
||||||
if (decoderInfo != null) {
|
if (decoderInfo != null) {
|
||||||
for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
|
for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
|
||||||
result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
|
result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
|
||||||
|
@ -173,7 +173,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
if (!MimeTypes.isVideo(mimeType)) {
|
if (!MimeTypes.isVideo(mimeType)) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return FORMAT_UNSUPPORTED_TYPE;
|
||||||
}
|
}
|
||||||
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
MediaCodecDecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
|
||||||
format.requiresSecureDecryption);
|
format.requiresSecureDecryption);
|
||||||
if (decoderInfo == null) {
|
if (decoderInfo == null) {
|
||||||
return FORMAT_UNSUPPORTED_SUBTYPE;
|
return FORMAT_UNSUPPORTED_SUBTYPE;
|
||||||
|
@ -17,9 +17,9 @@ package com.google.android.exoplayer2.playbacktests.gts;
|
|||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.CodecCounters;
|
import com.google.android.exoplayer2.CodecCounters;
|
||||||
import com.google.android.exoplayer2.DecoderInfo;
|
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
|
import com.google.android.exoplayer2.MediaCodecDecoderInfo;
|
||||||
import com.google.android.exoplayer2.MediaCodecUtil;
|
import com.google.android.exoplayer2.MediaCodecUtil;
|
||||||
import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException;
|
import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
@ -365,7 +365,7 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSkipAdaptiveTest(String mimeType) throws DecoderQueryException {
|
private boolean shouldSkipAdaptiveTest(String mimeType) throws DecoderQueryException {
|
||||||
DecoderInfo decoderInfo = MediaCodecUtil.getDecoderInfo(mimeType, false);
|
MediaCodecDecoderInfo decoderInfo = MediaCodecUtil.getDecoderInfo(mimeType, false);
|
||||||
assertNotNull(decoderInfo);
|
assertNotNull(decoderInfo);
|
||||||
if (decoderInfo.adaptive) {
|
if (decoderInfo.adaptive) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user