ExoMediaDrm
@UnstableApi
interface ExoMediaDrm
DummyExoMediaDrm |
An |
FakeExoMediaDrm |
A fake implementation of |
FrameworkMediaDrm |
An |
Used to obtain keys for decrypting protected media streams.
Reference counting
Access to an instance is managed by reference counting, where acquire increments the reference count and release decrements it. When the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.
Each new instance has an initial reference count of 1. Hence application code that creates a new instance does not normally need to call acquire, and must call release when the instance is no longer required.
| See also | |
|---|---|
MediaDrm |
Summary
Nested types |
|---|
|
Provides an |
class ExoMediaDrm.KeyRequestContains data used to request keys from a license server. |
@DocumentedKey request types. |
class ExoMediaDrm.KeyStatusDefines the status of a key. |
interface ExoMediaDrm.OnEventListenerCalled when a DRM event occurs. |
interface ExoMediaDrm.OnExpirationUpdateListenerCalled when a session expiration update occurs. |
interface ExoMediaDrm.OnKeyStatusChangeListenerCalled when the keys in a DRM session change state. |
interface ExoMediaDrm.ProviderProvider for |
|
Contains data to request a certificate from a provisioning server. |
Constants |
|
|---|---|
const Int |
Event indicating that keys have expired, and are no longer usable. |
const Int |
Event indicating that keys need to be requested from the license server. |
const Int |
Event indicating that a certificate needs to be requested from the provisioning server. |
const Int |
Key request type for keys that will be used for offline use. |
const Int |
Key request type indicating that saved offline keys should be released. |
const Int |
Key request type for keys that will be used for online use. |
Public functions |
|
|---|---|
Unit |
acquire()Increments the reference count. |
Unit |
closeSession(sessionId: ByteArray!)Closes a DRM session. |
CryptoConfig! |
createCryptoConfig(sessionId: ByteArray!)Creates a |
Int |
Returns the |
ExoMediaDrm.KeyRequest! |
getKeyRequest(Generates a key request. |
PersistableBundle? |
Returns metrics data for this ExoMediaDrm instance, or |
(Mutable)List<ByteArray<Byte>!>! |
Returns a list of the |
ByteArray<Byte>! |
getPropertyByteArray(propertyName: String!)Returns the value of a byte array property. |
String! |
getPropertyString(propertyName: String!)Returns the value of a string property. |
ExoMediaDrm.ProvisionRequest! |
Generates a provisioning request. |
ByteArray<Byte>! |
Opens a new DRM session. |
ByteArray<Byte>? |
provideKeyResponse(scope: ByteArray!, response: ByteArray!)Provides a key response for the last request to be generated using |
Unit |
provideProvisionResponse(response: ByteArray!)Provides a provisioning response for the last request to be generated using |
(Mutable)Map<String!, String!>! |
queryKeyStatus(sessionId: ByteArray!)Returns the key status for a given session, as {name, value} pairs. |
Unit |
release()Decrements the reference count. |
Unit |
removeOfflineLicense(keySetId: ByteArray!)Removes an offline license. |
Boolean |
requiresSecureDecoder(sessionId: ByteArray!, mimeType: String!)Returns whether the given session requires use of a secure decoder for the given MIME type. |
Unit |
restoreKeys(sessionId: ByteArray!, keySetId: ByteArray!)Restores persisted offline keys into a session. |
Unit |
setOnEventListener(listener: ExoMediaDrm.OnEventListener?)Sets the listener for DRM events. |
Unit |
Sets the listener for session expiration events. |
Unit |
Sets the listener for key status change events. |
Unit |
setPlayerIdForSession(sessionId: ByteArray!, playerId: PlayerId!)Sets the |
Unit |
setPropertyByteArray(propertyName: String!, value: ByteArray!)Sets the value of a byte array property. |
Unit |
setPropertyString(propertyName: String!, value: String!)Sets the value of a string property. |
Constants
EVENT_KEY_EXPIRED
@UnstableApi
const val EVENT_KEY_EXPIRED = 3: Int
Event indicating that keys have expired, and are no longer usable.
EVENT_KEY_REQUIRED
@UnstableApi
const val EVENT_KEY_REQUIRED = 2: Int
Event indicating that keys need to be requested from the license server.
EVENT_PROVISION_REQUIRED
@UnstableApi
const val EVENT_PROVISION_REQUIRED = 1: Int
Event indicating that a certificate needs to be requested from the provisioning server.
KEY_TYPE_OFFLINE
@UnstableApi
const val KEY_TYPE_OFFLINE = 2: Int
Key request type for keys that will be used for offline use. They will be saved to the device for subsequent use when the device is not connected to a network.
KEY_TYPE_RELEASE
@UnstableApi
const val KEY_TYPE_RELEASE = 3: Int
Key request type indicating that saved offline keys should be released.
KEY_TYPE_STREAMING
@UnstableApi
const val KEY_TYPE_STREAMING = 1: Int
Key request type for keys that will be used for online use. Streaming keys will not be saved to the device for subsequent use when the device is not connected to a network.
Public functions
acquire
fun acquire(): Unit
Increments the reference count. When the caller no longer needs to use the instance, it must call release to decrement the reference count.
A new instance will have an initial reference count of 1, and therefore it is not normally necessary for application code to call this method.
closeSession
fun closeSession(sessionId: ByteArray!): Unit
Closes a DRM session.
| Parameters | |
|---|---|
sessionId: ByteArray! |
The ID of the session to close. |
createCryptoConfig
fun createCryptoConfig(sessionId: ByteArray!): CryptoConfig!
Creates a CryptoConfig that can be passed to a compatible decoder to allow decryption of protected content using the specified session.
| Parameters | |
|---|---|
sessionId: ByteArray! |
The ID of the session. |
| Returns | |
|---|---|
CryptoConfig! |
A |
| Throws | |
|---|---|
android.media.MediaCryptoException |
If a |
getCryptoType
@C.CryptoType
fun getCryptoType(): Int
Returns the type of CryptoConfig instances returned by createCryptoConfig.
getKeyRequest
fun getKeyRequest(
scope: ByteArray!,
schemeDatas: (Mutable)List<DrmInitData.SchemeData!>?,
keyType: Int,
optionalParameters: HashMap<String!, String!>?
): ExoMediaDrm.KeyRequest!
Generates a key request.
| Parameters | |
|---|---|
scope: ByteArray! |
If |
schemeDatas: (Mutable)List<DrmInitData.SchemeData!>? |
If key type is |
keyType: Int |
The type of the request. Either |
optionalParameters: HashMap<String!, String!>? |
Are included in the key request message to allow a client application to provide additional message parameters to the server. This may be |
| Returns | |
|---|---|
ExoMediaDrm.KeyRequest! |
The generated key request. |
| See also | |
|---|---|
getKeyRequest |
getMetrics
fun getMetrics(): PersistableBundle?
Returns metrics data for this ExoMediaDrm instance, or null if metrics are unavailable.
getOfflineLicenseKeySetIds
fun getOfflineLicenseKeySetIds(): (Mutable)List<ByteArray<Byte>!>!
Returns a list of the keySetIds for all offline licenses.
This is an optional method, and some implementations may only support it on certain Android API levels.
See getOfflineLicenseKeySetIds for more details.
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the implementation doesn't support this method. |
getPropertyByteArray
fun getPropertyByteArray(propertyName: String!): ByteArray<Byte>!
Returns the value of a byte array property. For standard property names, see getPropertyByteArray.
| Parameters | |
|---|---|
propertyName: String! |
The property name. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If the underlying DRM plugin does not support the property. |
getPropertyString
fun getPropertyString(propertyName: String!): String!
Returns the value of a string property. For standard property names, see getPropertyString.
| Parameters | |
|---|---|
propertyName: String! |
The property name. |
| Returns | |
|---|---|
String! |
The property value. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If the underlying DRM plugin does not support the property. |
getProvisionRequest
fun getProvisionRequest(): ExoMediaDrm.ProvisionRequest!
Generates a provisioning request.
| Returns | |
|---|---|
ExoMediaDrm.ProvisionRequest! |
The generated provisioning request. |
openSession
fun openSession(): ByteArray<Byte>!
Opens a new DRM session. A session ID is returned.
| Throws | |
|---|---|
android.media.NotProvisionedException |
If provisioning is needed. |
android.media.ResourceBusyException |
If required resources are in use. |
android.media.MediaDrmException |
If the session could not be opened. |
provideKeyResponse
fun provideKeyResponse(scope: ByteArray!, response: ByteArray!): ByteArray<Byte>?
Provides a key response for the last request to be generated using getKeyRequest.
| Parameters | |
|---|---|
scope: ByteArray! |
If the request had type |
response: ByteArray! |
The response data from the server. |
| Returns | |
|---|---|
ByteArray<Byte>? |
If the request had type |
| Throws | |
|---|---|
android.media.NotProvisionedException |
If the response indicates that provisioning is needed. |
android.media.DeniedByServerException |
If the response indicates that the server rejected the request. |
provideProvisionResponse
fun provideProvisionResponse(response: ByteArray!): Unit
Provides a provisioning response for the last request to be generated using getProvisionRequest.
| Parameters | |
|---|---|
response: ByteArray! |
The response data from the server. |
| Throws | |
|---|---|
android.media.DeniedByServerException |
If the response indicates that the server rejected the request. |
queryKeyStatus
fun queryKeyStatus(sessionId: ByteArray!): (Mutable)Map<String!, String!>!
Returns the key status for a given session, as {name, value} pairs. Since DRM license policies vary by vendor, the returned entries depend on the DRM plugin being used. Refer to your DRM provider's documentation for more information.
| Parameters | |
|---|---|
sessionId: ByteArray! |
The ID of the session being queried. |
release
fun release(): Unit
Decrements the reference count. If the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.
removeOfflineLicense
fun removeOfflineLicense(keySetId: ByteArray!): Unit
Removes an offline license.
This method is generally not needed, and should only be used if the preferred approach of generating a license release request by passing KEY_TYPE_RELEASE to getKeyRequest is not possible.
This is an optional method, and some implementations may only support it on certain Android API levels.
See removeOfflineLicense for more details.
| Parameters | |
|---|---|
keySetId: ByteArray! |
The |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the implementation doesn't support this method. |
requiresSecureDecoder
fun requiresSecureDecoder(sessionId: ByteArray!, mimeType: String!): Boolean
Returns whether the given session requires use of a secure decoder for the given MIME type. Assumes a license policy that requires the highest level of security supported by the session.
restoreKeys
fun restoreKeys(sessionId: ByteArray!, keySetId: ByteArray!): Unit
Restores persisted offline keys into a session.
| Parameters | |
|---|---|
sessionId: ByteArray! |
The ID of the session into which the keys will be restored. |
keySetId: ByteArray! |
The |
setOnEventListener
fun setOnEventListener(listener: ExoMediaDrm.OnEventListener?): Unit
Sets the listener for DRM events.
This is an optional method, and some implementations may only support it on certain Android API levels.
| Parameters | |
|---|---|
listener: ExoMediaDrm.OnEventListener? |
The listener to receive events, or |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the implementation doesn't support this method. |
| See also | |
|---|---|
setOnEventListener |
setOnExpirationUpdateListener
fun setOnExpirationUpdateListener(
listener: ExoMediaDrm.OnExpirationUpdateListener?
): Unit
Sets the listener for session expiration events.
This is an optional method, and some implementations may only support it on certain Android API levels.
| Parameters | |
|---|---|
listener: ExoMediaDrm.OnExpirationUpdateListener? |
The listener to receive events, or |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the implementation doesn't support this method. |
| See also | |
|---|---|
setOnExpirationUpdateListener |
setOnKeyStatusChangeListener
fun setOnKeyStatusChangeListener(
listener: ExoMediaDrm.OnKeyStatusChangeListener?
): Unit
Sets the listener for key status change events.
This is an optional method, and some implementations may only support it on certain Android API levels.
| Parameters | |
|---|---|
listener: ExoMediaDrm.OnKeyStatusChangeListener? |
The listener to receive events, or |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
if the implementation doesn't support this method. |
| See also | |
|---|---|
setOnKeyStatusChangeListener |
setPlayerIdForSession
fun setPlayerIdForSession(sessionId: ByteArray!, playerId: PlayerId!): Unit
Sets the PlayerId of the player using a session.
setPropertyByteArray
fun setPropertyByteArray(propertyName: String!, value: ByteArray!): Unit
Sets the value of a byte array property.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If the underlying DRM plugin does not support the property. |
setPropertyString
fun setPropertyString(propertyName: String!, value: String!): Unit
Sets the value of a string property.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If the underlying DRM plugin does not support the property. |