114 lines
4.3 KiB
Java
114 lines
4.3 KiB
Java
package org.webrtc;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.media.MediaCodecInfo;
|
|
import android.os.Build;
|
|
import androidx.annotation.Nullable;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
public class MediaCodecUtils {
|
|
public static final int COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 2141391876;
|
|
public static final int COLOR_QCOM_FORMATYVU420PackedSemiPlanar16m4ka = 2141391874;
|
|
public static final int COLOR_QCOM_FORMATYVU420PackedSemiPlanar32m4ka = 2141391873;
|
|
public static final int COLOR_QCOM_FORMATYVU420PackedSemiPlanar64x32Tile2m8ka = 2141391875;
|
|
public static final int[] DECODER_COLOR_FORMATS = {19, 21, 2141391872, 2141391873, 2141391874, 2141391875, 2141391876};
|
|
public static final int[] ENCODER_COLOR_FORMATS = {19, 21, 2141391872, 2141391876};
|
|
public static final String EXYNOS_PREFIX = "OMX.Exynos.";
|
|
public static final String INTEL_PREFIX = "OMX.Intel.";
|
|
public static final String NVIDIA_PREFIX = "OMX.Nvidia.";
|
|
public static final String QCOM_PREFIX = "OMX.qcom.";
|
|
public static final String[] SOFTWARE_IMPLEMENTATION_PREFIXES = {"OMX.google.", "OMX.SEC.", "c2.android"};
|
|
private static final String TAG = "MediaCodecUtils";
|
|
public static final int[] TEXTURE_COLOR_FORMATS = getTextureColorFormats();
|
|
|
|
/* renamed from: org.webrtc.MediaCodecUtils$1 reason: invalid class name */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
public static final /* synthetic */ int[] $SwitchMap$org$webrtc$VideoCodecMimeType;
|
|
|
|
static {
|
|
VideoCodecMimeType.values();
|
|
int[] iArr = new int[3];
|
|
$SwitchMap$org$webrtc$VideoCodecMimeType = iArr;
|
|
try {
|
|
iArr[VideoCodecMimeType.VP8.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$org$webrtc$VideoCodecMimeType[VideoCodecMimeType.VP9.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$org$webrtc$VideoCodecMimeType[VideoCodecMimeType.H264.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
}
|
|
}
|
|
|
|
private MediaCodecUtils() {
|
|
}
|
|
|
|
public static boolean codecSupportsType(MediaCodecInfo mediaCodecInfo, VideoCodecMimeType videoCodecMimeType) {
|
|
for (String str : mediaCodecInfo.getSupportedTypes()) {
|
|
if (videoCodecMimeType.mimeType().equals(str)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static Map<String, String> getCodecProperties(VideoCodecMimeType videoCodecMimeType, boolean z2) {
|
|
int ordinal = videoCodecMimeType.ordinal();
|
|
if (ordinal == 0 || ordinal == 1) {
|
|
return new HashMap();
|
|
}
|
|
if (ordinal == 2) {
|
|
return H264Utils.getDefaultH264Params(z2);
|
|
}
|
|
throw new IllegalArgumentException("Unsupported codec: " + videoCodecMimeType);
|
|
}
|
|
|
|
private static int[] getTextureColorFormats() {
|
|
return new int[]{2130708361};
|
|
}
|
|
|
|
public static boolean isHardwareAccelerated(MediaCodecInfo mediaCodecInfo) {
|
|
return Build.VERSION.SDK_INT >= 29 ? isHardwareAcceleratedQOrHigher(mediaCodecInfo) : !isSoftwareOnly(mediaCodecInfo);
|
|
}
|
|
|
|
@TargetApi(29)
|
|
private static boolean isHardwareAcceleratedQOrHigher(MediaCodecInfo mediaCodecInfo) {
|
|
return mediaCodecInfo.isHardwareAccelerated();
|
|
}
|
|
|
|
public static boolean isSoftwareOnly(MediaCodecInfo mediaCodecInfo) {
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
return isSoftwareOnlyQOrHigher(mediaCodecInfo);
|
|
}
|
|
String name = mediaCodecInfo.getName();
|
|
for (String str : SOFTWARE_IMPLEMENTATION_PREFIXES) {
|
|
if (name.startsWith(str)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@TargetApi(29)
|
|
private static boolean isSoftwareOnlyQOrHigher(MediaCodecInfo mediaCodecInfo) {
|
|
return mediaCodecInfo.isSoftwareOnly();
|
|
}
|
|
|
|
@Nullable
|
|
public static Integer selectColorFormat(int[] iArr, MediaCodecInfo.CodecCapabilities codecCapabilities) {
|
|
for (int i : iArr) {
|
|
int[] iArr2 = codecCapabilities.colorFormats;
|
|
for (int i2 : iArr2) {
|
|
if (i2 == i) {
|
|
return Integer.valueOf(i2);
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|