DrmSession
@UnstableApi
public interface DrmSession
ErrorStateDrmSession |
A |
A DRM session.
Summary
Nested types |
|---|
public class DrmSession.DrmSessionException extends IOExceptionWraps the throwable which is the cause of the error state. |
@DocumentedThe state of the DRM session. |
Constants |
|
|---|---|
default static final int |
STATE_ERROR = 1The session has encountered an error. |
default static final int |
STATE_OPENED = 3The session is open, but does not have keys required for decryption. |
default static final int |
The session is open and has keys required for decryption. |
default static final int |
STATE_OPENING = 2The session is being opened. |
default static final int |
STATE_RELEASED = 0The session has been released. |
Public methods |
|
|---|---|
abstract void |
acquire(Increments the reference count. |
abstract @Nullable CryptoConfig |
Returns a |
abstract @Nullable DrmSession.DrmSessionException |
getError()Returns the cause of the error state, or null if |
abstract @Nullable byte[] |
Returns the key set id of the offline license loaded into this session, or null if there isn't one. |
abstract UUID |
Returns the DRM scheme UUID for this session. |
abstract int |
Returns the current state of the session, which is one of |
default boolean |
Returns whether this session allows playback of clear samples prior to keys being loaded. |
abstract @Nullable Map<String, String> |
Returns a map describing the key status for the session, or null if called before the session has been opened or after it's been released. |
abstract void |
release(Decrements the reference count. |
default static void |
replaceSession(Acquires |
abstract boolean |
requiresSecureDecoder(String mimeType)Returns whether this session requires use of a secure decoder for the given MIME type. |
Constants
STATE_ERROR
default static final int STATE_ERROR = 1
The session has encountered an error. getError can be used to retrieve the cause. This is a terminal state.
STATE_OPENED
default static final int STATE_OPENED = 3
The session is open, but does not have keys required for decryption.
STATE_OPENED_WITH_KEYS
default static final int STATE_OPENED_WITH_KEYS = 4
The session is open and has keys required for decryption.
STATE_RELEASED
default static final int STATE_RELEASED = 0
The session has been released. This is a terminal state.
Public methods
acquire
abstract void acquire(
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher
)
Increments the reference count. When the caller no longer needs to use the instance, it must call release to decrement the reference count.
| Parameters | |
|---|---|
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher |
The |
getCryptoConfig
abstract @Nullable CryptoConfig getCryptoConfig()
Returns a CryptoConfig for the open session, or null if called before the session has been opened or after it's been released.
getError
abstract @Nullable DrmSession.DrmSessionException getError()
Returns the cause of the error state, or null if getState is not STATE_ERROR.
getOfflineLicenseKeySetId
abstract @Nullable byte[] getOfflineLicenseKeySetId()
Returns the key set id of the offline license loaded into this session, or null if there isn't one.
getState
@DrmSession.State
abstract int getState()
Returns the current state of the session, which is one of STATE_ERROR, STATE_RELEASED, STATE_OPENING, STATE_OPENED and STATE_OPENED_WITH_KEYS.
playClearSamplesWithoutKeys
default boolean playClearSamplesWithoutKeys()
Returns whether this session allows playback of clear samples prior to keys being loaded.
queryKeyStatus
abstract @Nullable Map<String, String> queryKeyStatus()
Returns a map describing the key status for the session, or null if called before the session has been opened or after it's been released.
Since DRM license policies vary by vendor, the specific status field names are determined by each DRM vendor. Refer to your DRM provider documentation for definitions of the field names for a particular DRM engine plugin.
| Returns | |
|---|---|
@Nullable Map<String, String> |
A map describing the key status for the session, or null if called before the session has been opened or after it's been released. |
| See also | |
|---|---|
queryKeyStatus |
release
abstract void release(
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher
)
Decrements the reference count. If the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.
| Parameters | |
|---|---|
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher |
The |
replaceSession
default static void replaceSession(
@Nullable DrmSession previousSession,
@Nullable DrmSession newSession
)
Acquires newSession then releases previousSession.
Invokes newSession'sacquire and previousSession'srelease in that order (passing eventDispatcher = null). Null arguments are ignored. Does nothing if previousSession and newSession are the same session.
requiresSecureDecoder
abstract boolean requiresSecureDecoder(String mimeType)
Returns whether this 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.
The session must be in stateSTATE_OPENED or STATE_OPENED_WITH_KEYS.