Android OpenTV Player SDK  5.27.2.1680254288
 All Classes Namespaces Functions Variables Pages
OTVCommonMediaDrmCallback Class Reference

Detailed Description

A convenience base class implementation of OTVMediaDrmCallback.

This abstract class can be used as the base class in most bespoke implementations of OTVMediaDrmCallback for streaming Widevine- or PlayReady- encrypted streams while fetching the keys from a licence server.
For most licence servers, such as Nagra's Secure Service Platform (SSP) there is already an implementation provided with this SDK - see OTVHttpMediaDrmCallback.
An object of a class implementing OTVMediaDrmCallback) must be assigned to the player for playback of encrypted content.
The configuration of the object is done in the following stages:

The Properties key-value pairs define parameters that are passed to the licence server in the HTTP header. For example:
callback.setKeyRequestProperty("Content-Type", "application/octet-stream");
The Options key-value pairs define parameters that configure the DRM session, specific to the license server. These optional fields affect the construction of the key request challenge data in the OTVMediaDrmCallback#executeKeyRequest method. For example:
callback.setKeyRequestOption("protectedClientData", "someData");
The object should be configured prior to start of playback or setting the stream path, and then assigned to the OTVVideoView instance:
videoView.setMediaDrmCallback(callback);
Configuration may also be changed during playback.

Inheritance diagram for OTVCommonMediaDrmCallback:
OTVMediaDrmCallback OTVConnectMediaDrmCallback OTVHttpMediaDrmCallback OTVSSMHttpMediaDrmCallback

Public Member Functions

String getDrmType ()
 Returns the DRM type the callback instance is configured for. More...
 
boolean isMultiSession ()
 
byte[] executeProvisionRequest (UUID uuid, ProvisionRequest request) throws MediaDrmCallbackException
 Executes a provisioning request. More...
 
void setKeyRequestProperty (String name, String value)
 Sets a header for key requests made by the callback. More...
 
void clearKeyRequestProperty (String name)
 Clears a specified header for key requests made by the callback. More...
 
void clearAllKeyRequestProperties ()
 Clears all headers for key requests made by the callback. More...
 
void setDrmType (String xDrmType)
 Set which DRM system to be used to play the stream. More...
 
void setMultiSession (boolean xIsMultiSession)
 Set if the DRM system supports multiple sessions. More...
 
void setKeyRequestOption (String name, String value)
 Sets an optional parameter for key requests. More...
 
void clearKeyRequestOption (String name)
 Clears an option for key requests. More...
 
void clearAllKeyRequestOptions ()
 Clears all options for key requests. More...
 
HashMap< String, String > getKeyRequestOptions ()
 Gets options for key requests. More...
 
void setDrmPropertyString (String name, String value)
 Sets a drm property. More...
 
void clearAllDrmPropertyStrings ()
 Clears all properties for media drm. More...
 
HashMap< String, String > getDrmPropertyStrings ()
 Gets properties for media drm. More...
 
void setDrmPropertyByteArray (String name, byte[] value)
 Sets a drm byte array property. More...
 
void clearAllDrmPropertyByteArray ()
 Clears all byte array properties for media drm. More...
 
HashMap< String, byte[]> getDrmPropertyByteArray ()
 Gets byte array properties for media drm. More...
 
void setMutualAuthentication (SSLSocketFactory xSslSocketFactory)
 Sets SSLSocketFactory for Mutual Authentication. More...
 
byte[] executeProvisionRequest (UUID uuid, ExoMediaDrm.ProvisionRequest request) throws MediaDrmCallbackException
 Executes a provisioning request. More...
 
byte[] executeKeyRequest (UUID uuid, ExoMediaDrm.KeyRequest request) throws MediaDrmCallbackException
 Executes a key request. More...
 

Public Attributes

String OTV_DRMTYPE_WIDEVINE = "Widevine"
 Defined DRM type for Widevine. More...
 
String OTV_DRMTYPE_PLAYREADY = "PlayReady"
 Define DRM type for PlayReady. More...
 
String OTV_DRMTYPE_CONNECT = "Connect"
 Define DRM type for Connect. More...
 
String OTV_DRMTYPE_WISEPLAY = "Wiseplay"
 Define DRM type for Connect. More...
 

Protected Member Functions

 OTVCommonMediaDrmCallback (String defaultLicenseUrl)
 
byte[] executePost (String url, byte[] data, Map< String, String > requestProperties) throws IOException
 A utility for synchronously sending a POST HTTP message. More...
 
MediaDrmCallbackException generateDrmCBException (@NonNull IOException exception)
 Helper method to generate MediaDrmCallbackException with IOException. More...
 

Constructor & Destructor Documentation

OTVCommonMediaDrmCallback ( String  defaultLicenseUrl)
protected
Parameters
defaultLicenseUrlThe default license URL. Used for key requests that do not specify their own license URL.

Member Function Documentation

void clearAllDrmPropertyByteArray ( )

Clears all byte array properties for media drm.

