Skip to content

Commit

Permalink
Merge pull request #60 from anilibria/fix/TR-266-harware-codecs
Browse files Browse the repository at this point in the history
[TR-266] fix: hardware codec on mtk
  • Loading branch information
RadiationX authored Oct 21, 2022
2 parents 94f5843 + 9471886 commit 7565d03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import ru.radiationx.shared_app.codecs.types.KnownCodec
object MediaCodecsFinder {

private val nameRegex by lazy {
Regex("(?:\\w+\\.\\w+\\.([\\w\\.]+?)\\.(?:decoder|encoder)(?:\\.(\\w+))?)")
Regex(
"(?:\\w+\\.\\w+\\.([\\w\\.]+?)\\.(?:decoder|encoder)(?:\\.(\\w+))?)",
RegexOption.IGNORE_CASE
)
}

private val typeRegex by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package ru.radiationx.shared_app.codecs

import android.media.MediaCodecInfo
import android.media.MediaCodecList
import ru.radiationx.shared_app.codecs.types.Codec
import ru.radiationx.shared_app.codecs.types.CodecOutputType
import ru.radiationx.shared_app.codecs.types.CodecProcessingType
import ru.radiationx.shared_app.codecs.types.CodecType
import android.os.Build
import ru.radiationx.shared_app.codecs.types.*

object MediaCodecsProvider {

Expand All @@ -18,7 +16,12 @@ object MediaCodecsProvider {
firstMimeType.startsWith("video") -> CodecOutputType.VIDEO
else -> CodecOutputType.UNKNOWN
}
val processingType = if (isSoftwareCodec(it.name)) {
val isSoftwareCodec = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
!it.isHardwareAccelerated
} else {
isSoftwareCodec(it.name)
}
val processingType = if (isSoftwareCodec) {
CodecProcessingType.SOFTWARE
} else {
CodecProcessingType.HARDWARE
Expand All @@ -40,9 +43,6 @@ object MediaCodecsProvider {
}

private fun isSoftwareCodec(name: String): Boolean {
return name.startsWith("OMX.google.")
|| name.startsWith("c2.android.")
|| (!name.startsWith("OMX.")
&& !name.startsWith("c2."))
return name.startsWith("OMX.google.") || name.startsWith("c2.android.")
}
}

0 comments on commit 7565d03

Please sign in to comment.