|
|
@@ -15,15 +15,19 @@
|
|
|
*/
|
|
|
package com.tencent.qgame.animplayer.util
|
|
|
|
|
|
+import android.media.MediaCodecList
|
|
|
import android.media.MediaExtractor
|
|
|
import android.media.MediaFormat
|
|
|
import com.tencent.qgame.animplayer.Constant
|
|
|
import com.tencent.qgame.animplayer.FileContainer
|
|
|
|
|
|
+
|
|
|
object MediaUtil {
|
|
|
|
|
|
private const val TAG = "${Constant.TAG}.MediaUtil"
|
|
|
|
|
|
+ val isDeviceSupportHevc by lazy { checkCodec("video/hevc") }
|
|
|
+
|
|
|
fun getExtractor(file: FileContainer): MediaExtractor {
|
|
|
val extractor = MediaExtractor()
|
|
|
file.setDataSource(extractor)
|
|
|
@@ -63,4 +67,25 @@ object MediaUtil {
|
|
|
}
|
|
|
return -1
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查设备解码支持类型
|
|
|
+ */
|
|
|
+ private fun checkCodec(mimeType: String): Boolean {
|
|
|
+ val numCodecs = MediaCodecList.getCodecCount()
|
|
|
+ for (i in 0 until numCodecs) {
|
|
|
+ val codecInfo = MediaCodecList.getCodecInfoAt(i)
|
|
|
+ if (!codecInfo.isEncoder) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ val types = codecInfo.supportedTypes
|
|
|
+ for (j in types.indices) {
|
|
|
+ if (types[j].equals(mimeType, ignoreCase = true)) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|