Interface ExoMediaDrm
-
- All Known Implementing Classes:
DummyExoMediaDrm,FakeExoMediaDrm,FrameworkMediaDrm
@Deprecated public interface ExoMediaDrm
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.Reference counting
Access to an instance is managed by reference counting, where
acquire()increments the reference count andrelease()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 callrelease()when the instance is no longer required.- See Also:
MediaDrm
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classExoMediaDrm.AppManagedProviderDeprecated.Provides anExoMediaDrminstance owned by the app.static classExoMediaDrm.KeyRequestDeprecated.Contains data used to request keys from a license server.static classExoMediaDrm.KeyStatusDeprecated.Defines the status of a key.static interfaceExoMediaDrm.OnEventListenerDeprecated.Called when a DRM event occurs.static interfaceExoMediaDrm.OnExpirationUpdateListenerDeprecated.Called when a session expiration update occurs.static interfaceExoMediaDrm.OnKeyStatusChangeListenerDeprecated.Called when the keys in a DRM session change state.static interfaceExoMediaDrm.ProviderDeprecated.Provider forExoMediaDrminstances.static classExoMediaDrm.ProvisionRequestDeprecated.Contains data to request a certificate from a provisioning server.
-
Field Summary
Fields Modifier and Type Field Description static intEVENT_KEY_EXPIREDDeprecated.Event indicating that keys have expired, and are no longer usable.static intEVENT_KEY_REQUIREDDeprecated.Event indicating that keys need to be requested from the license server.static intEVENT_PROVISION_REQUIREDDeprecated.Event indicating that a certificate needs to be requested from the provisioning server.static intKEY_TYPE_OFFLINEDeprecated.Key request type for keys that will be used for offline use.static intKEY_TYPE_RELEASEDeprecated.Key request type indicating that saved offline keys should be released.static intKEY_TYPE_STREAMINGDeprecated.Key request type for keys that will be used for online use.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidacquire()Deprecated.Increments the reference count.voidcloseSession(byte[] sessionId)Deprecated.Closes a DRM session.CryptoConfigcreateCryptoConfig(byte[] sessionId)Deprecated.Creates aCryptoConfigthat can be passed to a compatible decoder to allow decryption of protected content using the specified session.@com.google.android.exoplayer2.C.CryptoType intgetCryptoType()Deprecated.ExoMediaDrm.KeyRequestgetKeyRequest(byte[] scope, List<DrmInitData.SchemeData> schemeDatas, int keyType, HashMap<String,String> optionalParameters)Deprecated.Generates a key request.PersistableBundlegetMetrics()Deprecated.Returns metrics data for this ExoMediaDrm instance, ornullif metrics are unavailable.byte[]getPropertyByteArray(String propertyName)Deprecated.Returns the value of a byte array property.StringgetPropertyString(String propertyName)Deprecated.Returns the value of a string property.ExoMediaDrm.ProvisionRequestgetProvisionRequest()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 usinggetKeyRequest(byte[], java.util.List<com.google.android.exoplayer2.drm.DrmInitData.SchemeData>, int, java.util.HashMap<java.lang.String, java.lang.String>).voidprovideProvisionResponse(byte[] response)Deprecated.Provides a provisioning response for the last request to be generated usinggetProvisionRequest().Map<String,String>queryKeyStatus(byte[] sessionId)Deprecated.Returns the key status for a given session, as {name, value} pairs.voidrelease()Deprecated.Decrements the reference count.booleanrequiresSecureDecoder(byte[] sessionId, String mimeType)Deprecated.Returns whether the given session requires use of a secure decoder for the given MIME type.voidrestoreKeys(byte[] sessionId, byte[] keySetId)Deprecated.Restores persisted offline keys into a session.voidsetOnEventListener(ExoMediaDrm.OnEventListener listener)Deprecated.Sets the listener for DRM events.voidsetOnExpirationUpdateListener(ExoMediaDrm.OnExpirationUpdateListener listener)Deprecated.Sets the listener for session expiration events.voidsetOnKeyStatusChangeListener(ExoMediaDrm.OnKeyStatusChangeListener listener)Deprecated.Sets the listener for key status change events.default voidsetPlayerIdForSession(byte[] sessionId, PlayerId playerId)Deprecated.Sets thePlayerIdof the player using a session.voidsetPropertyByteArray(String propertyName, byte[] value)Deprecated.Sets the value of a byte array property.voidsetPropertyString(String propertyName, String value)Deprecated.Sets the value of a string property.
-
-
-
Field Detail
-
EVENT_KEY_REQUIRED
static final int EVENT_KEY_REQUIRED
Deprecated.Event indicating that keys need to be requested from the license server.- See Also:
- Constant Field Values
-
EVENT_KEY_EXPIRED
static final int EVENT_KEY_EXPIRED
Deprecated.Event indicating that keys have expired, and are no longer usable.- See Also:
- Constant Field Values
-
EVENT_PROVISION_REQUIRED
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
-
KEY_TYPE_STREAMING
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
-
KEY_TYPE_OFFLINE
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
-
KEY_TYPE_RELEASE
static final int KEY_TYPE_RELEASE
Deprecated.Key request type indicating that saved offline keys should be released.- See Also:
- Constant Field Values
-
-
Method Detail
-
setOnEventListener
void setOnEventListener(@Nullable ExoMediaDrm.OnEventListener 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, ornullto stop receiving events.- Throws:
UnsupportedOperationException- if the implementation doesn't support this method.- See Also:
MediaDrm.setOnEventListener(MediaDrm.OnEventListener)
-
setOnKeyStatusChangeListener
void setOnKeyStatusChangeListener(@Nullable ExoMediaDrm.OnKeyStatusChangeListener 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, ornullto stop receiving events.- Throws:
UnsupportedOperationException- if the implementation doesn't support this method.- See Also:
MediaDrm.setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler)
-
setOnExpirationUpdateListener
void setOnExpirationUpdateListener(@Nullable ExoMediaDrm.OnExpirationUpdateListener 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, ornullto stop receiving events.- Throws:
UnsupportedOperationException- if the implementation doesn't support this method.- See Also:
MediaDrm.setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler)
-
openSession
byte[] openSession() throws MediaDrmExceptionDeprecated.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.
-
closeSession
void closeSession(byte[] sessionId)
Deprecated.Closes a DRM session.- Parameters:
sessionId- The ID of the session to close.
-
setPlayerIdForSession
default void setPlayerIdForSession(byte[] sessionId, PlayerId playerId)Deprecated.Sets thePlayerIdof the player using a session.- Parameters:
sessionId- The ID of the session.playerId- ThePlayerIdof the player using the session.
-
getKeyRequest
ExoMediaDrm.KeyRequest getKeyRequest(byte[] scope, @Nullable List<DrmInitData.SchemeData> schemeDatas, int keyType, @Nullable HashMap<String,String> optionalParameters) throws NotProvisionedException
Deprecated.Generates a key request.- Parameters:
scope- IfkeyTypeisKEY_TYPE_STREAMINGorKEY_TYPE_OFFLINE, the ID of the session that the keys will be provided to. IfkeyTypeisKEY_TYPE_RELEASE, thekeySetIdof the keys to release.schemeDatas- If key type isKEY_TYPE_STREAMINGorKEY_TYPE_OFFLINE, a list ofDrmInitData.SchemeDatainstances extracted from the media. Null otherwise.keyType- The type of the request. EitherKEY_TYPE_STREAMINGto acquire keys for streaming,KEY_TYPE_OFFLINEto acquire keys for offline usage, orKEY_TYPE_RELEASEto 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 benullif no additional parameters are to be sent.- Returns:
- The generated key request.
- Throws:
NotProvisionedException- See Also:
MediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
-
provideKeyResponse
@Nullable byte[] provideKeyResponse(byte[] scope, byte[] response) throws NotProvisionedException, DeniedByServerExceptionDeprecated.Provides a key response for the last request to be generated usinggetKeyRequest(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 typeKEY_TYPE_STREAMINGorKEY_TYPE_OFFLINE, the ID of the session to provide the keys to. IfkeyTypeisKEY_TYPE_RELEASE, thekeySetIdof the keys being released.response- The response data from the server.- Returns:
- If the request had type
KEY_TYPE_OFFLINE, thekeySetIdfor the offline keys. An empty byte array ornullmay 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.
-
getProvisionRequest
ExoMediaDrm.ProvisionRequest getProvisionRequest()
Deprecated.Generates a provisioning request.- Returns:
- The generated provisioning request.
-
provideProvisionResponse
void provideProvisionResponse(byte[] response) throws DeniedByServerExceptionDeprecated.Provides a provisioning response for the last request to be generated usinggetProvisionRequest().- Parameters:
response- The response data from the server.- Throws:
DeniedByServerException- If the response indicates that the server rejected the request.
-
queryKeyStatus
Map<String,String> 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.
-
requiresSecureDecoder
boolean requiresSecureDecoder(byte[] sessionId, String 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.
-
acquire
void acquire()
Deprecated.Increments the reference count. When the caller no longer needs to use the instance, it must callrelease()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.
-
release
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.
-
restoreKeys
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- ThekeySetIdof the keys to restore, as provided by the call toprovideKeyResponse(byte[], byte[])that persisted them.
-
getMetrics
@Nullable PersistableBundle getMetrics()
Deprecated.Returns metrics data for this ExoMediaDrm instance, ornullif metrics are unavailable.
-
getPropertyString
String getPropertyString(String propertyName)
Deprecated.Returns the value of a string property. For standard property names, seeMediaDrm.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.
-
getPropertyByteArray
byte[] getPropertyByteArray(String propertyName)
Deprecated.Returns the value of a byte array property. For standard property names, seeMediaDrm.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.
-
setPropertyString
void setPropertyString(String propertyName, String 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.
-
setPropertyByteArray
void setPropertyByteArray(String 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.
-
createCryptoConfig
CryptoConfig createCryptoConfig(byte[] sessionId) throws MediaCryptoException
Deprecated.Creates aCryptoConfigthat 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
CryptoConfigfor the given session. - Throws:
MediaCryptoException- If aCryptoConfigcould not be created.
-
getCryptoType
@com.google.android.exoplayer2.C.CryptoType int getCryptoType()
Deprecated.
-
-