docs/doc/reference/com/google/android/exoplayer2/drm/ExoMediaDrm.html
Package com.google.android.exoplayer2.drm
DummyExoMediaDrm, FakeExoMediaDrm, FrameworkMediaDrm[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public interfaceExoMediaDrm
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
Used to obtain keys for decrypting protected media streams.
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
Nested Classes | Modifier and Type | Interface | Description |
| --- | --- | --- |
| static class | ExoMediaDrm.AppManagedProvider |
Deprecated.
Provides an ExoMediaDrm instance owned by the app.
|
| static class | ExoMediaDrm.KeyRequest |
Deprecated.
Contains data used to request keys from a license server.
|
| static class | ExoMediaDrm.KeyStatus |
Deprecated.
Defines the status of a key.
|
| static interface | ExoMediaDrm.OnEventListener |
Deprecated.
Called when a DRM event occurs.
|
| static interface | ExoMediaDrm.OnExpirationUpdateListener |
Deprecated.
Called when a session expiration update occurs.
|
| static interface | ExoMediaDrm.OnKeyStatusChangeListener |
Deprecated.
Called when the keys in a DRM session change state.
|
| static interface | ExoMediaDrm.Provider |
Deprecated.
Provider for ExoMediaDrm instances.
|
| static class | ExoMediaDrm.ProvisionRequest |
Deprecated.
Contains data to request a certificate from a provisioning server. |
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static int | EVENT_KEY_EXPIRED |
Deprecated.
Event indicating that keys have expired, and are no longer usable.
|
| static int | EVENT_KEY_REQUIRED |
Deprecated.
Event indicating that keys need to be requested from the license server.
|
| static int | EVENT_PROVISION_REQUIRED |
Deprecated.
Event indicating that a certificate needs to be requested from the provisioning server.
|
| static int | KEY_TYPE_OFFLINE |
Deprecated.
Key request type for keys that will be used for offline use.
|
| static int | KEY_TYPE_RELEASE |
Deprecated.
Key request type indicating that saved offline keys should be released.
|
| static int | KEY_TYPE_STREAMING |
Deprecated.
Key request type for keys that will be used for online use. |
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | acquire() |
Deprecated.
Increments the reference count.
|
| void | closeSession(byte[] sessionId) |
Deprecated.
Closes a DRM session.
|
| CryptoConfig | createCryptoConfig(byte[] sessionId) |
Deprecated.
Creates a CryptoConfig that can be passed to a compatible decoder to allow decryption of protected content using the specified session.
|
| @com.google.android.exoplayer2.C.CryptoType int | getCryptoType() |
Deprecated.
Returns the type of CryptoConfig instances returned by createCryptoConfig(byte[]).
|
| ExoMediaDrm.KeyRequest | getKeyRequest(byte[] scope, List<DrmInitData.SchemeData> schemeDatas, int keyType, HashMap<String,String> optionalParameters) |
Deprecated.
Generates a key request.
|
| PersistableBundle | getMetrics() |
Deprecated.
Returns metrics data for this ExoMediaDrm instance, or null if metrics are unavailable.
|
| byte[] | getPropertyByteArray(String propertyName) |
Deprecated.
Returns the value of a byte array property.
|
| String | getPropertyString(String propertyName) |
Deprecated.
Returns the value of a string property.
|
| ExoMediaDrm.ProvisionRequest | getProvisionRequest() |
Deprecated.
Generates a provisioning request.
|
| byte[] | openSession() |
Deprecated.
Opens a new DRM session.
|
| byte[] | provideKeyResponse(byte[] scope, byte[] response) |
Deprecated.
Provides a key response for the last request to be generated using getKeyRequest(byte[], java.util.List<com.google.android.exoplayer2.drm.DrmInitData.SchemeData>, int, java.util.HashMap<java.lang.String, java.lang.String>).
|
| void | provideProvisionResponse(byte[] response) |
Deprecated.
Provides a provisioning response for the last request to be generated using getProvisionRequest().
|
| Map<String,String> | queryKeyStatus(byte[] sessionId) |
Deprecated.
Returns the key status for a given session, as {name, value} pairs.
|
| void | release() |
Deprecated.
Decrements the reference count.
|
| boolean | requiresSecureDecoder(byte[] sessionId, String mimeType) |
Deprecated.
Returns whether the given session requires use of a secure decoder for the given MIME type.
|
| void | restoreKeys(byte[] sessionId, byte[] keySetId) |
Deprecated.
Restores persisted offline keys into a session.
|
| void | setOnEventListener(ExoMediaDrm.OnEventListener listener) |
Deprecated.
Sets the listener for DRM events.
|
| void | setOnExpirationUpdateListener(ExoMediaDrm.OnExpirationUpdateListener listener) |
Deprecated.
Sets the listener for session expiration events.
|
| void | setOnKeyStatusChangeListener(ExoMediaDrm.OnKeyStatusChangeListener listener) |
Deprecated.
Sets the listener for key status change events.
|
| default void | setPlayerIdForSession(byte[] sessionId, PlayerId playerId) |
Deprecated.
Sets the PlayerId of the player using a session.
|
| void | setPropertyByteArray(String propertyName, byte[] value) |
Deprecated.
Sets the value of a byte array property.
|
| void | setPropertyString(String propertyName, String value) |
Deprecated.
Sets the value of a string property. |
-
static final int EVENT_KEY_REQUIRED
Deprecated.
Event indicating that keys need to be requested from the license server. See Also:Constant Field Values
-
static final int EVENT_KEY_EXPIRED
Deprecated.
Event indicating that keys have expired, and are no longer usable. See Also:Constant Field Values
-
static final int EVENT_PROVISION_REQUIRED
Deprecated.
Event indicating that a certificate needs to be requested from the provisioning server. See Also:Constant Field Values
-
static final int KEY_TYPE_STREAMING
Deprecated.
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. See Also:Constant Field Values
-
static final int KEY_TYPE_OFFLINE
Deprecated.
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. See Also:Constant Field Values
-
static final int KEY_TYPE_RELEASE
Deprecated.
Key request type indicating that saved offline keys should be released. See Also:Constant Field Values
-
void setOnEventListener(@Nullable[ExoMediaDrm.OnEventListener](ExoMediaDrm.OnEventListener.html "interface in com.google.android.exoplayer2.drm")listener)
Deprecated.
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 - The listener to receive events, or null to stop receiving events.Throws:UnsupportedOperationException - if the implementation doesn't support this method.See Also:MediaDrm.setOnEventListener(MediaDrm.OnEventListener)
-
void setOnKeyStatusChangeListener(@Nullable[ExoMediaDrm.OnKeyStatusChangeListener](ExoMediaDrm.OnKeyStatusChangeListener.html "interface in com.google.android.exoplayer2.drm")listener)
Deprecated.
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 - The listener to receive events, or null to stop receiving events.Throws:UnsupportedOperationException - if the implementation doesn't support this method.See Also:MediaDrm.setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler)
-
void setOnExpirationUpdateListener(@Nullable[ExoMediaDrm.OnExpirationUpdateListener](ExoMediaDrm.OnExpirationUpdateListener.html "interface in com.google.android.exoplayer2.drm")listener)
Deprecated.
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 - The listener to receive events, or null to stop receiving events.Throws:UnsupportedOperationException - if the implementation doesn't support this method.See Also:MediaDrm.setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler)
-
byte[] openSession()
throws[MediaDrmException](https://developer.android.com/reference/android/media/MediaDrmException.html "class or interface in android.media")
Deprecated.
Opens a new DRM session. A session ID is returned.
Returns:The session ID.Throws:NotProvisionedException - If provisioning is needed.ResourceBusyException - If required resources are in use.MediaDrmException - If the session could not be opened.
-
void closeSession(byte[] sessionId)
Deprecated.
Closes a DRM session.
Parameters:sessionId - The ID of the session to close.
-
default void setPlayerIdForSession(byte[] sessionId,[PlayerId](../analytics/PlayerId.html "class in com.google.android.exoplayer2.analytics")playerId)
Deprecated.
Sets the PlayerId of the player using a session.
Parameters:sessionId - The ID of the session.playerId - The PlayerId of the player using the session.
-
[ExoMediaDrm.KeyRequest](ExoMediaDrm.KeyRequest.html "class in com.google.android.exoplayer2.drm")getKeyRequest(byte[] scope,
@Nullable[List](https://developer.android.com/reference/java/util/List.html "class or interface in java.util")<[DrmInitData.SchemeData](DrmInitData.SchemeData.html "class in com.google.android.exoplayer2.drm")> schemeDatas,
int keyType,
@Nullable[HashMap](https://developer.android.com/reference/java/util/HashMap.html "class or interface in java.util")<[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> optionalParameters)
throws[NotProvisionedException](https://developer.android.com/reference/android/media/NotProvisionedException.html "class or interface in android.media")
Deprecated.
Generates a key request.
Parameters: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.Returns:The generated key request.Throws:NotProvisionedExceptionSee Also:MediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
-
@Nullable
byte[] provideKeyResponse(byte[] scope,
byte[] response)
throws[NotProvisionedException](https://developer.android.com/reference/android/media/NotProvisionedException.html "class or interface in android.media"),[DeniedByServerException](https://developer.android.com/reference/android/media/DeniedByServerException.html "class or interface in android.media")
Deprecated.
Provides a key response for the last request to be generated using getKeyRequest(byte[], java.util.List<com.google.android.exoplayer2.drm.DrmInitData.SchemeData>, int, java.util.HashMap<java.lang.String, java.lang.String>).
Parameters: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.Returns:If the request had type KEY_TYPE_OFFLINE, the keySetId for the offline keys. An empty byte array or null may be returned for other cases.Throws:NotProvisionedException - If the response indicates that provisioning is needed.DeniedByServerException - If the response indicates that the server rejected the request.
-
[ExoMediaDrm.ProvisionRequest](ExoMediaDrm.ProvisionRequest.html "class in com.google.android.exoplayer2.drm")getProvisionRequest()
Deprecated.
Generates a provisioning request. Returns:The generated provisioning request.
-
void provideProvisionResponse(byte[] response)
throws[DeniedByServerException](https://developer.android.com/reference/android/media/DeniedByServerException.html "class or interface in android.media")
Deprecated.
Provides a provisioning response for the last request to be generated using getProvisionRequest().
Parameters:response - The response data from the server.Throws:DeniedByServerException - If the response indicates that the server rejected the request.
-
[Map](https://developer.android.com/reference/java/util/Map.html "class or interface in java.util")<[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> queryKeyStatus(byte[] sessionId)
Deprecated.
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 - The ID of the session being queried.Returns:The key status for the session.
-
boolean requiresSecureDecoder(byte[] sessionId,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")mimeType)
Deprecated.
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.
Parameters:sessionId - The ID of the session.mimeType - The content MIME type to query.
-
void acquire()
Deprecated.
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.
-
void release()
Deprecated.
Decrements the reference count. If the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.
-
void restoreKeys(byte[] sessionId,
byte[] keySetId)
Deprecated.
Restores persisted offline keys into a session.
Parameters: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.
-
@Nullable[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle.html "class or interface in android.os")getMetrics()
Deprecated.
Returns metrics data for this ExoMediaDrm instance, or null if metrics are unavailable.
-
[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")getPropertyString([String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")propertyName)
Deprecated.
Returns the value of a string property. For standard property names, see MediaDrm.getPropertyString(java.lang.String).
Parameters:propertyName - The property name.Returns:The property value.Throws:IllegalArgumentException - If the underlying DRM plugin does not support the property.
-
byte[] getPropertyByteArray([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")propertyName)
Deprecated.
Returns the value of a byte array property. For standard property names, see MediaDrm.getPropertyByteArray(java.lang.String).
Parameters:propertyName - The property name.Returns:The property value.Throws:IllegalArgumentException - If the underlying DRM plugin does not support the property.
-
void setPropertyString([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")propertyName,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")value)
Deprecated.
Sets the value of a string property.
Parameters:propertyName - The property name.value - The value.Throws:IllegalArgumentException - If the underlying DRM plugin does not support the property.
-
void setPropertyByteArray([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")propertyName,
byte[] value)
Deprecated.
Sets the value of a byte array property.
Parameters:propertyName - The property name.value - The value.Throws:IllegalArgumentException - If the underlying DRM plugin does not support the property.
-
[CryptoConfig](../decoder/CryptoConfig.html "interface in com.google.android.exoplayer2.decoder")createCryptoConfig(byte[] sessionId)
throws[MediaCryptoException](https://developer.android.com/reference/android/media/MediaCryptoException.html "class or interface in android.media")
Deprecated.
Creates a CryptoConfig that can be passed to a compatible decoder to allow decryption of protected content using the specified session.
Parameters:sessionId - The ID of the session.Returns:A CryptoConfig for the given session.Throws:MediaCryptoException - If a CryptoConfig could not be created.
-
@com.google.android.exoplayer2.C.CryptoType int getCryptoType()
Deprecated.
Returns the type of CryptoConfig instances returned by createCryptoConfig(byte[]).