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:
olly 2016-07-11 09:14:17 -07:00 committed by Oliver Woodman
parent fdf26d6a1f
commit bcca373f5b
7 changed files with 53 additions and 47 deletions

View File

@ -148,7 +148,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderInfo() != null) {
return ADAPTIVE_NOT_SEAMLESS | FORMAT_HANDLED;
}
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
MediaCodecDecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
format.requiresSecureDecryption);
if (decoderInfo == null) {
return FORMAT_UNSUPPORTED_SUBTYPE;
@ -164,10 +164,10 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
@Override
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, Format format,
boolean requiresSecureDecoder) throws DecoderQueryException {
protected MediaCodecDecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector,
Format format, boolean requiresSecureDecoder) throws DecoderQueryException {
if (allowPassthrough(format.sampleMimeType)) {
DecoderInfo passthroughDecoderInfo = mediaCodecSelector.getPassthroughDecoderInfo();
MediaCodecDecoderInfo passthroughDecoderInfo = mediaCodecSelector.getPassthroughDecoderInfo();
if (passthroughDecoderInfo != null) {
passthroughEnabled = true;
return passthroughDecoderInfo;

View File

@ -29,7 +29,7 @@ import android.util.Pair;
* Contains information about a media decoder.
*/
@TargetApi(16)
public final class DecoderInfo {
public final class MediaCodecDecoderInfo {
/**
* The name of the decoder.
@ -42,28 +42,28 @@ public final class DecoderInfo {
/**
* Whether the decoder supports seamless resolution switches.
*
* @see android.media.MediaCodecInfo.CodecCapabilities#isFeatureSupported(String)
* @see android.media.MediaCodecInfo.CodecCapabilities#FEATURE_AdaptivePlayback
* @see MediaCodecInfo.CodecCapabilities#isFeatureSupported(String)
* @see MediaCodecInfo.CodecCapabilities#FEATURE_AdaptivePlayback
*/
public final boolean adaptive;
private final String mimeType;
private final CodecCapabilities capabilities;
public static DecoderInfo newPassthroughInstance(String name) {
return new DecoderInfo(name, null, null);
public static MediaCodecDecoderInfo newPassthroughInstance(String name) {
return new MediaCodecDecoderInfo(name, null, null);
}
public static DecoderInfo newInstance(String name, String mimeType,
public static MediaCodecDecoderInfo newInstance(String name, String mimeType,
CodecCapabilities capabilities) {
return new DecoderInfo(name, mimeType, capabilities);
return new MediaCodecDecoderInfo(name, mimeType, capabilities);
}
/**
* @param name The name 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.mimeType = mimeType;
this.capabilities = capabilities;

View File

@ -248,17 +248,17 @@ public abstract class MediaCodecRenderer extends Renderer {
throws DecoderQueryException;
/**
* Returns a {@link DecoderInfo} for a given format.
* Returns a {@link MediaCodecDecoderInfo} for a given format.
*
* @param mediaCodecSelector The decoder selector.
* @param format The format for which a 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
* decoder exists.
* @return A {@link MediaCodecDecoderInfo} describing the decoder to instantiate, or null if no
* suitable decoder exists.
* @throws DecoderQueryException Thrown if there was an error querying decoders.
*/
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, Format format,
boolean requiresSecureDecoder) throws DecoderQueryException {
protected MediaCodecDecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector,
Format format, boolean requiresSecureDecoder) throws DecoderQueryException {
return mediaCodecSelector.getDecoderInfo(format.sampleMimeType, requiresSecureDecoder);
}
@ -301,7 +301,7 @@ public abstract class MediaCodecRenderer extends Renderer {
}
}
DecoderInfo decoderInfo = null;
MediaCodecDecoderInfo decoderInfo = null;
try {
decoderInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
if (decoderInfo == null && drmSessionRequiresSecureDecoder) {

View File

@ -30,13 +30,13 @@ public interface MediaCodecSelector {
MediaCodecSelector DEFAULT = new MediaCodecSelector() {
@Override
public DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
public MediaCodecDecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
throws DecoderQueryException {
return MediaCodecUtil.getDecoderInfo(mimeType, requiresSecureDecoder);
}
@Override
public DecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException {
public MediaCodecDecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException {
return MediaCodecUtil.getPassthroughDecoderInfo();
}
@ -47,18 +47,20 @@ public interface MediaCodecSelector {
*
* @param mimeType The mime type for which a 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.
*/
DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
MediaCodecDecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
throws DecoderQueryException;
/**
* 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.
*/
DecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException;
MediaCodecDecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException;
}

View File

@ -58,14 +58,15 @@ public final class MediaCodecUtil {
}
private static final String TAG = "MediaCodecUtil";
private static final DecoderInfo PASSTHROUGH_DECODER_INFO =
DecoderInfo.newPassthroughInstance("OMX.google.raw.decoder");
private static final MediaCodecDecoderInfo PASSTHROUGH_DECODER_INFO =
MediaCodecDecoderInfo.newPassthroughInstance("OMX.google.raw.decoder");
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_HVC1 = "hvc1";
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.
private static int maxH264DecodableFrameSize = -1;
@ -93,9 +94,10 @@ public final class MediaCodecUtil {
/**
* 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.
return PASSTHROUGH_DECODER_INFO;
}
@ -106,28 +108,29 @@ public final class MediaCodecUtil {
* @param mimeType The mime type.
* @param secure Whether the decoder is required to support secure decryption. Always pass false
* 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 {
List<DecoderInfo> decoderInfos = getDecoderInfos(mimeType, secure);
List<MediaCodecDecoderInfo> decoderInfos = getDecoderInfos(mimeType, secure);
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}.
*
* @param mimeType The mime type.
* @param secure Whether the decoder is required to support secure decryption. Always pass false
* unless secure decryption really is required.
* @return A list of all @{link DecoderInfo}s for the given mime type, in the order given by
* {@link MediaCodecList}.
* @return A list of all @{link MediaCodecDecoderInfo}s for the given mime type, in the order
* given by {@link MediaCodecList}.
*/
public static synchronized List<DecoderInfo> getDecoderInfos(String mimeType, boolean secure)
throws DecoderQueryException {
public static synchronized List<MediaCodecDecoderInfo> getDecoderInfos(String mimeType,
boolean secure) throws DecoderQueryException {
CodecKey key = new CodecKey(mimeType, secure);
List<DecoderInfo> decoderInfos = decoderInfosCache.get(key);
List<MediaCodecDecoderInfo> decoderInfos = decoderInfosCache.get(key);
if (decoderInfos != null) {
return decoderInfos;
}
@ -149,10 +152,10 @@ public final class MediaCodecUtil {
return decoderInfos;
}
private static List<DecoderInfo> getDecoderInfosInternal(
private static List<MediaCodecDecoderInfo> getDecoderInfosInternal(
CodecKey key, MediaCodecListCompat mediaCodecList) throws DecoderQueryException {
try {
List<DecoderInfo> decoderInfos = new ArrayList<>();
List<MediaCodecDecoderInfo> decoderInfos = new ArrayList<>();
String mimeType = key.mimeType;
int numberOfCodecs = mediaCodecList.getCodecCount();
boolean secureDecodersExplicit = mediaCodecList.secureDecodersExplicit();
@ -168,10 +171,11 @@ public final class MediaCodecUtil {
boolean secure = mediaCodecList.isSecurePlaybackSupported(mimeType, capabilities);
if ((secureDecodersExplicit && key.secure == secure)
|| (!secureDecodersExplicit && !key.secure)) {
decoderInfos.add(DecoderInfo.newInstance(codecName, mimeType, capabilities));
decoderInfos.add(
MediaCodecDecoderInfo.newInstance(codecName, mimeType, capabilities));
} else if (!secureDecodersExplicit && secure) {
decoderInfos.add(DecoderInfo.newInstance(codecName + ".secure", mimeType,
capabilities));
decoderInfos.add(MediaCodecDecoderInfo.newInstance(codecName + ".secure",
mimeType, capabilities));
// It only makes sense to have one synthesized secure decoder, return immediately.
return decoderInfos;
}
@ -273,7 +277,7 @@ public final class MediaCodecUtil {
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
if (maxH264DecodableFrameSize == -1) {
int result = 0;
DecoderInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
MediaCodecDecoderInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
if (decoderInfo != null) {
for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);

View File

@ -173,7 +173,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
if (!MimeTypes.isVideo(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
MediaCodecDecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
format.requiresSecureDecryption);
if (decoderInfo == null) {
return FORMAT_UNSUPPORTED_SUBTYPE;

View File

@ -17,9 +17,9 @@ package com.google.android.exoplayer2.playbacktests.gts;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CodecCounters;
import com.google.android.exoplayer2.DecoderInfo;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaCodecDecoderInfo;
import com.google.android.exoplayer2.MediaCodecUtil;
import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException;
import com.google.android.exoplayer2.Renderer;
@ -365,7 +365,7 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
}
private boolean shouldSkipAdaptiveTest(String mimeType) throws DecoderQueryException {
DecoderInfo decoderInfo = MediaCodecUtil.getDecoderInfo(mimeType, false);
MediaCodecDecoderInfo decoderInfo = MediaCodecUtil.getDecoderInfo(mimeType, false);
assertNotNull(decoderInfo);
if (decoderInfo.adaptive) {
return false;