Search in sources :

Example 21 with CodecCapabilities

use of android.media.MediaCodecInfo.CodecCapabilities in project robolectric by robolectric.

the class MediaCodecInfoBuilderTest method canCreateVideoDecoderCapabilities.

@Test
@Config(minSdk = Q)
public void canCreateVideoDecoderCapabilities() {
    CodecCapabilities codecCapabilities = MediaCodecInfoBuilder.CodecCapabilitiesBuilder.newBuilder().setMediaFormat(VP9_MEDIA_FORMAT).setProfileLevels(VP9_PROFILE_LEVELS).setColorFormats(VP9_COLOR_FORMATS).build();
    assertThat(codecCapabilities.getMimeType()).isEqualTo(MIMETYPE_VIDEO_VP9);
    assertThat(codecCapabilities.getAudioCapabilities()).isNull();
    assertThat(codecCapabilities.getVideoCapabilities()).isNotNull();
    assertThat(codecCapabilities.getEncoderCapabilities()).isNull();
    assertThat(codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_SecurePlayback)).isTrue();
    assertThat(codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_MultipleFrames)).isTrue();
    assertThat(codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_DynamicTimestamp)).isFalse();
    assertThat(codecCapabilities.profileLevels).hasLength(VP9_PROFILE_LEVELS.length);
    assertThat(codecCapabilities.profileLevels).isEqualTo(VP9_PROFILE_LEVELS);
    assertThat(codecCapabilities.colorFormats).hasLength(VP9_COLOR_FORMATS.length);
    assertThat(codecCapabilities.colorFormats).isEqualTo(VP9_COLOR_FORMATS);
}
Also used : CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 22 with CodecCapabilities

use of android.media.MediaCodecInfo.CodecCapabilities in project robolectric by robolectric.

the class MediaCodecInfoBuilderTest method canCreateMediaCodecInfoForEncoder.

@Test
@Config(minSdk = Q)
public void canCreateMediaCodecInfoForEncoder() {
    CodecCapabilities codecCapabilities = MediaCodecInfoBuilder.CodecCapabilitiesBuilder.newBuilder().setMediaFormat(AAC_MEDIA_FORMAT).setIsEncoder(true).setProfileLevels(AAC_PROFILE_LEVELS).build();
    MediaCodecInfo mediaCodecInfo = MediaCodecInfoBuilder.newBuilder().setName(AAC_ENCODER_NAME).setIsEncoder(true).setIsVendor(true).setCapabilities(codecCapabilities).build();
    assertThat(mediaCodecInfo.getName()).isEqualTo(AAC_ENCODER_NAME);
    assertThat(mediaCodecInfo.isEncoder()).isTrue();
    assertThat(mediaCodecInfo.isVendor()).isTrue();
    assertThat(mediaCodecInfo.isSoftwareOnly()).isFalse();
    assertThat(mediaCodecInfo.isHardwareAccelerated()).isFalse();
    assertThat(mediaCodecInfo.getSupportedTypes()).asList().containsExactly(MIMETYPE_AUDIO_AAC);
    assertThat(mediaCodecInfo.getCapabilitiesForType(MIMETYPE_AUDIO_AAC)).isNotNull();
}
Also used : MediaCodecInfo(android.media.MediaCodecInfo) CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 23 with CodecCapabilities

use of android.media.MediaCodecInfo.CodecCapabilities in project robolectric by robolectric.

the class MediaCodecInfoBuilderTest method canCreateVideoEncoderCapabilities.

