@Deprecated public class ExoPlayerDrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto> extends java.lang.Object implements com.google.android.exoplayer.drm.DrmSessionManager<T>, DrmSession<T>
DrmSessionManager
that supports offline playback of DRM restricted content
using MediaDrm
.
This code was adapted from com.google.android.exoplayer2.drm.DefaultDrmSessionManager to provide similar functionality in ExoPlayer version 1.
Modifier and Type | Class and Description |
---|---|
static interface |
ExoPlayerDrmSessionManager.EventListener
Deprecated.
Listener of
ExoPlayerDrmSessionManager events. |
static interface |
ExoPlayerDrmSessionManager.Mode
Deprecated.
Determines the action to be done after a session acquired.
|
DrmSession.DrmSessionException
Modifier and Type | Field and Description |
---|---|
static int |
MODE_DOWNLOAD
Deprecated.
Downloads an offline license or renews an existing one.
|
static int |
MODE_PLAYBACK
Deprecated.
Loads and refreshes (if necessary) a license for playback.
|
static int |
MODE_QUERY
Deprecated.
Restores an offline license to allow its status to be queried.
|
static int |
MODE_RELEASE
Deprecated.
Releases an existing offline license.
|
static java.lang.String |
PLAY_READY_CUSTOM_DATA_KEY
Deprecated.
The key to use when passing CustomData to a PlayReady instance in an optional parameter map.
|
Constructor and Description |
---|
ExoPlayerDrmSessionManager(java.util.UUID uuid,
com.google.android.exoplayer.drm.ExoMediaDrm<T> mediaDrm,
com.google.android.exoplayer.drm.MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
ExoPlayerDrmSessionManager.EventListener eventListener)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
DrmSession<T> |
acquireSession(com.google.android.exoplayer.drm.DrmInitData drmInitData)
Deprecated.
|
void |
close()
Deprecated.
Closes the session.
|
DrmException |
getDrmError()
Deprecated.
|
DrmSession.DrmSessionException |
getError()
Deprecated.
Returns the cause of the error state.
|
T |
getMediaCrypto()
Deprecated.
Provides reference to the current DRM session.
|
byte[] |
getOfflineLicenseKeySetId()
Deprecated.
Returns the key set id of the offline license loaded into this session, if there is one.
|
byte[] |
getPropertyByteArray(java.lang.String key)
Deprecated.
Provides access to
MediaDrm.getPropertyByteArray(String) . |
java.lang.String |
getPropertyString(java.lang.String key)
Deprecated.
Provides access to
MediaDrm.getPropertyString(String) . |
int |
getState()
Deprecated.
Returns the current state of the session.
|
static ExoPlayerDrmSessionManager<com.google.android.exoplayer.drm.FrameworkMediaCrypto> |
newFrameworkInstance(java.util.UUID uuid,
com.google.android.exoplayer.drm.MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
ExoPlayerDrmSessionManager.EventListener eventListener)
Deprecated.
Instantiates a new instance.
|
static ExoPlayerDrmSessionManager<com.google.android.exoplayer.drm.FrameworkMediaCrypto> |
newPlayReadyInstance(com.google.android.exoplayer.drm.MediaDrmCallback callback,
java.lang.String customData,
android.os.Handler eventHandler,
ExoPlayerDrmSessionManager.EventListener eventListener)
Deprecated.
Instantiates a new instance using the PlayReady scheme.
|
static ExoPlayerDrmSessionManager<com.google.android.exoplayer.drm.FrameworkMediaCrypto> |
newWidevineInstance(android.os.Looper playbackLooper,
com.google.android.exoplayer.drm.MediaDrmCallback callback,
java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
android.os.Handler eventHandler,
ExoPlayerDrmSessionManager.EventListener eventListener)
Deprecated.
Instantiates a new instance using the Widevine scheme.
|
void |
open(com.google.android.exoplayer.drm.DrmInitData drmInitData)
Deprecated.
Opens the session, possibly asynchronously.
|
java.util.Map<java.lang.String,java.lang.String> |
queryKeyStatus()
Deprecated.
Returns an informative description of the key status for the session.
|
void |
releaseSession(DrmSession<T> session)
Deprecated.
|
boolean |
requiresSecureDecoderComponent(java.lang.String mimeType)
Deprecated.
Whether the session requires a secure decoder for the specified mime type.
|
void |
setMode(int mode,
byte[] offlineLicenseKeySetId)
Deprecated.
Sets the mode, which determines the role of sessions acquired from the instance.
|
void |
setPlaybackLooper(android.os.Looper looper)
Deprecated.
Sets the playback looper that will be used.
|
void |
setPropertyByteArray(java.lang.String key,
byte[] value)
Deprecated.
Provides access to
MediaDrm.setPropertyByteArray(String, byte[]) . |
void |
setPropertyString(java.lang.String key,
java.lang.String value)
Deprecated.
Provides access to
MediaDrm.setPropertyString(String, String) . |
public static final java.lang.String PLAY_READY_CUSTOM_DATA_KEY
public static final int MODE_PLAYBACK
public static final int MODE_QUERY
DrmSessionManager.STATE_ERROR
.public static final int MODE_DOWNLOAD
public static final int MODE_RELEASE
public ExoPlayerDrmSessionManager(java.util.UUID uuid, com.google.android.exoplayer.drm.ExoMediaDrm<T> mediaDrm, com.google.android.exoplayer.drm.MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, ExoPlayerDrmSessionManager.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 ExoPlayerDrmSessionManager<com.google.android.exoplayer.drm.FrameworkMediaCrypto> newWidevineInstance(android.os.Looper playbackLooper, com.google.android.exoplayer.drm.MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, ExoPlayerDrmSessionManager.EventListener eventListener) throws com.google.android.exoplayer.drm.UnsupportedDrmException, android.media.UnsupportedSchemeException
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.com.google.android.exoplayer.drm.UnsupportedDrmException
- If the specified DRM scheme is not supported.android.media.UnsupportedSchemeException
public static ExoPlayerDrmSessionManager<com.google.android.exoplayer.drm.FrameworkMediaCrypto> newPlayReadyInstance(com.google.android.exoplayer.drm.MediaDrmCallback callback, java.lang.String customData, android.os.Handler eventHandler, ExoPlayerDrmSessionManager.EventListener eventListener) throws com.google.android.exoplayer.drm.UnsupportedDrmException, android.media.UnsupportedSchemeException
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.com.google.android.exoplayer.drm.UnsupportedDrmException
- If the specified DRM scheme is not supported.android.media.UnsupportedSchemeException
public static ExoPlayerDrmSessionManager<com.google.android.exoplayer.drm.FrameworkMediaCrypto> newFrameworkInstance(java.util.UUID uuid, com.google.android.exoplayer.drm.MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, android.os.Handler eventHandler, ExoPlayerDrmSessionManager.EventListener eventListener) throws com.google.android.exoplayer.drm.UnsupportedDrmException, android.media.UnsupportedSchemeException
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.com.google.android.exoplayer.drm.UnsupportedDrmException
- If the specified DRM scheme is not supported.android.media.UnsupportedSchemeException
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.
getPropertyString
in interface BrightcoveDrmSession
key
- The key to request.MediaDrm.getPropertyString(String)
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.
setPropertyString
in interface BrightcoveDrmSession
key
- The property to write.value
- The value to write.MediaDrm.setPropertyString(String, String)
public final byte[] getPropertyByteArray(java.lang.String key)
MediaDrm.getPropertyByteArray(String)
.
This method may be called when the manager is in any state.
getPropertyByteArray
in interface BrightcoveDrmSession
key
- The key to request.MediaDrm.getPropertyByteArray(String)
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.
setPropertyByteArray
in interface BrightcoveDrmSession
key
- The property to write.value
- The value to write.MediaDrm.setPropertyByteArray(String, byte[])
public void setMode(int mode, byte[] offlineLicenseKeySetId)
acquireSession(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(com.google.android.exoplayer.drm.DrmInitData drmInitData)
public void setPlaybackLooper(android.os.Looper looper)
looper
- reference to the playback looperjava.lang.IllegalStateException
- if the playback looper has been already to different instance.public void releaseSession(DrmSession<T> session)
public final int getState()
getState
in interface DrmSession<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
getState
in interface com.google.android.exoplayer.drm.DrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
DrmSessionManager.STATE_ERROR
,
DrmSessionManager.STATE_CLOSED
,
DrmSessionManager.STATE_OPENING
,
DrmSessionManager.STATE_OPENED
or
DrmSessionManager.STATE_OPENED_WITH_KEYS
.public final T getMediaCrypto()
This method may be called when the session is in the following states:
DrmSessionManager.STATE_OPENED
,
DrmSessionManager.STATE_OPENED_WITH_KEYS
getMediaCrypto
in interface DrmSession<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
getMediaCrypto
in interface com.google.android.exoplayer.drm.DrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
ExoMediaCrypto
for the open session.java.lang.IllegalStateException
- If called when a session isn't opened.public boolean requiresSecureDecoderComponent(java.lang.String mimeType)
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:
DrmSessionManager.STATE_OPENED
,
DrmSessionManager.STATE_OPENED_WITH_KEYS
requiresSecureDecoderComponent
in interface DrmSession<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
requiresSecureDecoderComponent
in interface com.google.android.exoplayer.drm.DrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
java.lang.IllegalStateException
- If called when a session isn't opened.public DrmSession.DrmSessionException getError()
DrmSession
This method may be called when the session is in any state.
getError
in interface DrmSession<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
getError
in interface com.google.android.exoplayer.drm.DrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
DrmSessionManager.STATE_ERROR
. Null otherwise.public final DrmException getDrmError()
getDrmError
in interface BrightcoveDrmSession
public java.util.Map<java.lang.String,java.lang.String> queryKeyStatus()
DrmSession
Since 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 BrightcoveDrmSession
queryKeyStatus
in interface DrmSession<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
MediaDrm#queryKeyStatus(byte[])
public byte[] getOfflineLicenseKeySetId()
DrmSession
getOfflineLicenseKeySetId
in interface BrightcoveDrmSession
getOfflineLicenseKeySetId
in interface DrmSession<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
public void open(com.google.android.exoplayer.drm.DrmInitData drmInitData)
open
in interface com.google.android.exoplayer.drm.DrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>
drmInitData
- DRM initialization data.public void close()
close
in interface com.google.android.exoplayer.drm.DrmSessionManager<T extends com.google.android.exoplayer.drm.ExoMediaCrypto>