public class DefaultDrmSessionManager<T extends ExoMediaCrypto> extends java.lang.Object implements DrmSessionManager<T>, com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager<T>
DrmSessionManager
that supports playbacks using ExoMediaDrm
.Modifier and Type | Class and Description |
---|---|
static interface |
DefaultDrmSessionManager.EventListener
Listener of
DefaultDrmSessionManager events. |
static interface |
DefaultDrmSessionManager.Mode
Determines the action to be done after a session acquired.
|
Modifier and Type | Field and Description |
---|---|
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 java.lang.String |
PLAYREADY_CUSTOM_DATA_KEY
The key to use when passing CustomData to a PlayReady instance in an optional parameter map.
|
Constructor and Description |
---|
DefaultDrmSessionManager(java.util.UUID uuid,
ExoMediaDrm<T> mediaDrm,
MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
DefaultDrmSessionManager.EventListener eventListener) |
DefaultDrmSessionManager(java.util.UUID uuid,
ExoMediaDrm<T> mediaDrm,
MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
DefaultDrmSessionManager.EventListener eventListener,
boolean multiSession) |
DefaultDrmSessionManager(java.util.UUID uuid,
ExoMediaDrm<T> mediaDrm,
MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
DefaultDrmSessionManager.EventListener eventListener,
boolean multiSession,
int initialDrmRequestRetryCount) |
Modifier and Type | Method and Description |
---|---|
DrmSession<T> |
acquireSession(android.os.Looper playbackLooper,
DrmInitData drmInitData)
Acquires a
DrmSession for the specified DrmInitData . |
boolean |
canAcquireSession(DrmInitData drmInitData)
Returns whether the manager is capable of acquiring a session for the given
DrmInitData . |
byte[] |
getPropertyByteArray(java.lang.String key)
Provides access to
ExoMediaDrm.getPropertyByteArray(String) . |
java.lang.String |
getPropertyString(java.lang.String key)
Provides access to
ExoMediaDrm.getPropertyString(String) . |
static DefaultDrmSessionManager<FrameworkMediaCrypto> |
newFrameworkInstance(java.util.UUID uuid,
MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
DefaultDrmSessionManager.EventListener eventListener)
Instantiates a new instance.
|
static DefaultDrmSessionManager<FrameworkMediaCrypto> |
newPlayReadyInstance(MediaDrmCallback callback,
java.lang.String customData,
android.os.Handler eventHandler,
DefaultDrmSessionManager.EventListener eventListener)
Instantiates a new instance using the PlayReady scheme.
|
static DefaultDrmSessionManager<FrameworkMediaCrypto> |
newWidevineInstance(MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
DefaultDrmSessionManager.EventListener eventListener)
Instantiates a new instance using the Widevine scheme.
|
void |
onProvisionCompleted()
Called by a session when it successfully completes a provisioning operation.
|
void |
onProvisionError(java.lang.Exception error)
Called by a session when it fails to perform a provisioning operation.
|
void |
provisionRequired(com.google.android.exoplayer2.drm.DefaultDrmSession<T> session)
Called when a session requires provisioning.
|
void |
releaseSession(DrmSession<T> session)
Releases a
DrmSession . |
void |
setMode(int mode,
byte[] offlineLicenseKeySetId)
Sets the mode, which determines the role of sessions acquired from the instance.
|
void |
setPropertyByteArray(java.lang.String key,
byte[] value)
Provides access to
ExoMediaDrm.setPropertyByteArray(String, byte[]) . |
void |
setPropertyString(java.lang.String key,
java.lang.String value)
Provides access to
ExoMediaDrm.setPropertyString(String, String) . |
public static final java.lang.String PLAYREADY_CUSTOM_DATA_KEY
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 DefaultDrmSessionManager(java.util.UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, DefaultDrmSessionManager.EventListener eventListener)
uuid
- The UUID of the drm scheme.mediaDrm
- An underlying ExoMediaDrm
for use by the manager.callback
- Performs key and provisioning requests.optionalKeyRequestParameters
- An optional map of parameters to pass as the last argument
to ExoMediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
. May be null.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public DefaultDrmSessionManager(java.util.UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, DefaultDrmSessionManager.EventListener eventListener, boolean multiSession)
uuid
- The UUID of the drm scheme.mediaDrm
- An underlying ExoMediaDrm
for use by the manager.callback
- Performs key and provisioning requests.optionalKeyRequestParameters
- An optional map of parameters to pass as the last argument
to ExoMediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
. May be null.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.multiSession
- A boolean that specify whether multiple key session support is enabled.
Default is false.public DefaultDrmSessionManager(java.util.UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, DefaultDrmSessionManager.EventListener eventListener, boolean multiSession, int initialDrmRequestRetryCount)
uuid
- The UUID of the drm scheme.mediaDrm
- An underlying ExoMediaDrm
for use by the manager.callback
- Performs key and provisioning requests.optionalKeyRequestParameters
- An optional map of parameters to pass as the last argument
to ExoMediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
. May be null.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.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 static DefaultDrmSessionManager<FrameworkMediaCrypto> newWidevineInstance(MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, DefaultDrmSessionManager.EventListener eventListener) throws UnsupportedDrmException
callback
- Performs key and provisioning requests.optionalKeyRequestParameters
- An optional map of parameters to pass as the last argument
to ExoMediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
. May be null.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.UnsupportedDrmException
- If the specified DRM scheme is not supported.public static DefaultDrmSessionManager<FrameworkMediaCrypto> newPlayReadyInstance(MediaDrmCallback callback, java.lang.String customData, android.os.Handler eventHandler, DefaultDrmSessionManager.EventListener eventListener) throws UnsupportedDrmException
Note that PlayReady is unsupported by most Android devices, with the exception of Android TV devices, which do provide support.
callback
- Performs key and provisioning requests.customData
- Optional custom data to include in requests generated by the instance.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.UnsupportedDrmException
- If the specified DRM scheme is not supported.public static DefaultDrmSessionManager<FrameworkMediaCrypto> newFrameworkInstance(java.util.UUID uuid, MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, DefaultDrmSessionManager.EventListener eventListener) throws UnsupportedDrmException
uuid
- The UUID of the drm scheme.callback
- Performs key and provisioning requests.optionalKeyRequestParameters
- An optional map of parameters to pass as the last argument
to ExoMediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)
. May be null.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.UnsupportedDrmException
- If the specified DRM scheme is not supported.public final java.lang.String getPropertyString(java.lang.String key)
ExoMediaDrm.getPropertyString(String)
.
This method may be called when the manager is in any state.
key
- The key to request.public final void setPropertyString(java.lang.String key, java.lang.String value)
ExoMediaDrm.setPropertyString(String, String)
.
This method may be called when the manager is in any state.
key
- The property to write.value
- The value to write.public final byte[] getPropertyByteArray(java.lang.String key)
ExoMediaDrm.getPropertyByteArray(String)
.
This method may be called when the manager is in any state.
key
- The key to request.public final void setPropertyByteArray(java.lang.String key, byte[] value)
ExoMediaDrm.setPropertyByteArray(String, byte[])
.
This method may be called when the manager is in any state.
key
- The property to write.value
- The value to write.public void setMode(int mode, byte[] offlineLicenseKeySetId)
acquireSession(Looper, DrmInitData)
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, a streaming license is
requested otherwise the offline license is restored.
MODE_QUERY
: offlineLicenseKeySetId
can not be null. The offline license
is restored.
MODE_DOWNLOAD
: If offlineLicenseKeySetId
is null, an offline license is
requested otherwise the offline license is renewed.
MODE_RELEASE
: offlineLicenseKeySetId
can not 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 boolean canAcquireSession(@NonNull DrmInitData drmInitData)
DrmSessionManager
DrmInitData
.canAcquireSession
in interface DrmSessionManager<T extends ExoMediaCrypto>
drmInitData
- DRM initialization data.DrmInitData
.public DrmSession<T> acquireSession(android.os.Looper playbackLooper, DrmInitData drmInitData)
DrmSessionManager
DrmSession
for the specified DrmInitData
. The DrmSession
must be returned to DrmSessionManager.releaseSession(DrmSession)
when it is no longer required.acquireSession
in interface DrmSessionManager<T extends ExoMediaCrypto>
playbackLooper
- The looper associated with the media playback thread.drmInitData
- DRM initialization data. All contained DrmInitData.SchemeData
s must contain
non-null DrmInitData.SchemeData.data
.public void releaseSession(DrmSession<T> session)
DrmSessionManager
DrmSession
.releaseSession
in interface DrmSessionManager<T extends ExoMediaCrypto>
public void provisionRequired(com.google.android.exoplayer2.drm.DefaultDrmSession<T> session)
com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager
provision()
to have this session perform the provisioning operation. The manager
will call DefaultDrmSession.onProvisionCompleted()
when provisioning has
completed, or DefaultDrmSession.onProvisionError(java.lang.Exception)
if provisioning fails.provisionRequired
in interface com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager<T extends ExoMediaCrypto>
session
- The session.public void onProvisionCompleted()
com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager
onProvisionCompleted
in interface com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager<T extends ExoMediaCrypto>
public void onProvisionError(java.lang.Exception error)
com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager
onProvisionError
in interface com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager<T extends ExoMediaCrypto>
error
- The error that occurred.