Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only DirectPlay hardware-accelerated video codecs for ExoPlayer #1391

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jellyfin.mobile.player.deviceprofile

import android.media.MediaCodecInfo
import android.media.MediaCodecList
import android.os.Build
import org.jellyfin.mobile.app.AppPreferences
import org.jellyfin.mobile.utils.Constants
import org.jellyfin.sdk.model.api.CodecProfile
Expand All @@ -11,6 +13,7 @@ import org.jellyfin.sdk.model.api.DlnaProfileType
import org.jellyfin.sdk.model.api.SubtitleDeliveryMethod
import org.jellyfin.sdk.model.api.SubtitleProfile
import org.jellyfin.sdk.model.api.TranscodingProfile
import java.util.Locale

class DeviceProfileBuilder(
private val appPreferences: AppPreferences,
Expand All @@ -37,6 +40,9 @@ class DeviceProfileBuilder(
val name = codec.name
when (codec) {
is DeviceCodec.Video -> {
if (isSoftwareOnly(codecInfo)) {
continue
}
if (videoCodecs.containsKey(name)) {
videoCodecs[name] = videoCodecs[name]!!.mergeCodec(codec)
} else {
Expand Down Expand Up @@ -158,6 +164,54 @@ class DeviceProfileBuilder(
}
}

// taken from https://github.com/Parseus/codecinfo
private fun isSoftwareOnly(codecInfo: MediaCodecInfo): Boolean {
if (Build.VERSION.SDK_INT >= 29) {
return codecInfo.isSoftwareOnly
}

val codecName = codecInfo.name.lowercase(Locale.ENGLISH)

// Broadcom codecs which specifically mention HW acceleration in their names
if (codecName.contains("omx.brcm.video", true) && codecName.contains("hw", true)) {
return false
}

// Marvell codecs which specifically mention HW acceleration in their names
if (codecName.startsWith("omx.marvell.video.hw", true)) {
return false
}

// Intel codecs which specifically mention HW acceleration in their names
if (codecName.startsWith("omx.intel.hw_vd", true)) {
return false
}

// Qualcomm codecs which specifically mention HW acceleration in their names
if (codecName.startsWith("omx.qcom") && codecName.endsWith("hw")) {
return false
}

// ARC/ARC++ (App Runtime for Chrome) codecs are always HW-only.
if (codecName.startsWith("c2.vda.arc") || codecName.startsWith("arc.")) {
return false
}

return codecName.startsWith("omx.google.")
|| codecName.contains("ffmpeg") // either OMX.ffmpeg or OMX.k3.ffmpeg
|| (codecName.startsWith("omx.sec.") && codecName.contains(".sw."))
|| codecName == "omx.qcom.video.decoder.hevcswvdec"
|| codecName.startsWith("c2.android.")
|| codecName.startsWith("c2.google.")
|| codecName.startsWith("omx.sprd.soft.")
|| codecName.startsWith("omx.avcodec.")
|| codecName.startsWith("omx.pv")
|| codecName.endsWith("sw", true)
|| codecName.endsWith("sw.dec", true)
|| codecName.contains("sw_vd", true)
|| (!codecName.startsWith("omx.") && !codecName.startsWith("c2."))
}

fun getExternalPlayerProfile(): DeviceProfile = DeviceProfile(
name = EXTERNAL_PLAYER_PROFILE_NAME,
directPlayProfiles = listOf(
Expand Down