Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun isSoftwareOnly(codecInfo: MediaCodecInfo): Boolean {
- if (SDK_INT >= Q) {
- return codecInfo.isSoftwareOnly
- }
- val codecName = codecInfo.name.toLowerCase(Locale.ENGLISH)
- // Some Broadcom codecs specifically mention HW acceleration in their names.
- if (codecName.contains("omx.brcm.video", true) && codecName.contains("hw", true)) {
- return false
- }
- // ARC++ (App Runtime for Chrome) codecs, which are always HW-accelerated.
- // c2.vda.arc.* appears on Chromebooks with a newer ARC++ version
- // based on Android 9.0 and arc.* appears on the older, Android 7.1.1-based version.
- if (codecName.startsWith("c2.vda.arc") || codecName.startsWith("arc.")) {
- return false
- }
- return codecName.startsWith("omx.google.")
- || codecName.startsWith("omx.ffmpeg.")
- || (codecName.startsWith("omx.sec.") && codecName.contains(".sw."))
- || codecName == "omx.qcom.video.decoder.hevcswvdec"
- || codecName.startsWith("c2.android.")
- || codecName.startsWith("c2.google.")
- || codecName.endsWith("sw", true)
- || codecName.endsWith("sw.dec", true)
- || codecName.contains("sw_vd", true)
- || (!codecName.startsWith("omx.") && !codecName.startsWith("c2."))
- }
- private fun isHardwareAccelerated(codecInfo: MediaCodecInfo): Boolean {
- return if (SDK_INT >= Q) {
- codecInfo.isHardwareAccelerated
- } else {
- !isSoftwareOnly(codecInfo)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement