use of android.media.MediaCodecInfo in project edx-app-android by edx.
the class MediaCodecUtil method isH264ProfileSupported.
/**
* @param profile An AVC profile constant from {@link CodecProfileLevel}.
* @param level An AVC profile level from {@link CodecProfileLevel}.
* @return Whether the specified profile is supported at the specified level.
*/
public static boolean isH264ProfileSupported(int profile, int level) {
Pair<MediaCodecInfo, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264);
if (info == null) {
return false;
}
CodecCapabilities capabilities = info.second;
for (int i = 0; i < capabilities.profileLevels.length; i++) {
CodecProfileLevel profileLevel = capabilities.profileLevels[i];
if (profileLevel.profile == profile && profileLevel.level >= level) {
return true;
}
}
return false;
}
use of android.media.MediaCodecInfo in project edx-app-android by edx.
the class MediaCodecUtil method maxH264DecodableFrameSize.
/**
* @return the maximum frame size for an H264 stream that can be decoded on the device.
*/
public static int maxH264DecodableFrameSize() {
Pair<MediaCodecInfo, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264);
if (info == null) {
return 0;
}
int maxH264DecodableFrameSize = 0;
CodecCapabilities capabilities = info.second;
for (int i = 0; i < capabilities.profileLevels.length; i++) {
CodecProfileLevel profileLevel = capabilities.profileLevels[i];
maxH264DecodableFrameSize = Math.max(avcLevelToMaxFrameSize(profileLevel.level), maxH264DecodableFrameSize);
}
return maxH264DecodableFrameSize;
}
use of android.media.MediaCodecInfo in project LanSoEditor_advance by LanSoSdk.
the class VideoEditor method isSupportNV21ColorFormat.
public static boolean isSupportNV21ColorFormat() {
if (isSupportNV21) {
return true;
}
MediaCodecInfo codecInfo = selectCodec(MIME_TYPE_AVC);
if (codecInfo == null) {
return false;
}
isSupportNV21 = selectColorFormat(codecInfo, MIME_TYPE_AVC);
return isSupportNV21;
}
use of android.media.MediaCodecInfo in project LanSoEditor_advance by LanSoSdk.
the class VideoEditor method selectCodec.
private static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
String[] types = codecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(mimeType)) {
return codecInfo;
}
}
}
return null;
}
use of android.media.MediaCodecInfo in project android_packages_apps_Snap by LineageOS.
the class SettingsManager method getSupportedVideoSize.
private List<String> getSupportedVideoSize(int cameraId) {
StreamConfigurationMap map = mCharacteristics.get(cameraId).get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Size[] sizes = map.getOutputSizes(MediaRecorder.class);
boolean isHeifEnabled = getSavePictureFormat() == HEIF_FORMAT;
VideoCapabilities heifCap = null;
if (isHeifEnabled) {
MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
for (MediaCodecInfo info : list.getCodecInfos()) {
if (info.isEncoder() && info.getName().contains("heic")) {
heifCap = info.getCapabilitiesForType(MediaFormat.MIMETYPE_IMAGE_ANDROID_HEIC).getVideoCapabilities();
Log.d(TAG, "supported heif height range =" + heifCap.getSupportedHeights().toString() + " width range =" + heifCap.getSupportedWidths().toString());
}
}
}
List<String> res = new ArrayList<>();
for (int i = 0; i < sizes.length; i++) {
if (isHeifEnabled && heifCap != null) {
if (!heifCap.getSupportedWidths().contains(sizes[i].getWidth()) || !heifCap.getSupportedHeights().contains(sizes[i].getHeight())) {
continue;
}
}
if (CameraSettings.VIDEO_QUALITY_TABLE.containsKey(sizes[i].toString())) {
Integer profile = CameraSettings.VIDEO_QUALITY_TABLE.get(sizes[i].toString());
if (profile != null && CamcorderProfile.hasProfile(cameraId, profile)) {
res.add(sizes[i].toString());
}
}
}
return res;
}
Aggregations