RDK Documentation (Open Sourced RDK Components)
AampDRMSessionManager Class Reference

Controller for managing DRM sessions. More...

#include <AampDRMSessionManager.h>

Collaboration diagram for AampDRMSessionManager:
Collaboration graph

Public Member Functions

 AampDRMSessionManager (AampLogManager *logObj, int maxDrmSessions)
 AampDRMSessionManager constructor.
 
void initializeDrmSessions ()
 
 ~AampDRMSessionManager ()
 AampDRMSessionManager Destructor.
 
AampDrmSessioncreateDrmSession (const char *systemId, MediaFormat mediaFormat, const unsigned char *initDataPtr, uint16_t dataLength, MediaType streamType, PrivateInstanceAAMP *aamp, DrmMetaDataEventPtr e, const unsigned char *contentMetadata=nullptr, bool isPrimarySession=false)
 Creates and/or returns the DRM session corresponding to keyId (Present in initDataPtr) AampDRMSession manager has two static AampDrmSession objects. This method will return the existing DRM session pointer if any one of these static DRM session objects are created against requested keyId. Binds the oldest DRM Session with new keyId if no matching keyId is found in existing sessions. More...
 
AampDrmSessioncreateDrmSession (std::shared_ptr< AampDrmHelper > drmHelper, DrmMetaDataEventPtr eventHandle, PrivateInstanceAAMP *aampInstance, MediaType streamType)
 Create DrmSession by using the AampDrmHelper object.
 
DrmDatagetLicense (AampLicenseRequest &licRequest, int32_t *httpError, MediaType streamType, PrivateInstanceAAMP *aamp, bool isContentMetadataAvailable=false, std::string licenseProxy="")
 Get DRM license key from DRM server. More...
 
bool IsKeyIdUsable (std::vector< uint8_t > keyIdArray)
 Get DRM license key from DRM server. More...
 
void clearSessionData ()
 Clean up the memory used by session variables. More...
 
void clearAccessToken ()
 Clean up the memory for accessToken. More...
 
void clearFailedKeyIds ()
 Clean up the failed keyIds. More...
 
void clearDrmSession (bool forceClearSession=false)
 Clean up the Session Data if license key acquisition failed or if LicenseCaching is false. More...
 
void setVideoWindowSize (int width, int height)
 
void setPlaybackSpeedState (int speed, double position, bool delayNeeded=false)
 
void setSessionMgrState (SessionMgrState state)
 Set Session manager state. More...
 
SessionMgrState getSessionMgrState ()
 Get Session manager state. More...
 
void setCurlAbort (bool isAbort)
 Set Session abort flag. More...
 
bool getCurlAbort (void)
 Get Session abort flag. More...
 
void setLicenseRequestAbort (bool isAbort)
 Get Session abort flag. More...
 
const char * getAccessToken (int &tokenLength, long &error_code, bool bSslPeerVerify)
 Get the accessToken from authService. More...
 
KeyState getDrmSession (std::shared_ptr< AampDrmHelper > drmHelper, int &selectedSlot, DrmMetaDataEventPtr eventHandle, PrivateInstanceAAMP *aampInstance, bool isPrimarySession=false)
 Create a DRM Session using the Drm Helper Determine a slot in the drmSession Contexts which can be used. More...
 
KeyState initializeDrmSession (std::shared_ptr< AampDrmHelper > drmHelper, int sessionSlot, DrmMetaDataEventPtr eventHandle, PrivateInstanceAAMP *aampInstance)
 Initialize the Drm System with InitData(PSSH)
 
KeyState acquireLicense (std::shared_ptr< AampDrmHelper > drmHelper, int sessionSlot, int &cdmError, DrmMetaDataEventPtr eventHandle, PrivateInstanceAAMP *aampInstance, MediaType streamType)
 sent license challenge to the DRM server and provide the respone to CDM
 
KeyState handleLicenseResponse (std::shared_ptr< AampDrmHelper > drmHelper, int sessionSlot, int &cdmError, int32_t httpResponseCode, int32_t httpExtResponseCode, shared_ptr< DrmData > licenseResponse, DrmMetaDataEventPtr eventHandle, PrivateInstanceAAMP *aampInstance)
 
KeyState processLicenseResponse (std::shared_ptr< AampDrmHelper > drmHelper, int sessionSlot, int &cdmError, shared_ptr< DrmData > licenseResponse, DrmMetaDataEventPtr eventHandle, PrivateInstanceAAMP *aampInstance)
 
