Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java

Issue 2084143002: Make AVDA fall back to software decoding if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: symbolic constants, coments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
index 5bda3df60c9b0e6abe2797e20d21738b4b17f1a5..b03f216806206ea9d5e15decf12ae2cf21cf7177 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
@@ -83,10 +83,11 @@ class MediaCodecUtil {
* Get a name of default android codec.
* @param mime MIME type of the media.
* @param direction Whether this is encoder or decoder.
+ * @param requireSoftware Whether we require a software codec.
DaleCurtis 2016/06/21 21:17:56 requireSoftwareCodec is probably a better name.
liberato (no reviews please) 2016/06/22 17:56:13 Done.
* @return name of the codec.
*/
@CalledByNative
- private static String getDefaultCodecName(String mime, int direction) {
+ private static String getDefaultCodecName(String mime, int direction, boolean requireSoftware) {
MediaCodecListHelper codecListHelper = new MediaCodecListHelper();
int codecCount = codecListHelper.getCodecCount();
for (int i = 0; i < codecCount; ++i) {
@@ -95,6 +96,8 @@ class MediaCodecUtil {
int codecDirection = info.isEncoder() ? MEDIA_CODEC_ENCODER : MEDIA_CODEC_DECODER;
if (codecDirection != direction) continue;
+ if (requireSoftware && !info.getName().startsWith("OMX.google")) continue;
DaleCurtis 2016/06/21 21:17:56 Does this exist on Samsung phones? The samsung one
liberato (no reviews please) 2016/06/22 17:56:13 according to this: http://androidxref.com/6.0.1_r
+
String[] supportedTypes = info.getSupportedTypes();
for (int j = 0; j < supportedTypes.length; ++j) {
if (supportedTypes[j].equalsIgnoreCase(mime)) return info.getName();
@@ -136,7 +139,8 @@ class MediaCodecUtil {
*/
@CalledByNative
private static boolean canDecode(String mime, boolean isSecure) {
- CodecCreationInfo info = createDecoder(mime, isSecure);
+ // TODO(liberato): Should we insist on software here?
+ CodecCreationInfo info = createDecoder(mime, isSecure, false);
if (info.mediaCodec == null) return false;
try {
@@ -151,9 +155,10 @@ class MediaCodecUtil {
* Creates MediaCodec decoder.
* @param mime MIME type of the media.
* @param secure Whether secure decoder is required.
+ * @param requireSoftware Whether a software decoder is required.
* @return CodecCreationInfo object
*/
- static CodecCreationInfo createDecoder(String mime, boolean isSecure) {
+ static CodecCreationInfo createDecoder(String mime, boolean isSecure, boolean requireSoftware) {
// Always return a valid CodecCreationInfo, its |mediaCodec| field will be null
// if we cannot create the codec.
CodecCreationInfo result = new CodecCreationInfo();
@@ -173,7 +178,8 @@ class MediaCodecUtil {
try {
// |isSecure| only applies to video decoders.
if (mime.startsWith("video") && isSecure) {
- String decoderName = getDefaultCodecName(mime, MEDIA_CODEC_DECODER);
+ String decoderName =
+ getDefaultCodecName(mime, MEDIA_CODEC_DECODER, requireSoftware);
if (decoderName.equals("")) return null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// To work around an issue that we cannot get the codec info from the secure
@@ -188,12 +194,19 @@ class MediaCodecUtil {
}
result.mediaCodec = MediaCodec.createByCodecName(decoderName + ".secure");
} else {
- result.mediaCodec = MediaCodec.createDecoderByType(mime);
+ if (requireSoftware) {
+ String decoderName =
+ getDefaultCodecName(mime, MEDIA_CODEC_DECODER, requireSoftware);
+ result.mediaCodec = MediaCodec.createByCodecName(decoderName);
+ } else {
+ result.mediaCodec = MediaCodec.createDecoderByType(mime);
+ }
result.supportsAdaptivePlayback =
codecSupportsAdaptivePlayback(result.mediaCodec, mime);
}
} catch (Exception e) {
- Log.e(TAG, "Failed to create MediaCodec: %s, isSecure: %s", mime, isSecure, e);
+ Log.e(TAG, "Failed to create MediaCodec: %s, isSecure: %s, requireSoftware: %d", mime,
+ isSecure, requireSoftware, e);
result.mediaCodec = null;
}
return result;

Powered by Google App Engine
This is Rietveld 408576698