DefaultDrmSessionManager
@UnstableApi
public class DefaultDrmSessionManager implements DrmSessionManager
A DrmSessionManager that supports playbacks using ExoMediaDrm.
This implementation supports pre-acquisition of sessions using preacquireSession.
Summary
Nested types |
|---|
public final class DefaultDrmSessionManager.BuilderBuilder for |
public final class DefaultDrmSessionManager.MissingSchemeDataException extends ExceptionSignals that the |
@DocumentedDetermines the action to be done after a session acquired. |
Constants |
|
|---|---|
static final long |
DEFAULT_SESSION_KEEPALIVE_MS = 300000Default value for |
static final int |
Number of times to retry for initial provisioning and key request for reporting error. |
static final int |
MODE_DOWNLOAD = 2Downloads an offline license or renews an existing one. |
static final int |
MODE_PLAYBACK = 0Loads and refreshes (if necessary) a license for playback. |
static final int |
MODE_QUERY = 1Restores an offline license to allow its status to be queried. |
static final int |
MODE_RELEASE = 3Releases an existing offline license. |
static final String |
PLAYREADY_CUSTOM_DATA_KEY = "PRCustomData"A key for specifying PlayReady custom data in the key request parameters passed to |
Public methods |
|
|---|---|
@Nullable DrmSession |
acquireSession(Returns a |
int |
@C.CryptoTypeReturns the |
DrmSessionManager.DrmSessionReference |
preacquireSession(Pre-acquires a DRM session for the specified |
final void |
prepare()Acquires any required resources. |
final void |
release()Releases any acquired resources. |
void |
setMode(Sets the mode, which determines the role of sessions acquired from the instance. |
void |
Sets information about the player using this DRM session manager. |
Inherited Constants |
||
|---|---|---|
|
Constants
DEFAULT_SESSION_KEEPALIVE_MS
public static final long DEFAULT_SESSION_KEEPALIVE_MS = 300000
Default value for setSessionKeepaliveMs.
INITIAL_DRM_REQUEST_RETRY_COUNT
public static final int INITIAL_DRM_REQUEST_RETRY_COUNT = 3
Number of times to retry for initial provisioning and key request for reporting error.
MODE_DOWNLOAD
public static final int MODE_DOWNLOAD = 2
Downloads an offline license or renews an existing one.
MODE_PLAYBACK
public static final int MODE_PLAYBACK = 0
Loads and refreshes (if necessary) a license for playback. Supports streaming and offline licenses.
MODE_QUERY
public static final int MODE_QUERY = 1
Restores an offline license to allow its status to be queried.
PLAYREADY_CUSTOM_DATA_KEY
public static final String PLAYREADY_CUSTOM_DATA_KEY = "PRCustomData"
A key for specifying PlayReady custom data in the key request parameters passed to setKeyRequestParameters.
Public methods
acquireSession
public @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
public 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
public 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 |
prepare
public final 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.
setMode
public void setMode(
@DefaultDrmSessionManager.Mode int mode,
@Nullable byte[] offlineLicenseKeySetId
)
Sets the mode, which determines the role of sessions acquired from the instance. This must be called before acquireSession is called.
By default, the mode is MODE_PLAYBACK and a streaming license is requested when required.
mode must be one of these:
MODE_PLAYBACK: IfofflineLicenseKeySetIdis null then a streaming license is requested. Otherwise, the offline license is restored.MODE_QUERY:offlineLicenseKeySetIdcannot be null. The offline license is restored to allow its status to be queried.MODE_DOWNLOAD: IfofflineLicenseKeySetIdis null then an offline license is requested. Otherwise, the offline license is renewed.MODE_RELEASE:offlineLicenseKeySetIdcannot be null. The offline license is released.
| Parameters | |
|---|---|
@DefaultDrmSessionManager.Mode int mode |
The mode to be set. |
@Nullable byte[] offlineLicenseKeySetId |
The key set id of the license to be used with the given mode. |