Fallback to matching video decoder by MIME type.

This commit is contained in:
Nicholas Tinsley 2024-02-15 17:03:45 -05:00 committed by Greyson Parrelli
parent 9dc856202a
commit fc1d60e65b

View file

@ -39,6 +39,13 @@ object MediaCodecCompat {
} else {
findBackupDecoderForDolbyVision(inputFormat) ?: throw IOException("Can't create decoder for $mimeType!")
}
} else if (mimeType != null) {
try {
val decoder = MediaCodec.createDecoderByType(mimeType)
return Pair(decoder, inputFormat)
} catch (iae: IllegalArgumentException) {
throw IOException("Can't create decoder for $mimeType, which is not a valid MIME type.", iae)
}
}
throw IOException("Can't create decoder for $mimeType!")