public interface ExoMediaDrm
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.
MediaDrm| Modifier and Type | Interface and Description |
|---|---|
static class |
ExoMediaDrm.AppManagedProvider
Provides an
ExoMediaDrm instance owned by the app. |
static class |
ExoMediaDrm.KeyRequest
Contains data used to request keys from a license server.
|
static class |
ExoMediaDrm.KeyStatus
Defines the status of a key.
|
static interface |
ExoMediaDrm.OnEventListener
Called when a DRM event occurs.
|
static interface |
ExoMediaDrm.OnExpirationUpdateListener
Called when a session expiration update occurs.
|
static interface |
ExoMediaDrm.OnKeyStatusChangeListener
Called when the keys in a DRM session change state.
|
static interface |
ExoMediaDrm.Provider
Provider for
ExoMediaDrm instances. |
static class |
ExoMediaDrm.ProvisionRequest
Contains data to request a certificate from a provisioning server.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
EVENT_KEY_EXPIRED
Event indicating that keys have expired, and are no longer usable.
|
static int |
EVENT_KEY_REQUIRED
Event indicating that keys need to be requested from the license server.
|
static int |
EVENT_PROVISION_REQUIRED
Event indicating that a certificate needs to be requested from the provisioning server.
|
static int |
KEY_TYPE_OFFLINE
Key request type for keys that will be used for offline use.
|
static int |
KEY_TYPE_RELEASE
Key request type indicating that saved offline keys should be released.
|
static int |
KEY_TYPE_STREAMING
Key request type for keys that will be used for online use.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Increments the reference count.
|
void |
closeSession(byte[] sessionId)
Closes a DRM session.
|
ExoMediaCrypto |
createMediaCrypto(byte[] sessionId)
Creates an
ExoMediaCrypto for a given session. |
java.lang.Class<? extends ExoMediaCrypto> |
getExoMediaCryptoType()
Returns the
ExoMediaCrypto type created by createMediaCrypto(byte[]). |
ExoMediaDrm.KeyRequest |
getKeyRequest(byte[] scope,
java.util.List<DrmInitData.SchemeData> schemeDatas,
int keyType,
java.util.HashMap<java.lang.String,java.lang.String> optionalParameters)
Generates a key request.
|
android.os.PersistableBundle |
getMetrics()
Returns metrics data for this ExoMediaDrm instance, or
null if metrics are unavailable. |
byte[] |
getPropertyByteArray(java.lang.String propertyName)
Returns the value of a byte array property.
|
java.lang.String |
getPropertyString(java.lang.String propertyName)
Returns the value of a string property.
|
ExoMediaDrm.ProvisionRequest |
getProvisionRequest()
Generates a provisioning request.
|
byte[] |
openSession()
Opens a new DRM session.
|
byte[] |
provideKeyResponse(byte[] scope,
byte[] response)
Provides a key response for the last request to be generated using
getKeyRequest(byte[], java.util.List<tv.danmaku.ijk.media.drm.DrmInitData.SchemeData>, int, java.util.HashMap<java.lang.String, java.lang.String>). |
void |
provideProvisionResponse(byte[] response)
Provides a provisioning response for the last request to be generated using
getProvisionRequest(). |
java.util.Map<java.lang.String,java.lang.String> |
queryKeyStatus(byte[] sessionId)
Returns the key status for a given session, as {name, value} pairs.
|
void |
release()
Decrements the reference count.
|
void |
restoreKeys(byte[] sessionId,
byte[] keySetId)
Restores persisted offline keys into a session.
|
void |
setOnEventListener(ExoMediaDrm.OnEventListener listener)
Sets the listener for DRM events.
|
void |
setOnExpirationUpdateListener(ExoMediaDrm.OnExpirationUpdateListener listener)
Sets the listener for session expiration events.
|
void |
setOnKeyStatusChangeListener(ExoMediaDrm.OnKeyStatusChangeListener listener)
Sets the listener for key status change events.
|
void |
setPropertyByteArray(java.lang.String propertyName,
byte[] value)
Sets the value of a byte array property.
|
void |
setPropertyString(java.lang.String propertyName,
java.lang.String value)
Sets the value of a string property.
|
static final int EVENT_KEY_REQUIRED
static final int EVENT_KEY_EXPIRED
static final int EVENT_PROVISION_REQUIRED
static final int KEY_TYPE_STREAMING
static final int KEY_TYPE_OFFLINE
static final int KEY_TYPE_RELEASE
void setOnEventListener(ExoMediaDrm.OnEventListener listener)
This is an optional method, and some implementations may only support it on certain Android API levels.
listener - The listener to receive events, or null to stop receiving events.java.lang.UnsupportedOperationException - if the implementation doesn't support this method.MediaDrm.setOnEventListener(MediaDrm.OnEventListener)void setOnKeyStatusChangeListener(ExoMediaDrm.OnKeyStatusChangeListener listener)
This is an optional method, and some implementations may only support it on certain Android API levels.
listener - The listener to receive events, or null to stop receiving events.java.lang.UnsupportedOperationException - if the implementation doesn't support this method.MediaDrm.setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler)void setOnExpirationUpdateListener(ExoMediaDrm.OnExpirationUpdateListener listener)
This is an optional method, and some implementations may only support it on certain Android API levels.
listener - The listener to receive events, or null to stop receiving events.java.lang.UnsupportedOperationException - if the implementation doesn't support this method.MediaDrm.setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler)byte[] openSession()
throws android.media.MediaDrmException
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.void closeSession(byte[] sessionId)
sessionId - The ID of the session to close.ExoMediaDrm.KeyRequest getKeyRequest(byte[] scope, java.util.List<DrmInitData.SchemeData> schemeDatas, int keyType, java.util.HashMap<java.lang.String,java.lang.String> optionalParameters) throws android.media.NotProvisionedException
scope - If keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE,
the ID of the session that the keys will be provided to. If keyType is KEY_TYPE_RELEASE, the keySetId of the keys to release.schemeDatas - If key type is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE, a
list of DrmInitData.SchemeData instances extracted from the media. Null otherwise.keyType - The type of the request. Either KEY_TYPE_STREAMING to acquire keys for
streaming, KEY_TYPE_OFFLINE to acquire keys for offline usage, or KEY_TYPE_RELEASE to release acquired keys. Releasing keys invalidates them for all
sessions.optionalParameters - Are included in the key request message to allow a client application
to provide additional message parameters to the server. This may be null if no
additional parameters are to be sent.android.media.NotProvisionedExceptionMediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)byte[] provideKeyResponse(byte[] scope,
byte[] response)
throws android.media.NotProvisionedException,
android.media.DeniedByServerException
getKeyRequest(byte[], java.util.List<tv.danmaku.ijk.media.drm.DrmInitData.SchemeData>, int, java.util.HashMap<java.lang.String, java.lang.String>).scope - If the request had type KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE,
the ID of the session to provide the keys to. If keyType is KEY_TYPE_RELEASE, the keySetId of the keys being released.response - The response data from the server.KEY_TYPE_OFFLINE, the keySetId for the offline
keys. An empty byte array or null may be returned for other cases.android.media.NotProvisionedException - If the response indicates that provisioning is needed.android.media.DeniedByServerException - If the response indicates that the server rejected the request.ExoMediaDrm.ProvisionRequest getProvisionRequest()
void provideProvisionResponse(byte[] response)
throws android.media.DeniedByServerException
getProvisionRequest().response - The response data from the server.android.media.DeniedByServerException - If the response indicates that the server rejected the request.java.util.Map<java.lang.String,java.lang.String> queryKeyStatus(byte[] sessionId)
sessionId - The ID of the session being queried.void acquire()
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.
void release()
void restoreKeys(byte[] sessionId,
byte[] keySetId)
sessionId - The ID of the session into which the keys will be restored.keySetId - The keySetId of the keys to restore, as provided by the call to provideKeyResponse(byte[], byte[]) that persisted them.android.os.PersistableBundle getMetrics()
null if metrics are unavailable.java.lang.String getPropertyString(java.lang.String propertyName)
MediaDrm.getPropertyString(java.lang.String).propertyName - The property name.java.lang.IllegalArgumentException - If the underlying DRM plugin does not support the property.byte[] getPropertyByteArray(java.lang.String propertyName)
MediaDrm.getPropertyByteArray(java.lang.String).propertyName - The property name.java.lang.IllegalArgumentException - If the underlying DRM plugin does not support the property.void setPropertyString(java.lang.String propertyName,
java.lang.String value)
propertyName - The property name.value - The value.java.lang.IllegalArgumentException - If the underlying DRM plugin does not support the property.void setPropertyByteArray(java.lang.String propertyName,
byte[] value)
propertyName - The property name.value - The value.java.lang.IllegalArgumentException - If the underlying DRM plugin does not support the property.ExoMediaCrypto createMediaCrypto(byte[] sessionId) throws android.media.MediaCryptoException
ExoMediaCrypto for a given session.sessionId - The ID of the session.ExoMediaCrypto for the given session.android.media.MediaCryptoException - If an ExoMediaCrypto could not be created.java.lang.Class<? extends ExoMediaCrypto> getExoMediaCryptoType()
ExoMediaCrypto type created by createMediaCrypto(byte[]).