Search in sources :

Example 6 with MediaCodecList

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);
}
Also used : MediaCodecList(android.media.MediaCodecList) Test(org.junit.Test)

Example 7 with MediaCodecList

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);
}
Also used : MediaCodecList(android.media.MediaCodecList) Test(org.junit.Test)

Example 8 with MediaCodecList

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();
}
Also used : MediaFormat(android.media.MediaFormat) MediaCodecInfo(android.media.MediaCodecInfo) MediaCodecList(android.media.MediaCodecList) ArrayList(java.util.ArrayList) TargetApi(android.annotation.TargetApi)

Aggregations

MediaCodecList (android.media.MediaCodecList)8 MediaCodecInfo (android.media.MediaCodecInfo)4 Test (org.junit.Test)4 TargetApi (android.annotation.TargetApi)3 MediaFormat (android.media.MediaFormat)2 ArrayList (java.util.ArrayList)2 NonNull (android.support.annotation.NonNull)1 ComplexElement (org.acra.model.ComplexElement)1 JSONObject (org.json.JSONObject)1