use of android.media.MediaCodecList in project robolectric by robolectric.
the class ShadowMediaCodecListTest method getCodecInfosLength.
@Test
public void getCodecInfosLength() {
MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
assertThat(mediaCodecList.getCodecInfos()).hasLength(2);
}
use of android.media.MediaCodecList in project robolectric by robolectric.
the class ShadowMediaCodecListTest method testReset.
@Test
public void testReset() {
ShadowMediaCodecList.reset();
MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
assertThat(mediaCodecList.getCodecInfos()).hasLength(0);
}
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