use of android.media.MediaCodecInfo in project aws-sdk-android by aws-amplify.
the class VideoEncoderUtils method getSystemSupportedEncoders.
/**
* @return list of encoders supported by the system
*/
public static List<MediaCodecInfo> getSystemSupportedEncoders() {
final MediaCodecList codecList = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
final List<MediaCodecInfo> codecInfoList = new ArrayList<MediaCodecInfo>();
for (final MediaCodecInfo codecInfo : codecList.getCodecInfos()) {
if (codecInfo.isEncoder()) {
codecInfoList.add(codecInfo);
}
}
return codecInfoList;
}
use of android.media.MediaCodecInfo in project Telegram-FOSS by Telegram-FOSS-Team.
the class MediaController method selectCodec.
@SuppressLint("NewApi")
public static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount();
MediaCodecInfo lastCodecInfo = null;
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
String[] types = codecInfo.getSupportedTypes();
for (String type : types) {
if (type.equalsIgnoreCase(mimeType)) {
lastCodecInfo = codecInfo;
String name = lastCodecInfo.getName();
if (name != null) {
if (!name.equals("OMX.SEC.avc.enc")) {
return lastCodecInfo;
} else if (name.equals("OMX.SEC.AVC.Encoder")) {
return lastCodecInfo;
}
}
}
}
}
return lastCodecInfo;
}
use of android.media.MediaCodecInfo in project Telegram-FOSS by Telegram-FOSS-Team.
the class MediaCodecVideoDecoderFactory method getSupportedCodecs.
@Override
public VideoCodecInfo[] getSupportedCodecs() {
List<VideoCodecInfo> supportedCodecInfos = new ArrayList<VideoCodecInfo>();
// VP8, VP9, H.265(optional), H264 (high profile), and H264 (baseline profile).
for (VideoCodecMimeType type : new VideoCodecMimeType[] { VideoCodecMimeType.VP8, VideoCodecMimeType.VP9, VideoCodecMimeType.H264, VideoCodecMimeType.H265 }) {
MediaCodecInfo codec = findCodecForType(type);
if (codec != null) {
String name = type.name();
if (type == VideoCodecMimeType.H264 && isH264HighProfileSupported(codec)) {
supportedCodecInfos.add(new VideoCodecInfo(name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */
true)));
}
supportedCodecInfos.add(new VideoCodecInfo(name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */
false)));
}
}
return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]);
}
use of android.media.MediaCodecInfo in project Telegram-FOSS by Telegram-FOSS-Team.
the class MediaCodecVideoDecoderFactory method findCodecForType.
@Nullable
private MediaCodecInfo findCodecForType(VideoCodecMimeType type) {
// HW decoding is not supported on builds before KITKAT.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return null;
}
ArrayList<MediaCodecInfo> infos = MediaCodecUtils.getSortedCodecsList();
int codecCount = infos.size();
for (int i = 0; i < codecCount; ++i) {
MediaCodecInfo info = infos.get(i);
if (info == null || info.isEncoder()) {
continue;
}
if (isSupportedCodec(info, type)) {
return info;
}
}
// No support for this type.
return null;
}
use of android.media.MediaCodecInfo in project Telegram-FOSS by Telegram-FOSS-Team.
the class HardwareVideoEncoderFactory method createEncoder.
@Nullable
@Override
public VideoEncoder createEncoder(VideoCodecInfo input) {
// HW encoding is not supported below Android Kitkat.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return null;
}
VideoCodecMimeType type = VideoCodecMimeType.valueOf(input.name);
MediaCodecInfo info = findCodecForType(type);
if (info == null) {
return null;
}
String codecName = info.getName();
String mime = type.mimeType();
Integer surfaceColorFormat = MediaCodecUtils.selectColorFormat(MediaCodecUtils.TEXTURE_COLOR_FORMATS, info.getCapabilitiesForType(mime));
Integer yuvColorFormat = MediaCodecUtils.selectColorFormat(MediaCodecUtils.ENCODER_COLOR_FORMATS, info.getCapabilitiesForType(mime));
if (type == VideoCodecMimeType.H264) {
boolean isHighProfile = H264Utils.isSameH264Profile(input.params, MediaCodecUtils.getCodecProperties(type, /* highProfile= */
true));
boolean isBaselineProfile = H264Utils.isSameH264Profile(input.params, MediaCodecUtils.getCodecProperties(type, /* highProfile= */
false));
if (!isHighProfile && !isBaselineProfile) {
return null;
}
if (isHighProfile && !isH264HighProfileSupported(info)) {
return null;
}
}
return new HardwareVideoEncoder(new MediaCodecWrapperFactoryImpl(), codecName, type, surfaceColorFormat, yuvColorFormat, input.params, getKeyFrameIntervalSec(type), getForcedKeyFrameIntervalMs(type, codecName), createBitrateAdjuster(type, codecName), sharedContext);
}
Aggregations