public class StreamingDrmSessionManager<T extends ExoMediaCrypto> extends java.lang.Object implements DrmSessionManager<T>, DrmSession<T>
DrmSessionManager
that supports streaming playbacks using MediaDrm
.Modifier and Type | Class and Description |
---|---|
static interface |
StreamingDrmSessionManager.EventListener
Listener of
StreamingDrmSessionManager events. |
DrmSession.State
Modifier and Type | Field and Description |
---|---|
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 |
---|
StreamingDrmSessionManager(java.util.UUID uuid,
ExoMediaDrm<T> mediaDrm,
MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener) |
Modifier and Type | Method and Description |
---|---|
DrmSession<T> |
acquireSession(android.os.Looper playbackLooper,
DrmInitData drmInitData)
Acquires a
DrmSession for the specified DrmInitData . |
java.lang.Exception |
getError()
Returns the cause of the error state.
|
T |
getMediaCrypto()
Returns a
ExoMediaCrypto for the open session. |
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 StreamingDrmSessionManager<FrameworkMediaCrypto> |
newFrameworkInstance(java.util.UUID uuid,
MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener)
Instantiates a new instance.
|
static StreamingDrmSessionManager<FrameworkMediaCrypto> |
newPlayReadyInstance(MediaDrmCallback callback,
java.lang.String customData,
android.os.Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener)
Instantiates a new instance using the PlayReady scheme.
|
static StreamingDrmSessionManager<FrameworkMediaCrypto> |
newWidevineInstance(MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener)
Instantiates a new instance using the Widevine scheme.
|
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 |
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 StreamingDrmSessionManager(java.util.UUID uuid, ExoMediaDrm<T> mediaDrm, MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, StreamingDrmSessionManager.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 StreamingDrmSessionManager<FrameworkMediaCrypto> newWidevineInstance(MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, StreamingDrmSessionManager.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 StreamingDrmSessionManager<FrameworkMediaCrypto> newPlayReadyInstance(MediaDrmCallback callback, java.lang.String customData, android.os.Handler eventHandler, StreamingDrmSessionManager.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 StreamingDrmSessionManager<FrameworkMediaCrypto> newFrameworkInstance(java.util.UUID uuid, MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, StreamingDrmSessionManager.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 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.public void releaseSession(DrmSession<T> session)
DrmSessionManager
DrmSession
.releaseSession
in interface DrmSessionManager<T extends ExoMediaCrypto>
public final int getState()
DrmSession
getState
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()
DrmSession
ExoMediaCrypto
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 java.lang.Exception getError()
DrmSession
This method may be called when the session is in any state.
getError
in interface DrmSession<T extends ExoMediaCrypto>
DrmSession.STATE_ERROR
. Null otherwise.