bool configureLicenseServerParameters (std::shared_ptr< AampDrmHelper > drmHelper, AampLicenseRequest &licRequest, std::string &licenseServerProxy, const AampChallengeInfo &challengeInfo, PrivateInstanceAAMP *aampInstance)
 Configure the Drm license server parameters for URL/proxy and custom http request headers.
 
void notifyCleanup ()
 Resethe current seesion ID.
 
void ContentProtectionDataUpdate (PrivateInstanceAAMP *aampInstance, std::vector< uint8_t > keyId, MediaType streamType)
 

Private Member Functions

 AampDRMSessionManager (const AampDRMSessionManager &)=delete
 Copy constructor disabled. More...
 
AampDRMSessionManageroperator= (const AampDRMSessionManager &)=delete
 assignment operator disabled More...
 

Static Private Member Functions

static size_t write_callback (char *ptr, size_t size, size_t nmemb, void *userdata)
 Curl write callback, used to get the curl o/p from DRM license, accessToken curl requests. More...
 
static int progress_callback (void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
 

Private Attributes

AampLogManagermLogObj
 
DrmSessionContextdrmSessionContexts
 
KeyIDcachedKeyIDs
 
char * accessToken
 
int accessTokenLen
 
SessionMgrState sessionMgrState
 
pthread_mutex_t accessTokenMutex
 
pthread_mutex_t cachedKeyMutex
 
pthread_mutex_t mDrmSessionLock
 
bool curlSessionAbort
 
bool licenseRequestAbort
 
bool mEnableAccessAtrributes
 
int mMaxDRMSessions
 

yes

Controller for managing DRM sessions.

Definition at line 145 of file AampDRMSessionManager.h.

Constructor & Destructor Documentation

◆ AampDRMSessionManager()

AampDRMSessionManager::AampDRMSessionManager ( const AampDRMSessionManager )
privatedelete

Copy constructor disabled.

Member Function Documentation

◆ operator=()

AampDRMSessionManager& AampDRMSessionManager::operator= ( const AampDRMSessionManager )
privatedelete

assignment operator disabled

◆ write_callback()

AampDRMSessionManager::write_callback ( char *  ptr,
size_t  size,
size_t  nmemb,
void *  userdata 
)
staticprivate

Curl write callback, used to get the curl o/p from DRM license, accessToken curl requests.

Parameters
[in]ptr- Pointer to received data.
[in]size,nmemb- Size of received data (size * nmemb).
[out]userdata- Pointer to buffer where the received data is copied.
Returns
returns the number of bytes processed.

Definition at line 333 of file AampDRMSessionManager.cpp.

◆ progress_callback()

int AampDRMSessionManager::progress_callback ( void *  clientp,
double  dltotal,
double  dlnow,
double  ultotal,
double  ulnow 
)
staticprivate
Parameters
clientpapp-specific as optionally set with CURLOPT_PROGRESSDATA
dltotaltotal bytes expected to download
dlnowdownloaded bytes so far
ultotaltotal bytes expected to upload
ulnowuploaded bytes so far
Return values
Returnnon-zero for CURLE_ABORTED_BY_CALLBACK

Definition at line 308 of file AampDRMSessionManager.cpp.

◆ createDrmSession()

AampDrmSession * AampDRMSessionManager::createDrmSession ( const char *  systemId,
MediaFormat  mediaFormat,
const unsigned char *  initDataPtr,
uint16_t  initDataLen,
MediaType  streamType,
PrivateInstanceAAMP aamp,
DrmMetaDataEventPtr  e,
const unsigned char *  contentMetadataPtr = nullptr,
bool  isPrimarySession = false 
)

Creates and/or returns the DRM session corresponding to keyId (Present in initDataPtr) AampDRMSession manager has two static AampDrmSession objects. This method will return the existing DRM session pointer if any one of these static DRM session objects are created against requested keyId. Binds the oldest DRM Session with new keyId if no matching keyId is found in existing sessions.

Returns
Pointer to DrmSession for the given PSSH data; NULL if session creation/mapping fails.

Definition at line 875 of file AampDRMSessionManager.cpp.

◆ getLicense()

AampDRMSessionManager::getLicense ( AampLicenseRequest licRequest,
int32_t *  httpError,
MediaType  streamType,
PrivateInstanceAAMP aamp,
bool  isContentMetadataAvailable = false,
std::string  licenseProxy = "" 
)

Get DRM license key from DRM server.

Parameters
[in]licRequest- License request details (URL, headers etc.)
[out]httpError- Gets updated with http error; default -1.
[in]isContentMetadataAvailable- Flag to indicate whether MSO specific headers are to be used.
[in]licenseProxy- Proxy to use for license requests.
Returns
Structure holding DRM license key and it's length; NULL and 0 if request fails
Note
Memory for license key is dynamically allocated, deallocation should be handled at the caller side. customHeader ownership should be taken up by getLicense function

Definition at line 670 of file AampDRMSessionManager.cpp.

◆ IsKeyIdUsable()

AampDRMSessionManager::IsKeyIdUsable ( std::vector< uint8_t >  keyIdArray)

Get DRM license key from DRM server.

Parameters
[in]keyIdArray- key Id extracted from pssh data
Returns
bool - true if key is not cached/cached with no failure, false if keyId is already marked as failed.

Definition at line 482 of file AampDRMSessionManager.cpp.

◆ clearSessionData()

AampDRMSessionManager::clearSessionData ( )

Clean up the memory used by session variables.

Returns
void.

Definition at line 155 of file AampDRMSessionManager.cpp.

◆ clearAccessToken()

AampDRMSessionManager::clearAccessToken ( )

Clean up the memory for accessToken.

Returns
void.

Definition at line 244 of file AampDRMSessionManager.cpp.

◆ clearFailedKeyIds()

AampDRMSessionManager::clearFailedKeyIds ( )

Clean up the failed keyIds.

Returns
void.

Definition at line 222 of file AampDRMSessionManager.cpp.

◆ clearDrmSession()

AampDRMSessionManager::clearDrmSession ( bool  forceClearSession = false)

Clean up the Session Data if license key acquisition failed or if LicenseCaching is false.

Parameters
forceClearSessionclear the drm session irrespective of failed keys if LicenseCaching is false.
Returns
void.

Definition at line 257 of file AampDRMSessionManager.cpp.

◆ setSessionMgrState()

AampDRMSessionManager::setSessionMgrState ( SessionMgrState  state)

Set Session manager state.

Parameters
statesession manager sate to be set
Returns
void.

Definition at line 183 of file AampDRMSessionManager.cpp.

◆ getSessionMgrState()

AampDRMSessionManager::getSessionMgrState ( )

Get Session manager state.

Returns
session manager state.

Definition at line 191 of file AampDRMSessionManager.cpp.

◆ setCurlAbort()

AampDRMSessionManager::setCurlAbort ( bool  isAbort)

Set Session abort flag.

Parameters
isAbortbool flag to curl abort
Returns
void.

Definition at line 199 of file AampDRMSessionManager.cpp.

◆ getCurlAbort()

AampDRMSessionManager::getCurlAbort ( void  )

Get Session abort flag.

Returns
bool flag curlSessionAbort.

Definition at line 206 of file AampDRMSessionManager.cpp.

◆ setLicenseRequestAbort()

AampDRMSessionManager::setLicenseRequestAbort ( bool  isAbort)

Get Session abort flag.

Parameters
isAbortbool flag to curl abort
Returns
void

Definition at line 213 of file AampDRMSessionManager.cpp.

◆ getAccessToken()

AampDRMSessionManager::getAccessToken ( int &  tokenLength,
long &  error_code,
bool  bSslPeerVerify 
)

Get the accessToken from authService.

Parameters
[out]tokenLength- Gets updated with accessToken length.
Returns
Pointer to accessToken.
Note
AccessToken memory is dynamically allocated, deallocation should be handled at the caller side.

Definition at line 388 of file AampDRMSessionManager.cpp.

◆ getDrmSession()

AampDRMSessionManager::getDrmSession ( std::shared_ptr< AampDrmHelper drmHelper,
int &  selectedSlot,
DrmMetaDataEventPtr  eventHandle,
PrivateInstanceAAMP aampInstance,
bool  isPrimarySession = false 
)

Create a DRM Session using the Drm Helper Determine a slot in the drmSession Contexts which can be used.

Returns
index to the selected drmSessionContext which has been selected

Definition at line 1019 of file AampDRMSessionManager.cpp.


The documentation for this class was generated from the following files: