Added in API level 16

MediaCrypto


class MediaCrypto
kotlin.Any
   ↳ android.media.MediaCrypto

MediaCrypto class can be used in conjunction with android.media.MediaCodec to decode encrypted media data. Crypto schemes are assigned 16 byte UUIDs, the method isCryptoSchemeSupported can be used to query if a given scheme is supported on the device.

Summary

Public constructors
MediaCrypto(uuid: UUID, sessionId: ByteArray)

Instantiate a MediaCrypto object and associate it with a MediaDrm session

Public methods
static Boolean

Query if the given scheme identified by its UUID is supported on this device.

Unit

Boolean

Query if the crypto scheme requires the use of a secure decoder to decode data of the given mime type.

Unit

Associate a new MediaDrm session with this MediaCrypto instance.

Protected methods
Unit

Public constructors

MediaCrypto

Added in API level 16
MediaCrypto(
    uuid: UUID,
    sessionId: ByteArray)

Instantiate a MediaCrypto object and associate it with a MediaDrm session

Parameters
uuid UUID: The UUID of the crypto scheme. This value cannot be null.
sessionId ByteArray: The MediaDrm sessionId to associate with this MediaCrypto session. The sessionId may be changed after the MediaCrypto is created using setMediaDrmSession This value cannot be null.

Public methods

isCryptoSchemeSupported

Added in API level 16
static fun isCryptoSchemeSupported(uuid: UUID): Boolean

Query if the given scheme identified by its UUID is supported on this device.

Parameters
uuid UUID: The UUID of the crypto scheme. This value cannot be null.

release

Added in API level 16
fun release(): Unit

requiresSecureDecoderComponent

Added in API level 16
fun requiresSecureDecoderComponent(mime: String): Boolean

Query if the crypto scheme requires the use of a secure decoder to decode data of the given mime type.

Parameters
mime String: The mime type of the media data This value cannot be null.

setMediaDrmSession

Added in API level 23
fun setMediaDrmSession(sessionId: ByteArray): Unit

Associate a new MediaDrm session with this MediaCrypto instance.

The MediaDrm session is used to securely load decryption keys for a crypto scheme. The crypto keys loaded through the MediaDrm session may be selected for use during the decryption operation performed by android.media.MediaCodec#queueSecureInputBuffer by specifying their key IDs in the android.media.MediaCodec.CryptoInfo#key field.

Parameters
sessionId ByteArray: The MediaDrm sessionId to associate with this MediaCrypto instance. The session's scheme must match the scheme UUID used when constructing this MediaCrypto instance. This value cannot be null.
Exceptions
android.media.MediaCryptoException on failure to set the sessionId

Protected methods

finalize

Added in API level 16
protected fun finalize(): Unit
Exceptions
java.lang.Throwable the Exception raised by this method