void clearAllDrmPropertyStrings ( )

Clears all properties for media drm.

void clearAllKeyRequestOptions ( )

Clears all options for key requests.

void clearAllKeyRequestProperties ( )

Clears all headers for key requests made by the callback.

void clearKeyRequestOption ( String  name)

Clears an option for key requests.

Parameters
nameThe name of the option.
void clearKeyRequestProperty ( String  name)

Clears a specified header for key requests made by the callback.

Parameters
nameThe name of the specified header field.
byte [] executeKeyRequest ( UUID  uuid,
ExoMediaDrm.KeyRequest  request 
) throws MediaDrmCallbackException
inherited

Executes a key request.

Parameters
uuidThe UUID of the content protection scheme.12
requestThe request.
Returns
The response data.
Exceptions
MediaDrmCallbackExceptionIf an error occurred executing the request.

Implemented in OTVConnectMediaDrmCallback.

byte [] executePost ( String  url,
byte[]  data,
Map< String, String >  requestProperties 
) throws IOException
protected

A utility for synchronously sending a POST HTTP message.


Used for requesting the licence via HTTP/HTTPS. Can be overridden if special operations are required.

Parameters
urlThe URL address to post to.
dataOptional additional data to send with the POST message.
requestPropertiesA map of key-value HTTP header entries to use in the message
Exceptions
IOExceptionIf an error occurred executing the request.
byte [] executeProvisionRequest ( UUID  uuid,
ExoMediaDrm.ProvisionRequest  request 
) throws MediaDrmCallbackException
inherited

Executes a provisioning request.

Parameters
uuidThe UUID of the content protection scheme.
requestThe request.
Returns
The response data.
Exceptions
MediaDrmCallbackExceptionIf an error occurred executing the request.

Implemented in OTVConnectMediaDrmCallback.

byte [] executeProvisionRequest ( UUID  uuid,
ProvisionRequest  request 
) throws MediaDrmCallbackException

Executes a provisioning request.

Parameters
uuidThe UUID of the content protection scheme.
requestThe request.
Returns
The response data.
Exceptions
MediaDrmCallbackExceptionIf an error occurred executing the request.
MediaDrmCallbackException generateDrmCBException ( @NonNull IOException  exception)
protected

Helper method to generate MediaDrmCallbackException with IOException.

Parameters
exceptionthe IOException
Returns
a MediaDrmCallbackException object
HashMap<String, byte[]> getDrmPropertyByteArray ( )

Gets byte array properties for media drm.

The default value is null.

Returns
all drm byte array properties.

Implements OTVMediaDrmCallback.

HashMap<String, String> getDrmPropertyStrings ( )

Gets properties for media drm.

The default value is null.

Returns
all drm properties.

Implements OTVMediaDrmCallback.

String getDrmType ( )

Returns the DRM type the callback instance is configured for.

Implements OTVMediaDrmCallback.

HashMap<String, String> getKeyRequestOptions ( )

Gets options for key requests.

Returns
all key request options.

Implements OTVMediaDrmCallback.

boolean isMultiSession ( )
Returns
false if the DRM system does not support multiple sessions, otherwise return true.

Implements OTVMediaDrmCallback.

void setDrmPropertyByteArray ( String  name,
byte[]  value 
)

Sets a drm byte array property.

Parameters
nameThe name of the property.
valueThe value of the byte array property.
void setDrmPropertyString ( String  name,
String  value 
)

Sets a drm property.

Parameters
nameThe name of the property.
valueThe value of the property.
void setDrmType ( String  xDrmType)

Set which DRM system to be used to play the stream.


If not explicitly set, the default is OTV_DRMTYPE_WIDEVINE.

Parameters
xDrmType"Widevine" , "PlayReady" , "Connect" or "Wiseplay"
void setKeyRequestOption ( String  name,
String  value 
)

Sets an optional parameter for key requests.

Parameters
nameThe name of the option.
valueThe value of the option.
void setKeyRequestProperty ( String  name,
String  value 
)

Sets a header for key requests made by the callback.

Parameters
nameThe name of the header field.
valueThe value of the field.
void setMultiSession ( boolean  xIsMultiSession)

Set if the DRM system supports multiple sessions.


If not explicitly set, the default is false.

Parameters
xIsMultiSessiontrue if the DRM system should support multiple sessions.
void setMutualAuthentication ( SSLSocketFactory  xSslSocketFactory)

Sets SSLSocketFactory for Mutual Authentication.

Parameters
xSslSocketFactorySSLSocketFactory instance

Member Data Documentation

String OTV_DRMTYPE_CONNECT = "Connect"
inherited

Define DRM type for Connect.

String OTV_DRMTYPE_PLAYREADY = "PlayReady"
inherited

Define DRM type for PlayReady.

String OTV_DRMTYPE_WIDEVINE = "Widevine"
inherited

Defined DRM type for Widevine.

String OTV_DRMTYPE_WISEPLAY = "Wiseplay"
inherited

Define DRM type for Connect.