@Test
@Config(minSdk = Q)
public void canCreateVideoEncoderCapabilities() {
    CodecCapabilities codecCapabilities = MediaCodecInfoBuilder.CodecCapabilitiesBuilder.newBuilder().setMediaFormat(AVC_MEDIA_FORMAT).setIsEncoder(true).setProfileLevels(AVC_PROFILE_LEVELS).setColorFormats(AVC_COLOR_FORMATS).build();
    assertThat(codecCapabilities.getMimeType()).isEqualTo(MIMETYPE_VIDEO_AVC);
    assertThat(codecCapabilities.getAudioCapabilities()).isNull();
    assertThat(codecCapabilities.getVideoCapabilities()).isNotNull();
    assertThat(codecCapabilities.getEncoderCapabilities()).isNotNull();
    assertThat(codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_IntraRefresh)).isTrue();
    assertThat(codecCapabilities.isFeatureSupported(CodecCapabilities.FEATURE_MultipleFrames)).isFalse();
    assertThat(codecCapabilities.profileLevels).hasLength(AVC_PROFILE_LEVELS.length);
    assertThat(codecCapabilities.profileLevels).isEqualTo(AVC_PROFILE_LEVELS);
    assertThat(codecCapabilities.colorFormats).hasLength(AVC_COLOR_FORMATS.length);
    assertThat(codecCapabilities.colorFormats).isEqualTo(AVC_COLOR_FORMATS);
}
Also used : CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 24 with CodecCapabilities

use of android.media.MediaCodecInfo.CodecCapabilities in project robolectric by robolectric.

the class MediaCodecInfoBuilderTest method mediaCodecInfo_preQ.

@Test
@Config(minSdk = LOLLIPOP)
public void mediaCodecInfo_preQ() {
    if (RuntimeEnvironment.getApiLevel() <= M) {
        MediaCodecList.getCodecCount();
    }
    CodecCapabilities codecCapabilities = MediaCodecInfoBuilder.CodecCapabilitiesBuilder.newBuilder().setMediaFormat(AAC_MEDIA_FORMAT).setIsEncoder(true).setProfileLevels(AAC_PROFILE_LEVELS).build();
    MediaCodecInfo mediaCodecInfo = MediaCodecInfoBuilder.newBuilder().setName(AAC_ENCODER_NAME).setIsEncoder(true).setCapabilities(codecCapabilities).build();
    assertThat(mediaCodecInfo.getName()).isEqualTo(AAC_ENCODER_NAME);
    assertThat(mediaCodecInfo.isEncoder()).isTrue();
    assertThat(mediaCodecInfo.getSupportedTypes()).asList().containsExactly(MIMETYPE_AUDIO_AAC);
    assertThat(mediaCodecInfo.getCapabilitiesForType(MIMETYPE_AUDIO_AAC)).isNotNull();
}
Also used : MediaCodecInfo(android.media.MediaCodecInfo) CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 25 with CodecCapabilities

use of android.media.MediaCodecInfo.CodecCapabilities in project ExoPlayer by google.

the class EnumerateDecodersTest method logDecoderInfos.

private void logDecoderInfos(String mimeType, boolean secure, boolean tunneling) throws DecoderQueryException {
    List<MediaCodecInfo> mediaCodecInfos = MediaCodecUtil.getDecoderInfos(mimeType, secure, tunneling);
    for (MediaCodecInfo mediaCodecInfo : mediaCodecInfos) {
        CodecCapabilities capabilities = mediaCodecInfo.capabilities;
        metricsLogger.logMetric("capabilities_" + mediaCodecInfo.name, codecCapabilitiesToString(mimeType, capabilities));
    }
}
Also used : MediaCodecInfo(com.google.android.exoplayer2.mediacodec.MediaCodecInfo) CodecCapabilities(android.media.MediaCodecInfo.CodecCapabilities)

Aggregations

CodecCapabilities (android.media.MediaCodecInfo.CodecCapabilities)28 MediaCodecInfo (android.media.MediaCodecInfo)15 Test (org.junit.Test)11 Config (org.robolectric.annotation.Config)8 CodecProfileLevel (android.media.MediaCodecInfo.CodecProfileLevel)7 Nullable (androidx.annotation.Nullable)6 ArrayList (java.util.ArrayList)5 SparseIntArray (android.util.SparseIntArray)4 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 SuppressLint (android.annotation.SuppressLint)3 Point (android.graphics.Point)3 VideoCapabilities (android.media.MediaCodecInfo.VideoCapabilities)3 MediaCodecList (android.media.MediaCodecList)3 TreeMap (java.util.TreeMap)3 SurfaceTexture (android.graphics.SurfaceTexture)2 MediaFormat (android.media.MediaFormat)2 Handler (android.os.Handler)2 Looper (android.os.Looper)2 SystemClock (android.os.SystemClock)2