Use Android Q API to test if MediaCodecInfo is HW Accelerated
Also, add the prefix of SW Codecs in Codec2.0. Bug: None Change-Id: Ifc7a079a68506975cd9e52ddaf6da69744ac0614 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177800 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31723}
This commit is contained in:
committed by
Commit Bot
parent
84bb634238
commit
80d2159ff4
@ -10,6 +10,7 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaCodecInfo.CodecCapabilities;
|
||||
import android.os.Build;
|
||||
@ -28,7 +29,8 @@ class MediaCodecUtils {
|
||||
static final String INTEL_PREFIX = "OMX.Intel.";
|
||||
static final String NVIDIA_PREFIX = "OMX.Nvidia.";
|
||||
static final String QCOM_PREFIX = "OMX.qcom.";
|
||||
static final String[] SOFTWARE_IMPLEMENTATION_PREFIXES = {"OMX.google.", "OMX.SEC."};
|
||||
static final String[] SOFTWARE_IMPLEMENTATION_PREFIXES = {
|
||||
"OMX.google.", "OMX.SEC.", "c2.android"};
|
||||
|
||||
// NV12 color format supported by QCOM codec, but not declared in MediaCodec -
|
||||
// see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
|
||||
@ -97,6 +99,36 @@ class MediaCodecUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isHardwareAccelerated(MediaCodecInfo info) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
return isHardwareAcceleratedQOrHigher(info);
|
||||
}
|
||||
return !isSoftwareOnly(info);
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
private static boolean isHardwareAcceleratedQOrHigher(android.media.MediaCodecInfo codecInfo) {
|
||||
return codecInfo.isHardwareAccelerated();
|
||||
}
|
||||
|
||||
static boolean isSoftwareOnly(android.media.MediaCodecInfo codecInfo) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
return isSoftwareOnlyQOrHigher(codecInfo);
|
||||
}
|
||||
String name = codecInfo.getName();
|
||||
for (String prefix : SOFTWARE_IMPLEMENTATION_PREFIXES) {
|
||||
if (name.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
private static boolean isSoftwareOnlyQOrHigher(android.media.MediaCodecInfo codecInfo) {
|
||||
return codecInfo.isSoftwareOnly();
|
||||
}
|
||||
|
||||
private MediaCodecUtils() {
|
||||
// This class should not be instantiated.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user