mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Check full format support in decoder for Transformer
For the case where a hardware decoder does not fully support the requested format, a software decoder will be preferred. PiperOrigin-RevId: 717584768
This commit is contained in:
parent
6fe011beb4
commit
7c10ef03e4
@ -256,6 +256,26 @@ public final class MediaCodecUtil {
|
||||
return decoderInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the provided decoder list sorted such that decoders with complete format
|
||||
* support are listed first. The returned list is modifiable for convenience.
|
||||
*/
|
||||
@CheckResult
|
||||
public static List<MediaCodecInfo> getDecoderInfosSortedByFullFormatSupport(
|
||||
List<MediaCodecInfo> decoderInfos, Format format) {
|
||||
decoderInfos = new ArrayList<>(decoderInfos);
|
||||
sortByScore(
|
||||
decoderInfos,
|
||||
decoderInfo -> {
|
||||
try {
|
||||
return decoderInfo.isFormatSupported(format) ? 1 : 0;
|
||||
} catch (DecoderQueryException e) {
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
return decoderInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the provided decoder list sorted such that software decoders are listed
|
||||
* first. Break ties by listing non-{@link MediaCodecInfo#vendor} decoders first, due to issues
|
||||
|
@ -1400,7 +1400,7 @@ public final class AndroidTestUtil {
|
||||
private static String findDecoderForFormat(Format format)
|
||||
throws MediaCodecUtil.DecoderQueryException {
|
||||
List<androidx.media3.exoplayer.mediacodec.MediaCodecInfo> decoderInfoList =
|
||||
MediaCodecUtil.getDecoderInfosSortedByFormatSupport(
|
||||
MediaCodecUtil.getDecoderInfosSortedByFullFormatSupport(
|
||||
MediaCodecUtil.getDecoderInfosSoftMatch(
|
||||
MediaCodecSelector.DEFAULT,
|
||||
format,
|
||||
|
@ -312,7 +312,7 @@ public final class DefaultDecoderFactory implements Codec.DecoderFactory {
|
||||
checkNotNull(format.sampleMimeType);
|
||||
try {
|
||||
decoderInfos =
|
||||
MediaCodecUtil.getDecoderInfosSortedByFormatSupport(
|
||||
MediaCodecUtil.getDecoderInfosSortedByFullFormatSupport(
|
||||
MediaCodecUtil.getDecoderInfosSoftMatch(
|
||||
mediaCodecSelector,
|
||||
format,
|
||||
|
Loading…
x
Reference in New Issue
Block a user