public class DefaultDrmSessionManager<T extends ExoMediaCrypto> extends java.lang.Object implements DrmSessionManager<T>, DrmSession<T>
DrmSessionManager that supports playbacks using MediaDrm.| 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.
|
DrmSession.DrmSessionException, DrmSession.State| Modifier and Type | Field and Description |
|---|---|
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.
|
STATE_CLOSED, STATE_ERROR, STATE_OPENED, STATE_OPENED_WITH_KEYS, STATE_OPENING| 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) |
| Modifier and Type | Method and Description |
|---|---|
DrmSession<T> |
acquireSession(android.os.Looper playbackLooper,
DrmInitData drmInitData)
Acquires a
DrmSession for the specified DrmInitData. |
DrmSession.DrmSessionException |
getError()
Returns the cause of the error state.
|
T |
getMediaCrypto()
Returns a
ExoMediaCrypto for the open session. |
byte[] |
getOfflineLicenseKeySetId()
Returns the key set id of the offline license loaded into this session, if there is one.
|
byte[] |
getPropertyByteArray(java.lang.String key)
Provides access to
MediaDrm.getPropertyByteArray(String). |
java.lang.String |
getPropertyString(java.lang.String key)
Provides access to
MediaDrm.getPropertyString(String). |
int |
getState()
Returns the current state of the session.
|
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.
|
java.util.Map<java.lang.String,java.lang.String> |
queryKeyStatus()
Returns an informative description of the key status for the session.
|
void |
releaseSession(DrmSession<T> session)
Releases a
DrmSession. |
boolean |
requiresSecureDecoderComponent(java.lang.String mimeType)
Whether the session requires a secure decoder for the specified mime type.
|
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
MediaDrm.setPropertyByteArray(String, byte[]). |
void |
setPropertyString(java.lang.String key,
java.lang.String value)
Provides access to
MediaDrm.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
DrmSession.STATE_ERROR.public static final int MODE_DOWNLOAD
public static final int MODE_RELEASE
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 MediaDrm.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 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 MediaDrm.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 MediaDrm.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)
MediaDrm.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)
MediaDrm.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)
MediaDrm.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)
MediaDrm.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 DrmSession<T> acquireSession(android.os.Looper playbackLooper, DrmInitData drmInitData)
DrmSessionManagerDrmSession 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.public void releaseSession(DrmSession<T> session)
DrmSessionManagerDrmSession.releaseSession in interface DrmSessionManager<T extends ExoMediaCrypto>public final int getState()
DrmSessiongetState in interface DrmSession<T extends ExoMediaCrypto>DrmSession.STATE_ERROR, DrmSession.STATE_CLOSED, DrmSession.STATE_OPENING,
DrmSession.STATE_OPENED and DrmSession.STATE_OPENED_WITH_KEYS.public final T getMediaCrypto()
DrmSessionExoMediaCrypto for the open session.
This method may be called when the session is in the following states:
DrmSession.STATE_OPENED, DrmSession.STATE_OPENED_WITH_KEYS
getMediaCrypto in interface DrmSession<T extends ExoMediaCrypto>ExoMediaCrypto for the open session.public boolean requiresSecureDecoderComponent(java.lang.String mimeType)
DrmSession
Normally this method should return
ExoMediaCrypto.requiresSecureDecoderComponent(String), however in some cases
implementations may wish to modify the return value (i.e. to force a secure decoder even when
one is not required).
This method may be called when the session is in the following states:
DrmSession.STATE_OPENED, DrmSession.STATE_OPENED_WITH_KEYS
requiresSecureDecoderComponent in interface DrmSession<T extends ExoMediaCrypto>public final DrmSession.DrmSessionException getError()
DrmSessionThis method may be called when the session is in any state.
getError in interface DrmSession<T extends ExoMediaCrypto>DrmSession.STATE_ERROR. Null otherwise.public java.util.Map<java.lang.String,java.lang.String> queryKeyStatus()
DrmSessionSince DRM license policies vary by vendor, the specific status field names are determined by each DRM vendor. Refer to your DRM provider documentation for definitions of the field names for a particular DRM engine plugin.
queryKeyStatus in interface DrmSession<T extends ExoMediaCrypto>MediaDrm.queryKeyStatus(byte[])public byte[] getOfflineLicenseKeySetId()
DrmSessiongetOfflineLicenseKeySetId in interface DrmSession<T extends ExoMediaCrypto>