DrmSessionManager


@UnstableApi
public interface DrmSessionManager

Known direct subclasses
DefaultDrmSessionManager

A DrmSessionManager that supports playbacks using ExoMediaDrm.


Manages a DRM session.

Summary

Nested types

Represents a single reference count of a DrmSession, while deliberately not giving access to the underlying session.

Constants

default static final DrmSessionManager

An instance that supports no DRM schemes.

Public methods

abstract @Nullable DrmSession
acquireSession(
    @Nullable DrmSessionEventListener.EventDispatcher eventDispatcher,
    Format format
)

Returns a DrmSession for the specified Format, with an incremented reference count.

abstract int

Returns the C.CryptoType that the DRM session manager will use for a given .

default DrmSessionManager.DrmSessionReference

Pre-acquires a DRM session for the specified Format.

default void

Acquires any required resources.

default void

Releases any acquired resources.

abstract void
setPlayer(Looper playbackLooper, PlayerId playerId)

Sets information about the player using this DRM session manager.

Constants

DRM_UNSUPPORTED

default static final DrmSessionManager DRM_UNSUPPORTED

An instance that supports no DRM schemes.

Public methods

acquireSession

abstract @Nullable DrmSession acquireSession(
    @Nullable DrmSessionEventListener.EventDispatcher eventDispatcher,
    Format format
)

Returns a DrmSession for the specified Format, with an incremented reference count. May return null if the drmInitData is null and the DRM session manager is not configured to attach a DrmSession to clear content. When the caller no longer needs to use a returned DrmSession, it must call release to decrement the reference count.

If the provided Format contains a null drmInitData, the returned DrmSession (if not null) will be a placeholder session which does not execute key requests, and cannot be used to handle encrypted content. However, a placeholder session may be used to configure secure decoders for playback of clear content periods, which can reduce the cost of transitioning between clear and encrypted content.

Parameters
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher

The DrmSessionEventListener.EventDispatcher used to distribute events, and passed on to acquire.

Format format

The Format for which to acquire a DrmSession.

Returns
@Nullable DrmSession

The DRM session. May be null if the given drmInitData is null.

getCryptoType

@C.CryptoType
abstract int getCryptoType(Format format)

Returns the C.CryptoType that the DRM session manager will use for a given . Returns CRYPTO_TYPE_UNSUPPORTED if the manager does not support any of the DRM schemes defined in the Format. Returns CRYPTO_TYPE_NONE if drmInitData is null and acquireSession will return null for the given Format.

Parameters
Format format

The Format.

Returns
int

The C.CryptoType that the manager will use, or @link C#CRYPTO_TYPE_UNSUPPORTED} if the manager does not support any of the DRM schemes defined in the Format. Will be CRYPTO_TYPE_NONE if drmInitData is null and acquireSession will return null for the given Format.

preacquireSession

default DrmSessionManager.DrmSessionReference preacquireSession(
    @Nullable DrmSessionEventListener.EventDispatcher eventDispatcher,
    Format format
)

Pre-acquires a DRM session for the specified Format.

This notifies the manager that a subsequent call to acquireSession with the same Format is likely, allowing a manager that supports pre-acquisition to get the required DrmSession ready in the background.

The caller must call release on the returned instance when they no longer require the pre-acquisition (i.e. they know they won't be making a matching call to acquireSession in the near future).

This manager may silently release the underlying session in order to allow another operation to complete. This will result in a subsequent call to acquireSession re-initializing a new session, including repeating key loads and other async initialization steps.

The caller must separately call acquireSession in order to obtain a session suitable for playback. The pre-acquired DrmSessionReference and full DrmSession instances are distinct. The caller must release both, and can release the DrmSessionReference before the DrmSession without affecting playback.

This can be called from any thread.

Implementations that do not support pre-acquisition always return an empty instance.

Parameters
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher

The DrmSessionEventListener.EventDispatcher used to distribute events, and passed on to acquire.

Format format

The Format for which to pre-acquire a DrmSession.

Returns
DrmSessionManager.DrmSessionReference

A releaser for the pre-acquired session. Guaranteed to be non-null even if the matching acquireSession would return null.

prepare

default void prepare()

Acquires any required resources.

release must be called to ensure the acquired resources are released. After releasing, an instance may be re-prepared.

release

default void release()

Releases any acquired resources.

setPlayer

abstract void setPlayer(Looper playbackLooper, PlayerId playerId)

Sets information about the player using this DRM session manager.

Parameters
Looper playbackLooper

The Looper associated with the player's playback thread.

PlayerId playerId

The PlayerId of the player.