DrmSessionManagerpublic class DefaultDrmSessionManager extends Object implements DrmSessionManager
DrmSessionManager that supports playbacks using ExoMediaDrm.| Modifier and Type | Class | Description |
|---|---|---|
static class |
DefaultDrmSessionManager.Builder |
Builder for
DefaultDrmSessionManager instances. |
static class |
DefaultDrmSessionManager.MissingSchemeDataException |
Signals that the
Format.drmInitData passed to acquireSession(android.os.Looper, com.google.android.exoplayer2.drm.DrmSessionEventListener.EventDispatcher, com.google.android.exoplayer2.Format) does not contain
scheme data for the required UUID. |
static interface |
DefaultDrmSessionManager.Mode |
Determines the action to be done after a session acquired.
|
| Modifier and Type | Field | Description |
|---|---|---|
static long |
DEFAULT_SESSION_KEEPALIVE_MS |
Default value for
DefaultDrmSessionManager.Builder.setSessionKeepaliveMs(long). |
static int |
INITIAL_DRM_REQUEST_RETRY_COUNT |
Number of times to retry for initial provisioning and key request for reporting error.
|
static int |
MODE_DOWNLOAD |
Downloads an offline license or renews an existing one.
|
static int |
MODE_PLAYBACK |
Loads and refreshes (if necessary) a license for playback.
|
static int |
MODE_QUERY |
Restores an offline license to allow its status to be queried.
|
static int |
MODE_RELEASE |
Releases an existing offline license.
|
static String |
PLAYREADY_CUSTOM_DATA_KEY |
A key for specifying PlayReady custom data in the key request parameters passed to
DefaultDrmSessionManager.Builder.setKeyRequestParameters(Map). |
DRM_UNSUPPORTED, DUMMY| Constructor | Description |
|---|---|
DefaultDrmSessionManager(UUID uuid,
ExoMediaDrm exoMediaDrm,
MediaDrmCallback callback,
HashMap<String,String> keyRequestParameters) |
Deprecated.
Use
DefaultDrmSessionManager.Builder instead. |
DefaultDrmSessionManager(UUID uuid,
ExoMediaDrm exoMediaDrm,
MediaDrmCallback callback,
HashMap<String,String> keyRequestParameters,
boolean multiSession) |
Deprecated.
Use
DefaultDrmSessionManager.Builder instead. |
DefaultDrmSessionManager(UUID uuid,
ExoMediaDrm exoMediaDrm,
MediaDrmCallback callback,
HashMap<String,String> keyRequestParameters,
boolean multiSession,
int initialDrmRequestRetryCount) |
Deprecated.
Use
DefaultDrmSessionManager.Builder instead. |
| Modifier and Type | Method | Description |
|---|---|---|
DrmSession |
acquireSession(Looper playbackLooper,
DrmSessionEventListener.EventDispatcher eventDispatcher,
Format format) |
Returns a
DrmSession for the specified Format, with an incremented reference
count. |
Class<? extends ExoMediaCrypto> |
getExoMediaCryptoType(Format format) |
Returns the
ExoMediaCrypto type associated to sessions acquired for the given Format. |
void |
prepare() |
Acquires any required resources.
|
void |
release() |
Releases any acquired resources.
|
void |
setMode(int mode,
byte[] offlineLicenseKeySetId) |
Sets the mode, which determines the role of sessions acquired from the instance.
|
public static final String PLAYREADY_CUSTOM_DATA_KEY
DefaultDrmSessionManager.Builder.setKeyRequestParameters(Map).public static final int MODE_PLAYBACK
public static final int MODE_QUERY
public static final int MODE_DOWNLOAD
public static final int MODE_RELEASE
public static final int INITIAL_DRM_REQUEST_RETRY_COUNT
public static final long DEFAULT_SESSION_KEEPALIVE_MS
DefaultDrmSessionManager.Builder.setSessionKeepaliveMs(long).@Deprecated public DefaultDrmSessionManager(UUID uuid, ExoMediaDrm exoMediaDrm, MediaDrmCallback callback, @Nullable HashMap<String,String> keyRequestParameters)
DefaultDrmSessionManager.Builder instead.uuid - The UUID of the drm scheme.exoMediaDrm - An underlying ExoMediaDrm for use by the manager.callback - Performs key and provisioning requests.keyRequestParameters - An optional map of parameters to pass as the last argument to
ExoMediaDrm.getKeyRequest(byte[], List, int, HashMap). May be null.@Deprecated public DefaultDrmSessionManager(UUID uuid, ExoMediaDrm exoMediaDrm, MediaDrmCallback callback, @Nullable HashMap<String,String> keyRequestParameters, boolean multiSession)
DefaultDrmSessionManager.Builder instead.uuid - The UUID of the drm scheme.exoMediaDrm - An underlying ExoMediaDrm for use by the manager.callback - Performs key and provisioning requests.keyRequestParameters - An optional map of parameters to pass as the last argument to
ExoMediaDrm.getKeyRequest(byte[], List, int, HashMap). May be null.multiSession - A boolean that specify whether multiple key session support is enabled.
Default is false.@Deprecated public DefaultDrmSessionManager(UUID uuid, ExoMediaDrm exoMediaDrm, MediaDrmCallback callback, @Nullable HashMap<String,String> keyRequestParameters, boolean multiSession, int initialDrmRequestRetryCount)
DefaultDrmSessionManager.Builder instead.uuid - The UUID of the drm scheme.exoMediaDrm - An underlying ExoMediaDrm for use by the manager.callback - Performs key and provisioning requests.keyRequestParameters - An optional map of parameters to pass as the last argument to
ExoMediaDrm.getKeyRequest(byte[], List, int, HashMap). May be null.multiSession - A boolean that specify whether multiple key session support is enabled.
Default is false.initialDrmRequestRetryCount - The number of times to retry for initial provisioning and
key request before reporting error.public void setMode(@Mode int mode, @Nullable byte[] offlineLicenseKeySetId)
acquireSession(Looper, DrmSessionEventListener.EventDispatcher, Format)
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: If offlineLicenseKeySetId is null then a streaming
license is requested. Otherwise, the offline license is restored.
MODE_QUERY: offlineLicenseKeySetId cannot be null. The offline license
is restored to allow its status to be queried.
MODE_DOWNLOAD: If offlineLicenseKeySetId is null then an offline license
is requested. Otherwise, the offline license is renewed.
MODE_RELEASE: offlineLicenseKeySetId cannot be null. The offline license
is released.
mode - The mode to be set.offlineLicenseKeySetId - The key set id of the license to be used with the given mode.public final void prepare()
DrmSessionManagerDrmSessionManager.release() must be called to ensure the acquired resources are released. After
releasing, an instance may be re-prepared.
prepare in interface DrmSessionManagerpublic final void release()
DrmSessionManagerrelease in interface DrmSessionManager@Nullable public DrmSession acquireSession(Looper playbackLooper, @Nullable DrmSessionEventListener.EventDispatcher eventDispatcher, Format format)
DrmSessionManagerDrmSession for the specified Format, with an incremented reference
count. May return null if the Format.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 DrmSession.release(DrmSessionEventListener.EventDispatcher) to decrement the reference count.
If the provided Format contains a null Format.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.
acquireSession in interface DrmSessionManagerplaybackLooper - The looper associated with the media playback thread.eventDispatcher - The DrmSessionEventListener.EventDispatcher used to distribute
events, and passed on to DrmSession.acquire(DrmSessionEventListener.EventDispatcher).format - The Format for which to acquire a DrmSession.Format.drmInitData is null.@Nullable public Class<? extends ExoMediaCrypto> getExoMediaCryptoType(Format format)
DrmSessionManagerExoMediaCrypto type associated to sessions acquired for the given Format. Returns the UnsupportedMediaCrypto type if this DRM session manager does not
support any of the DRM schemes defined in the given Format. Returns null if Format.drmInitData is null and DrmSessionManager.acquireSession(android.os.Looper, com.google.android.exoplayer2.drm.DrmSessionEventListener.EventDispatcher, com.google.android.exoplayer2.Format) would return null for the given Format.getExoMediaCryptoType in interface DrmSessionManagerformat - The Format for which to return the ExoMediaCrypto type.ExoMediaCrypto type associated to sessions acquired using the given Format, or UnsupportedMediaCrypto if this DRM session manager does not support any
of the DRM schemes defined in the given Format. May be null if Format.drmInitData is null and DrmSessionManager.acquireSession(android.os.Looper, com.google.android.exoplayer2.drm.DrmSessionEventListener.EventDispatcher, com.google.android.exoplayer2.Format) would return null for the given
Format.