Commit 7301b538 by olly Committed by Oliver Woodman

Add MediaCodecSelector.getPassthroughDecoderInfo.

Issue: #1518
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122157463
parent 180d1033
...@@ -170,7 +170,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem ...@@ -170,7 +170,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
if (!MimeTypes.isAudio(mimeType)) { if (!MimeTypes.isAudio(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE; return FORMAT_UNSUPPORTED_TYPE;
} }
if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderName() != null) { if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderInfo() != null) {
return ADAPTIVE_NOT_SEAMLESS | FORMAT_HANDLED; return ADAPTIVE_NOT_SEAMLESS | FORMAT_HANDLED;
} }
// TODO[REFACTOR]: If requiresSecureDecryption then we should probably also check that the // TODO[REFACTOR]: If requiresSecureDecryption then we should probably also check that the
...@@ -194,10 +194,10 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem ...@@ -194,10 +194,10 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, Format format, protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, Format format,
boolean requiresSecureDecoder) throws DecoderQueryException { boolean requiresSecureDecoder) throws DecoderQueryException {
if (allowPassthrough(format.sampleMimeType)) { if (allowPassthrough(format.sampleMimeType)) {
String passthroughDecoderName = mediaCodecSelector.getPassthroughDecoderName(); DecoderInfo passthroughDecoderInfo = mediaCodecSelector.getPassthroughDecoderInfo();
if (passthroughDecoderName != null) { if (passthroughDecoderInfo != null) {
passthroughEnabled = true; passthroughEnabled = true;
return new DecoderInfo(passthroughDecoderName); return passthroughDecoderInfo;
} }
} }
passthroughEnabled = false; passthroughEnabled = false;
......
...@@ -29,11 +29,6 @@ public interface MediaCodecSelector { ...@@ -29,11 +29,6 @@ public interface MediaCodecSelector {
*/ */
MediaCodecSelector DEFAULT = new MediaCodecSelector() { MediaCodecSelector DEFAULT = new MediaCodecSelector() {
/**
* The name for the raw (passthrough) decoder OMX component.
*/
private static final String RAW_DECODER_NAME = "OMX.google.raw.decoder";
@Override @Override
public DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder) public DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
throws DecoderQueryException { throws DecoderQueryException {
...@@ -41,9 +36,8 @@ public interface MediaCodecSelector { ...@@ -41,9 +36,8 @@ public interface MediaCodecSelector {
} }
@Override @Override
public String getPassthroughDecoderName() throws DecoderQueryException { public DecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException {
// TODO: Return null if the raw decoder doesn't exist. return MediaCodecUtil.getPassthroughDecoderInfo();
return RAW_DECODER_NAME;
} }
}; };
...@@ -53,20 +47,18 @@ public interface MediaCodecSelector { ...@@ -53,20 +47,18 @@ 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 to instantiate, or null if no suitable * @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
* 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) DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
throws DecoderQueryException; throws DecoderQueryException;
/** /**
* Gets the name of a decoder suitable for audio passthrough. * Selects a decoder to instantiate for audio passthrough.
* *
* @return The name of a decoder suitable for audio passthrough, or null if no suitable decoder * @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
* exists.
* @throws DecoderQueryException Thrown if there was an error querying decoders. * @throws DecoderQueryException Thrown if there was an error querying decoders.
*/ */
String getPassthroughDecoderName() throws DecoderQueryException; DecoderInfo getPassthroughDecoderInfo() throws DecoderQueryException;
} }
...@@ -52,6 +52,8 @@ public final class MediaCodecUtil { ...@@ -52,6 +52,8 @@ public final class MediaCodecUtil {
} }
private static final String TAG = "MediaCodecUtil"; private static final String TAG = "MediaCodecUtil";
private static final DecoderInfo PASSTHROUGH_DECODER_INFO =
new DecoderInfo("OMX.google.raw.decoder", null);
private static final HashMap<CodecKey, List<DecoderInfo>> decoderInfosCache = new HashMap<>(); private static final HashMap<CodecKey, List<DecoderInfo>> decoderInfosCache = new HashMap<>();
...@@ -79,12 +81,22 @@ public final class MediaCodecUtil { ...@@ -79,12 +81,22 @@ public final class MediaCodecUtil {
} }
/** /**
* Returns information about the decoder that will be used for a given mime type. * Returns information about a decoder suitable for audio passthrough.
**
* @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
*/
public static DecoderInfo getPassthroughDecoderInfo() {
// TODO: Return null if the raw decoder doesn't exist.
return PASSTHROUGH_DECODER_INFO;
}
/**
* Returns information about the preferred decoder for a given mime type.
* *
* @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 Information about the decoder that will be used, or null if no decoder exists. * @return A {@link DecoderInfo} describing the decoder, or null if no suitable decoder exists.
*/ */
public static DecoderInfo getDecoderInfo(String mimeType, boolean secure) public static DecoderInfo getDecoderInfo(String mimeType, boolean secure)
throws DecoderQueryException { throws DecoderQueryException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment