use of android.media.MediaCodecInfo in project robolectric by robolectric.
the class MediaCodecInfoBuilderTest method canCreateMediaCodecInfoWithMultipleFormats.
@Test
@Config(minSdk = Q)
public void canCreateMediaCodecInfoWithMultipleFormats() {
CodecCapabilities avcEncoderCapabilities = MediaCodecInfoBuilder.CodecCapabilitiesBuilder.newBuilder().setMediaFormat(AVC_MEDIA_FORMAT).setIsEncoder(true).setProfileLevels(AVC_PROFILE_LEVELS).setColorFormats(AVC_COLOR_FORMATS).build();
CodecCapabilities vp9EncoderCapabilities = MediaCodecInfoBuilder.CodecCapabilitiesBuilder.newBuilder().setMediaFormat(VP9_MEDIA_FORMAT).setIsEncoder(true).setProfileLevels(VP9_PROFILE_LEVELS).setColorFormats(VP9_COLOR_FORMATS).build();
MediaCodecInfo mediaCodecInfo = MediaCodecInfoBuilder.newBuilder().setName(MULTIFORMAT_ENCODER_NAME).setIsEncoder(true).setCapabilities(avcEncoderCapabilities, vp9EncoderCapabilities).build();
assertThat(mediaCodecInfo.getName()).isEqualTo(MULTIFORMAT_ENCODER_NAME);
assertThat(mediaCodecInfo.isEncoder()).isTrue();
assertThat(mediaCodecInfo.isVendor()).isFalse();
assertThat(mediaCodecInfo.isSoftwareOnly()).isFalse();
assertThat(mediaCodecInfo.isHardwareAccelerated()).isFalse();
assertThat(mediaCodecInfo.getSupportedTypes()).asList().contains(MIMETYPE_VIDEO_AVC);
assertThat(mediaCodecInfo.getSupportedTypes()).asList().contains(MIMETYPE_VIDEO_VP9);
assertThat(mediaCodecInfo.getCapabilitiesForType(MIMETYPE_VIDEO_AVC)).isNotNull();
assertThat(mediaCodecInfo.getCapabilitiesForType(MIMETYPE_VIDEO_VP9)).isNotNull();
}
use of android.media.MediaCodecInfo 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();
}
use of android.media.MediaCodecInfo 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();
}
use of android.media.MediaCodecInfo in project ExoPlayer by google.
the class EncoderUtil method getSupportedEncoders.
/**
* Returns a list of {@link MediaCodecInfo encoders} that support the given {@code mimeType}, or
* an empty list if there is none.
*/
public static ImmutableList<MediaCodecInfo> getSupportedEncoders(String mimeType) {
maybePopulateEncoderInfos();
ImmutableList.Builder<MediaCodecInfo> availableEncoders = new ImmutableList.Builder<>();
for (int i = 0; i < encoders.size(); i++) {
MediaCodecInfo encoderInfo = encoders.get(i);
String[] supportedMimeTypes = encoderInfo.getSupportedTypes();
for (String supportedMimeType : supportedMimeTypes) {
if (Ascii.equalsIgnoreCase(supportedMimeType, mimeType)) {
availableEncoders.add(encoderInfo);
}
}
}
return availableEncoders.build();
}
use of android.media.MediaCodecInfo in project robolectric by robolectric.
the class ShadowMediaCodec method __constructor__.
// Member methods.
@Implementation
protected void __constructor__(String name, boolean nameIsType, boolean encoder) {
invokeConstructor(MediaCodec.class, realCodec, ClassParameter.from(String.class, name), ClassParameter.from(boolean.class, nameIsType), ClassParameter.from(boolean.class, encoder));
if (!nameIsType) {
for (MediaCodecInfo codecInfo : new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos()) {
if (codecInfo.getName().equals(name)) {
encoder = codecInfo.isEncoder();
break;
}
}
}
CodecConfig codecConfig = encoder ? encoders.getOrDefault(name, DEFAULT_CODEC) : decoders.getOrDefault(name, DEFAULT_CODEC);
fakeCodec = codecConfig.codec;
for (int i = 0; i < BUFFER_COUNT; i++) {
inputBuffers[i] = ByteBuffer.allocateDirect(codecConfig.inputBufferSize).order(ByteOrder.LITTLE_ENDIAN);
outputBuffers[i] = ByteBuffer.allocateDirect(codecConfig.outputBufferSize).order(ByteOrder.LITTLE_ENDIAN);
outputBufferInfos[i] = new BufferInfo();
}
}
Aggregations