Skip to content

Commit

Permalink
fix: clearkey variants.
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jul 28, 2024
1 parent 3ad0fc5 commit 25a2568
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions data/src/main/java/com/m3u/data/database/model/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ data class Channel(
companion object {
const val LICENSE_TYPE_WIDEVINE = "com.widevine.alpha"
const val LICENSE_TYPE_CLEAR_KEY = "clearkey"
const val LICENSE_TYPE_CLEAR_KEY_2 = "org.w3.clearkey"
const val LICENSE_TYPE_PLAY_READY = "com.microsoft.playready"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class PlayerManagerImpl @Inject constructor(
logger.post { "media-source-factory: ${mediaSourceFactory::class.qualifiedName}" }
if (licenseType.isNotEmpty()) {
val drmCallback = when {
(licenseType == Channel.LICENSE_TYPE_CLEAR_KEY) &&
(licenseType in arrayOf(Channel.LICENSE_TYPE_CLEAR_KEY, Channel.LICENSE_TYPE_CLEAR_KEY_2)) &&
!licenseKey.startsWith("http") -> LocalMediaDrmCallback(licenseKey.toByteArray())

else -> HttpMediaDrmCallback(
Expand All @@ -250,15 +250,15 @@ class PlayerManagerImpl @Inject constructor(
)
}
val uuid = when (licenseType) {
Channel.LICENSE_TYPE_CLEAR_KEY -> C.CLEARKEY_UUID
Channel.LICENSE_TYPE_CLEAR_KEY, Channel.LICENSE_TYPE_CLEAR_KEY_2 -> C.CLEARKEY_UUID
Channel.LICENSE_TYPE_WIDEVINE -> C.WIDEVINE_UUID
Channel.LICENSE_TYPE_PLAY_READY -> C.PLAYREADY_UUID
else -> C.UUID_NIL
}
if (uuid != C.UUID_NIL && FrameworkMediaDrm.isCryptoSchemeSupported(uuid)) {
val drmSessionManager = DefaultDrmSessionManager.Builder()
.setUuidAndExoMediaDrmProvider(uuid, FrameworkMediaDrm.DEFAULT_PROVIDER)
.setMultiSession(licenseType != Channel.LICENSE_TYPE_CLEAR_KEY)
.setMultiSession(licenseType !in arrayOf(Channel.LICENSE_TYPE_CLEAR_KEY, Channel.LICENSE_TYPE_CLEAR_KEY_2))
.build(drmCallback)
mediaSourceFactory.setDrmSessionManagerProvider { drmSessionManager }
}
Expand Down

0 comments on commit 25a2568

Please sign in to comment.