DrmSessionManager
@UnstableApi
public interface DrmSessionManager
DefaultDrmSessionManager |
A |
Manages a DRM session.
Summary
Nested types |
|---|
public interface DrmSessionManager.DrmSessionReferenceRepresents a single reference count of a |
Constants |
|
|---|---|
default static final DrmSessionManager |
An instance that supports no DRM schemes. |
Public methods |
|
|---|---|
abstract @Nullable DrmSession |
acquireSession(Returns a |
abstract int |
@C.CryptoTypeReturns the |
default DrmSessionManager.DrmSessionReference |
preacquireSession(Pre-acquires a DRM session for the specified |
default void |
prepare()Acquires any required resources. |
default void |
release()Releases any acquired resources. |
abstract void |
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 |
Format format |
The |
| Returns | |
|---|---|
@Nullable DrmSession |
The DRM session. May be null if the given |
getCryptoType
@C.CryptoType
abstract int getCryptoType(Format format)
Returns the C.CryptoType that the DRM session manager will use for a given Format. 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.
| Returns | |
|---|---|
int |
The |
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 DrmSessionReference instance.
| Parameters | |
|---|---|
@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher |
The |
Format format |
The |
| Returns | |
|---|---|
DrmSessionManager.DrmSessionReference |
A releaser for the pre-acquired session. Guaranteed to be non-null even if the matching |