use of android.media.MediaCodecList in project acra by ACRA.
the class MediaCodecListCollector method collectMediaCodecList.
/**
* Builds an Element describing the list of available codecs on the device
* with their capabilities (supported Color Formats, Codec Profiles et
* Levels).
*
* @return The media codecs information
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@NonNull
private Element collectMediaCodecList() throws JSONException {
prepare();
final MediaCodecInfo[] infos;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
//noinspection deprecation
final int codecCount = MediaCodecList.getCodecCount();
infos = new MediaCodecInfo[codecCount];
for (int codecIdx = 0; codecIdx < codecCount; codecIdx++) {
//noinspection deprecation
infos[codecIdx] = MediaCodecList.getCodecInfoAt(codecIdx);
}
} else {
infos = new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos();
}
final ComplexElement result = new ComplexElement();
for (int i = 0; i < infos.length; i++) {
final MediaCodecInfo codecInfo = infos[i];
JSONObject codec = new JSONObject();
final String[] supportedTypes = codecInfo.getSupportedTypes();
codec.put("name", codecInfo.getName()).put("isEncoder", codecInfo.isEncoder());
JSONObject supportedTypesJson = new JSONObject();
for (String type : supportedTypes) {
supportedTypesJson.put(type, collectCapabilitiesForType(codecInfo, type));
}
codec.put("supportedTypes", supportedTypesJson);
result.put(String.valueOf(i), codec);
}
return result;
}
use of android.media.MediaCodecList in project speechutils by Kaljurand.
the class AudioUtils method getAvailableEncoders.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
String encoderAsStr = mcl.findEncoderForFormat(format);
List<String> encoders = new ArrayList<>();
for (MediaCodecInfo info : mcl.getCodecInfos()) {
if (info.isEncoder()) {
if (info.getName().equals(encoderAsStr)) {
encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
} else {
encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
}
}
}
return encoders;
}
return Collections.emptyList();
}
use of android.media.MediaCodecList in project robolectric by robolectric.
the class ShadowMediaCodecListTest method aacEncoderInfo.
@Test
public void aacEncoderInfo() {
MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
assertThat(mediaCodecList.getCodecInfos()[0]).isEqualTo(AAC_ENCODER_INFO);
}
use of android.media.MediaCodecList in project ExoPlayer by google.
the class EncoderUtil method maybePopulateEncoderInfos.
private static synchronized void maybePopulateEncoderInfos() {
if (encoders.isEmpty()) {
MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
MediaCodecInfo[] allCodecInfos = mediaCodecList.getCodecInfos();
for (MediaCodecInfo mediaCodecInfo : allCodecInfos) {
if (!mediaCodecInfo.isEncoder()) {
continue;
}
encoders.add(mediaCodecInfo);
}
}
}
use of android.media.MediaCodecList in project speechutils by Kaljurand.
the class AudioUtils method getAvailableEncoders.
// TODO: use MediaFormat.MIMETYPE_AUDIO_FLAC) on API>=21
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(String mime, int sampleRate) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
MediaFormat format = MediaFormatFactory.createMediaFormat(mime, sampleRate);
MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
String encoderAsStr = mcl.findEncoderForFormat(format);
List<String> encoders = new ArrayList<>();
for (MediaCodecInfo info : mcl.getCodecInfos()) {
if (info.isEncoder()) {
String name = info.getName();
String infoAsStr = name + ": " + TextUtils.join(", ", info.getSupportedTypes());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
infoAsStr += String.format(": %s/%s/%s/%s", info.isHardwareAccelerated(), info.isSoftwareOnly(), info.isAlias(), info.isVendor());
}
if (name.equals(encoderAsStr)) {
infoAsStr = '#' + infoAsStr;
}
encoders.add(infoAsStr);
}
}
return encoders;
}
return Collections.emptyList();
}
Aggregations