FrameworkMediaDrm
class FrameworkMediaDrm : ExoMediaDrm
An ExoMediaDrm implementation that wraps the framework MediaDrm.
Summary
Constants |
|
|---|---|
const ExoMediaDrm.Provider! |
|
Public functions |
|
|---|---|
synchronized Unit |
Increments the reference count. |
Unit |
@UnstableApiCloses a DRM session. |
FrameworkCryptoConfig! |
@UnstableApiCreates a |
Int |
Returns the |
ExoMediaDrm.KeyRequest! |
@UnstableApiGenerates a key request. |
PersistableBundle? |
Returns metrics data for this ExoMediaDrm instance, or |
(Mutable)List<ByteArray<Byte>!>! |
@UnstableApiReturns a list of the |
ByteArray<Byte>! |
@UnstableApiReturns the value of a byte array property. |
String! |
@UnstableApiReturns the value of a string property. |
ExoMediaDrm.ProvisionRequest! |
Generates a provisioning request. |
java-static Boolean |
isCryptoSchemeSupported(uuid: UUID!)Returns whether the DRM scheme with the given UUID is supported on this device. |
java-static FrameworkMediaDrm! |
@UnstableApiCreates an instance with an initial reference count of 1. |
ByteArray<Byte>! |
Opens a new DRM session. |
ByteArray<Byte>? |
@UnstableApiProvides a key response for the last request to be generated using |
Unit |
@UnstableApiProvides a provisioning response for the last request to be generated using |
(Mutable)Map<String!, String!>! |
@UnstableApiReturns the key status for a given session, as {name, value} pairs. |
synchronized Unit |
Decrements the reference count. |
Unit |
@UnstableApiRemoves an offline license. |
Boolean |
@UnstableApiReturns whether the given session requires use of a secure decoder for the given MIME type. |
Unit |
@UnstableApiRestores persisted offline keys into a session. |
Unit |
@UnstableApiSets the listener for DRM events. |
Unit |
Sets the listener for session expiration events. |
Unit |
Sets the listener for key status change events. |
Unit |
@UnstableApiSets the |
Unit |
@UnstableApiSets the value of a byte array property. |
Unit |
@UnstableApiSets the value of a string property. |
Inherited Constants |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Constants
DEFAULT_PROVIDER
@UnstableApi
const val DEFAULT_PROVIDER: ExoMediaDrm.Provider!
ExoMediaDrm.Provider that returns a new FrameworkMediaDrm for the requested UUID. Returns a DummyExoMediaDrm if the protection scheme identified by the given UUID is not supported by the device.
Public functions
acquire
@UnstableApi
synchronized 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
@UnstableApi
fun closeSession(sessionId: ByteArray!): Unit
Closes a DRM session.
| Parameters | |
|---|---|
sessionId: ByteArray! |
The ID of the session to close. |
createCryptoConfig
@UnstableApi
fun createCryptoConfig(sessionId: ByteArray!): FrameworkCryptoConfig!
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 | |
|---|---|
FrameworkCryptoConfig! |
A |
| Throws | |
|---|---|
android.media.MediaCryptoException |
If a |
getCryptoType
@UnstableApi
@C.CryptoType
fun getCryptoType(): Int
Returns the type of CryptoConfig instances returned by createCryptoConfig.
getKeyRequest
@UnstableApi
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
@UnstableApi
fun getMetrics(): PersistableBundle?
Returns metrics data for this ExoMediaDrm instance, or null if metrics are unavailable.
getOfflineLicenseKeySetIds
@UnstableApi
@RequiresApi(value = 29)
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
fun getProvisionRequest(): ExoMediaDrm.ProvisionRequest!
Generates a provisioning request.
| Returns | |
|---|---|
ExoMediaDrm.ProvisionRequest! |
The generated provisioning request. |
isCryptoSchemeSupported
java-static fun isCryptoSchemeSupported(uuid: UUID!): Boolean
Returns whether the DRM scheme with the given UUID is supported on this device.
| See also | |
|---|---|
isCryptoSchemeSupported |
newInstance
@UnstableApi
java-static fun newInstance(uuid: UUID!): FrameworkMediaDrm!
Creates an instance with an initial reference count of 1. release must be called on the instance when it's no longer required.
| Parameters | |
|---|---|
uuid: UUID! |
The scheme uuid. |
| Returns | |
|---|---|
FrameworkMediaDrm! |
The created instance. |
| Throws | |
|---|---|
androidx.media3.exoplayer.drm.UnsupportedDrmException |
If the DRM scheme is unsupported or cannot be instantiated. |
openSession
@UnstableApi
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
synchronized 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
@UnstableApi
@RequiresApi(value = 29)
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
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
@UnstableApi
fun setPlayerIdForSession(sessionId: ByteArray!, playerId: PlayerId!): Unit
Sets the PlayerId of the player using a session.
setPropertyByteArray
@UnstableApi
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
@UnstableApi
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. |