Skip to content

Commit

Permalink
Fix h264 and h265 MIME-Types not recognized
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Jul 21, 2023
1 parent 1cf2903 commit f2e9cad
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ class DeviceProfileBuilder(

@RequiresApi(Build.VERSION_CODES.Q)
fun canHardwareDecode(codec: String): Boolean {
var parsedCodec = codec
if (parsedCodec == "av1") parsedCodec = "av01"
val mimeType = MimeTypes.getMediaMimeType(parsedCodec) ?: return false
val parsedCodec = when(codec) {
"av1" -> "av01"
"h264" -> "avc1"
"h265" -> "hvc1"
else -> codec
}
val mimeType = MimeTypes.getVideoMediaMimeType(parsedCodec) ?: return false
val hardwareCodec = MediaCodecList(MediaCodecList.REGULAR_CODECS).codecInfos
.filter { it.isHardwareAccelerated }
.find { it.supportedTypes.contains(mimeType) }
Expand Down

0 comments on commit f2e9cad

Please sign in to comment.