Android OpenTV Player SDK  5.29.0.1685538953
 All Classes Namespaces Functions Variables Pages
OTVHttpMediaDrmCallback Class Reference

Detailed Description

The default implementation of OTVMediaDrmCallback.

This class can be used in most cases of streaming Widevine- or PlayReady- encrypted streams while fetching the keys from a licence server such as Nagra's Secure Service Platform (SSP).
An object of this class (or other implementations of OTVMediaDrmCallback) must be assigned to the player for playback of encrypted content. The configuration of the object is done with the following stages:

The 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 "Content-Type" property in particular is necessary as different DRM system types may require different formats (e.g. binary, JSON, XML etc.) The object is configured prior to start of playback or setting the stream path, and then assigned to the OTVVideoView instance:
videoView.setMediaDrmCallback(callback);
Configuration can also be changed during playback.

Inheritance diagram for OTVHttpMediaDrmCallback:
OTVCommonMediaDrmCallback OTVMediaDrmCallback

Public Member Functions

 OTVHttpMediaDrmCallback (String defaultLicenseUrl)
 
byte[] executeKeyRequest (UUID uuid, KeyRequest request) throws MediaDrmCallbackException
 Executes a key request. More...
 
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...
 
byte[] executeProvisionRequest (UUID uuid, ExoMediaDrm.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[] 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

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

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

Member Function Documentation

void clearAllDrmPropertyByteArray ( )
inherited

Clears all byte array properties for media drm.

void clearAllDrmPropertyStrings ( )
inherited

Clears all properties for media drm.

void clearAllKeyRequestOptions ( )
inherited

Clears all options for key requests.

void clearAllKeyRequestProperties ( )
inherited

Clears all headers for key requests made by the callback.

void clearKeyRequestOption ( String  name)
inherited

Clears an option for key requests.

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

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 [] executeKeyRequest ( UUID  uuid,
KeyRequest  request 
) throws MediaDrmCallbackException

Executes a key request.

Parameters
uuidThe UUID of the content protection scheme.
requestThe request.
Returns
The response data.
Exceptions
MediaDrmCallbackExceptionIf an error occurred executing the request.
byte [] executePost ( String  url,
byte[]  data,
Map< String, String >  requestProperties 
) throws IOException
protectedinherited

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
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.
MediaDrmCallbackException generateDrmCBException ( @NonNull IOException  exception)
protectedinherited

Helper method to generate MediaDrmCallbackException with IOException.

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

Gets byte array properties for media drm.

The default value is null.

Returns
all drm byte array properties.

Implements OTVMediaDrmCallback.

HashMap<String, String> getDrmPropertyStrings ( )
inherited

Gets properties for media drm.

The default value is null.

Returns
all drm properties.

Implements OTVMediaDrmCallback.

String getDrmType ( )
inherited

Returns the DRM type the callback instance is configured for.

Implements OTVMediaDrmCallback.

HashMap<String, String> getKeyRequestOptions ( )
inherited

Gets options for key requests.

Returns
all key request options.

Implements OTVMediaDrmCallback.

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

Implements OTVMediaDrmCallback.

void setDrmPropertyByteArray ( String  name,
byte[]  value 
)
inherited

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 
)
inherited

Sets a drm property.

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

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 
)
inherited

Sets an optional parameter for key requests.

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

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)
inherited

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)
inherited

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.