public final class FrameworkMediaDrm extends java.lang.Object implements ExoMediaDrm
ExoMediaDrm implementation that wraps the framework MediaDrm.| 限定符和类型 | 字段和说明 |
|---|---|
static ExoMediaDrm.Provider |
DEFAULT_PROVIDER
ExoMediaDrm.Provider that returns a new FrameworkMediaDrm for the requested
UUID. |
EVENT_KEY_EXPIRED, EVENT_KEY_REQUIRED, EVENT_PROVISION_REQUIRED, KEY_TYPE_OFFLINE, KEY_TYPE_RELEASE, KEY_TYPE_STREAMING| 限定符和类型 | 方法和说明 |
|---|---|
void |
acquire()
Increments the reference count.
|
void |
closeSession(byte[] sessionId)
Closes a DRM session.
|
FrameworkMediaCrypto |
createMediaCrypto(byte[] initData)
Creates an
ExoMediaCrypto for a given session. |
java.lang.Class<FrameworkMediaCrypto> |
getExoMediaCryptoType()
Returns the
ExoMediaCrypto type created by ExoMediaDrm.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.
|
static boolean |
isCryptoSchemeSupported(java.util.UUID uuid)
Returns whether the DRM scheme with the given UUID is supported on this device.
|
static FrameworkMediaDrm |
newInstance(java.util.UUID uuid)
Creates an instance with an initial reference count of 1.
|
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
ExoMediaDrm.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
ExoMediaDrm.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.
|
public static final ExoMediaDrm.Provider DEFAULT_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 static boolean isCryptoSchemeSupported(java.util.UUID uuid)
MediaDrm.isCryptoSchemeSupported(UUID)public static FrameworkMediaDrm newInstance(java.util.UUID uuid) throws UnsupportedDrmException
release() must be called on
the instance when it's no longer required.uuid - The scheme uuid.UnsupportedDrmException - If the DRM scheme is unsupported or cannot be instantiated.public void setOnEventListener(ExoMediaDrm.OnEventListener listener)
ExoMediaDrmThis is an optional method, and some implementations may only support it on certain Android API levels.
setOnEventListener 在接口中 ExoMediaDrmlistener - The listener to receive events, or null to stop receiving events.MediaDrm.setOnEventListener(MediaDrm.OnEventListener)public void setOnKeyStatusChangeListener(ExoMediaDrm.OnKeyStatusChangeListener listener)
This is an optional method, and some implementations may only support it on certain Android API levels.
setOnKeyStatusChangeListener 在接口中 ExoMediaDrmlistener - The listener to receive events, or null to stop receiving events.java.lang.UnsupportedOperationException - on API levels lower than 23.MediaDrm.setOnKeyStatusChangeListener(MediaDrm.OnKeyStatusChangeListener, Handler)public void setOnExpirationUpdateListener(ExoMediaDrm.OnExpirationUpdateListener listener)
This is an optional method, and some implementations may only support it on certain Android API levels.
setOnExpirationUpdateListener 在接口中 ExoMediaDrmlistener - The listener to receive events, or null to stop receiving events.java.lang.UnsupportedOperationException - on API levels lower than 23.MediaDrm.setOnExpirationUpdateListener(MediaDrm.OnExpirationUpdateListener, Handler)public byte[] openSession()
throws android.media.MediaDrmException
ExoMediaDrmopenSession 在接口中 ExoMediaDrmandroid.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.public void closeSession(byte[] sessionId)
ExoMediaDrmcloseSession 在接口中 ExoMediaDrmsessionId - The ID of the session to close.public 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
ExoMediaDrmgetKeyRequest 在接口中 ExoMediaDrmscope - If keyType is ExoMediaDrm.KEY_TYPE_STREAMING or ExoMediaDrm.KEY_TYPE_OFFLINE,
the ID of the session that the keys will be provided to. If keyType is ExoMediaDrm.KEY_TYPE_RELEASE, the keySetId of the keys to release.schemeDatas - If key type is ExoMediaDrm.KEY_TYPE_STREAMING or ExoMediaDrm.KEY_TYPE_OFFLINE, a
list of DrmInitData.SchemeData instances extracted from the media. Null otherwise.keyType - The type of the request. Either ExoMediaDrm.KEY_TYPE_STREAMING to acquire keys for
streaming, ExoMediaDrm.KEY_TYPE_OFFLINE to acquire keys for offline usage, or ExoMediaDrm.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)public byte[] provideKeyResponse(byte[] scope,
byte[] response)
throws android.media.NotProvisionedException,
android.media.DeniedByServerException
ExoMediaDrmExoMediaDrm.getKeyRequest(byte[], java.util.List<tv.danmaku.ijk.media.drm.DrmInitData.SchemeData>, int, java.util.HashMap<java.lang.String, java.lang.String>).provideKeyResponse 在接口中 ExoMediaDrmscope - If the request had type ExoMediaDrm.KEY_TYPE_STREAMING or ExoMediaDrm.KEY_TYPE_OFFLINE,
the ID of the session to provide the keys to. If keyType is ExoMediaDrm.KEY_TYPE_RELEASE, the keySetId of the keys being released.response - The response data from the server.ExoMediaDrm.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.public ExoMediaDrm.ProvisionRequest getProvisionRequest()
ExoMediaDrmgetProvisionRequest 在接口中 ExoMediaDrmpublic void provideProvisionResponse(byte[] response)
throws android.media.DeniedByServerException
ExoMediaDrmExoMediaDrm.getProvisionRequest().provideProvisionResponse 在接口中 ExoMediaDrmresponse - The response data from the server.android.media.DeniedByServerException - If the response indicates that the server rejected the request.public java.util.Map<java.lang.String,java.lang.String> queryKeyStatus(byte[] sessionId)
ExoMediaDrmqueryKeyStatus 在接口中 ExoMediaDrmsessionId - The ID of the session being queried.public void acquire()
ExoMediaDrmExoMediaDrm.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.
acquire 在接口中 ExoMediaDrmpublic void release()
ExoMediaDrmrelease 在接口中 ExoMediaDrmpublic void restoreKeys(byte[] sessionId,
byte[] keySetId)
ExoMediaDrmrestoreKeys 在接口中 ExoMediaDrmsessionId - 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 ExoMediaDrm.provideKeyResponse(byte[], byte[]) that persisted them.public android.os.PersistableBundle getMetrics()
ExoMediaDrmnull if metrics are unavailable.getMetrics 在接口中 ExoMediaDrmpublic java.lang.String getPropertyString(java.lang.String propertyName)
ExoMediaDrmMediaDrm.getPropertyString(java.lang.String).getPropertyString 在接口中 ExoMediaDrmpropertyName - The property name.public byte[] getPropertyByteArray(java.lang.String propertyName)
ExoMediaDrmMediaDrm.getPropertyByteArray(java.lang.String).getPropertyByteArray 在接口中 ExoMediaDrmpropertyName - The property name.public void setPropertyString(java.lang.String propertyName,
java.lang.String value)
ExoMediaDrmsetPropertyString 在接口中 ExoMediaDrmpropertyName - The property name.value - The value.public void setPropertyByteArray(java.lang.String propertyName,
byte[] value)
ExoMediaDrmsetPropertyByteArray 在接口中 ExoMediaDrmpropertyName - The property name.value - The value.public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws android.media.MediaCryptoException
ExoMediaDrmExoMediaCrypto for a given session.createMediaCrypto 在接口中 ExoMediaDrminitData - The ID of the session.ExoMediaCrypto for the given session.android.media.MediaCryptoException - If an ExoMediaCrypto could not be created.public java.lang.Class<FrameworkMediaCrypto> getExoMediaCryptoType()
ExoMediaDrmExoMediaCrypto type created by ExoMediaDrm.createMediaCrypto(byte[]).getExoMediaCryptoType 在接口中 ExoMediaDrm