public class StreamingDrmSessionManager<T extends ExoMediaCrypto> extends Object implements DrmSessionManager<T>
DrmSessionManager
implementations that support streaming playbacks
using ExoMediaDrm
.Modifier and Type | Class and Description |
---|---|
static interface |
StreamingDrmSessionManager.EventListener
Interface definition for a callback to be notified of
StreamingDrmSessionManager
events. |
Modifier and Type | Field and Description |
---|---|
static String |
PLAYREADY_CUSTOM_DATA_KEY
The key to use when passing CustomData to a PlayReady instance in an optional parameter map.
|
static UUID |
PLAYREADY_UUID
UUID for the PlayReady DRM scheme.
|
static UUID |
WIDEVINE_UUID
UUID for the Widevine DRM scheme.
|
STATE_CLOSED, STATE_ERROR, STATE_OPENED, STATE_OPENED_WITH_KEYS, STATE_OPENING
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the session.
|
Exception |
getError()
Gets the cause of the error state.
|
T |
getMediaCrypto()
Gets an
ExoMediaCrypto for the open session. |
byte[] |
getPropertyByteArray(String key)
Provides access to
MediaDrm.getPropertyByteArray(String) . |
String |
getPropertyString(String key)
Provides access to
MediaDrm.getPropertyString(String) . |
int |
getState()
Gets the current state of the session.
|
static StreamingDrmSessionManager<FrameworkMediaCrypto> |
newFrameworkInstance(UUID uuid,
Looper playbackLooper,
MediaDrmCallback callback,
HashMap<String,String> optionalKeyRequestParameters,
Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener) |
static <T extends ExoMediaCrypto> |
newInstance(UUID uuid,
Looper playbackLooper,
MediaDrmCallback callback,
HashMap<String,String> optionalKeyRequestParameters,
Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener,
ExoMediaDrm<T> mediaDrm) |
static StreamingDrmSessionManager<FrameworkMediaCrypto> |
newPlayReadyInstance(Looper playbackLooper,
MediaDrmCallback callback,
String customData,
Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener)
Instantiates a new instance using the PlayReady scheme.
|
static StreamingDrmSessionManager<FrameworkMediaCrypto> |
newWidevineInstance(Looper playbackLooper,
MediaDrmCallback callback,
HashMap<String,String> optionalKeyRequestParameters,
Handler eventHandler,
StreamingDrmSessionManager.EventListener eventListener)
Instantiates a new instance using the Widevine scheme.
|
void |
open(DrmInitData drmInitData)
Opens the session, possibly asynchronously.
|
boolean |
requiresSecureDecoderComponent(String mimeType)
Whether the session requires a secure decoder for the specified mime type.
|
void |
setPropertyByteArray(String key,
byte[] value)
Provides access to
MediaDrm.setPropertyByteArray(String, byte[]) . |
void |
setPropertyString(String key,
String value)
Provides access to
MediaDrm.setPropertyString(String, String) . |
public static final UUID WIDEVINE_UUID
public static final UUID PLAYREADY_UUID
Note that PlayReady is unsupported by most Android devices, with the exception of Android TV devices, which do provide support.
public static final String PLAYREADY_CUSTOM_DATA_KEY
public static StreamingDrmSessionManager<FrameworkMediaCrypto> newWidevineInstance(Looper playbackLooper, MediaDrmCallback callback, HashMap<String,String> optionalKeyRequestParameters, Handler eventHandler, StreamingDrmSessionManager.EventListener eventListener) throws UnsupportedDrmException
playbackLooper
- The looper associated with the media playback thread. Should usually be
obtained using ExoPlayer.getPlaybackLooper()
.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(Looper playbackLooper, MediaDrmCallback callback, String customData, 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.
playbackLooper
- The looper associated with the media playback thread. Should usually be
obtained using ExoPlayer.getPlaybackLooper()
.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(UUID uuid, Looper playbackLooper, MediaDrmCallback callback, HashMap<String,String> optionalKeyRequestParameters, Handler eventHandler, StreamingDrmSessionManager.EventListener eventListener) throws UnsupportedDrmException
uuid
- The UUID of the drm scheme.playbackLooper
- The looper associated with the media playback thread. Should usually be
obtained using ExoPlayer.getPlaybackLooper()
.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 <T extends ExoMediaCrypto> StreamingDrmSessionManager<T> newInstance(UUID uuid, Looper playbackLooper, MediaDrmCallback callback, HashMap<String,String> optionalKeyRequestParameters, Handler eventHandler, StreamingDrmSessionManager.EventListener eventListener, ExoMediaDrm<T> mediaDrm) throws UnsupportedDrmException
uuid
- The UUID of the drm scheme.playbackLooper
- The looper associated with the media playback thread. Should usually be
obtained using ExoPlayer.getPlaybackLooper()
.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.mediaDrm
- An underlying ExoMediaDrm
for use by the manager.UnsupportedDrmException
- If the specified DRM scheme is not supported.public final int getState()
DrmSessionManager
getState
in interface DrmSessionManager<T extends ExoMediaCrypto>
DrmSessionManager.STATE_ERROR
, DrmSessionManager.STATE_CLOSED
, DrmSessionManager.STATE_OPENING
,
DrmSessionManager.STATE_OPENED
and DrmSessionManager.STATE_OPENED_WITH_KEYS
.public final T getMediaCrypto()
DrmSessionManager
ExoMediaCrypto
for the open session.
This method may be called when the manager is in the following states:
DrmSessionManager.STATE_OPENED
, DrmSessionManager.STATE_OPENED_WITH_KEYS
getMediaCrypto
in interface DrmSessionManager<T extends ExoMediaCrypto>
ExoMediaCrypto
for the open session.public boolean requiresSecureDecoderComponent(String mimeType)
DrmSessionManager
Normally this method should return MediaCrypto.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 manager is in the following states:
DrmSessionManager.STATE_OPENED
, DrmSessionManager.STATE_OPENED_WITH_KEYS
requiresSecureDecoderComponent
in interface DrmSessionManager<T extends ExoMediaCrypto>
public final Exception getError()
DrmSessionManager
This method may be called when the manager is in any state.
getError
in interface DrmSessionManager<T extends ExoMediaCrypto>
DrmSessionManager.STATE_ERROR
. Null otherwise.public final String getPropertyString(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(String key, 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(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(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 open(DrmInitData drmInitData)
DrmSessionManager
open
in interface DrmSessionManager<T extends ExoMediaCrypto>
drmInitData
- DRM initialization data.public void close()
DrmSessionManager
close
in interface DrmSessionManager<T extends ExoMediaCrypto>