@UnstableApi
public interface DrmSession

Known direct subclasses
ErrorStateDrmSession

A DrmSession that's in a terminal error state.


A DRM session.

Summary

Nested types

Wraps the throwable which is the cause of the error state.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation DrmSession.State

The state of the DRM session.

Constants

default static final int

The session has encountered an error.

default static final int

The 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

The session is being opened.

default static final int

The session has been released.

Public methods

abstract void

Increments the reference count.

abstract @Nullable CryptoConfig

Returns a CryptoConfig for the open session, or null if called before the session has been opened or after it's been released.

abstract @Nullable DrmSession.DrmSessionException

Returns the cause of the error state, or null if getState is not STATE_ERROR.

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 STATE_ERROR, STATE_RELEASED, STATE_OPENING, STATE_OPENED and STATE_OPENED_WITH_KEYS.

default boolean

Returns whether this session allows playback of clear samples prior to keys being loaded.

abstract @Nullable Map<StringString>

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

Decrements the reference count.

default static void
replaceSession(
    @Nullable DrmSession previousSession,
    @Nullable DrmSession newSession
)

Acquires newSession then releases previousSession.

abstract boolean

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_OPENING

default static final int STATE_OPENING = 2

The session is being opened.

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 DrmSessionEventListener.EventDispatcher used to route DRM-related events dispatched from this session, or null if no event handling is needed.

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.

getSchemeUuid

abstract UUID getSchemeUuid()

Returns the DRM scheme UUID for this session.

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<StringStringqueryKeyStatus()

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<StringString>

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 DrmSessionEventListener.EventDispatcher to disconnect when the session is released (the same instance (possibly null) that was passed by the caller to acquire).

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.