RDK Documentation (Open Sourced RDK Components)
playreadydrmsession.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file playreadydrmsession.h
22  * @brief Playready Session management
23  */
24 
25 #ifndef PlayReadyDrmSession_h
26 #define PlayReadyDrmSession_h
27 
28 #include "AampDrmSession.h"
29 #include "aampoutputprotection.h"
30 #include <drmbuild_oem.h>
31 #include <drmcommon.h>
32 #include <drmmanager.h>
33 #include <drmmathsafe.h>
34 #include <drmtypes.h>
35 #include <drmerr.h>
36 #undef __in
37 #undef __out
38 using namespace std;
39 
40 #define ChkBufferSize(a,b) do { \
41  ChkBOOL((a) <= (b), DRM_E_FAIL); \
42 } while(FALSE)
43 
44 /**
45  * @class PlayReadyDRMSession
46  * @brief Class for PlayReady DRM operations
47  */
49 {
50 
51 private:
52  DRM_APP_CONTEXT *m_ptrAppContext;
53  DRM_DECRYPT_CONTEXT m_oDecryptContext;
54 
55  DRM_BYTE *m_sbOpaBuf;
56  DRM_DWORD m_cbOpaBuf;
57 
58  DRM_BYTE *m_sbRevocateBuf;
59  KeyState m_eKeyState;
60  DRM_CHAR m_rgchSesnID[CCH_BASE64_EQUIV(SIZEOF(DRM_ID)) + 1];
61  DRM_BOOL m_fCommit;
62 
63  DRM_BYTE *m_pbPRO;
64  DRM_DWORD m_cbPRO;
65 
66  DRM_BYTE *m_pbChallenge;
67  DRM_DWORD m_cbChallenge;
68  DRM_CHAR *m_ptrDestURL;
69  pthread_mutex_t decryptMutex;
70 
71  AampOutputProtection* m_pOutputProtection;
72 
73  /**
74  * @fn initAampDRMSession
75  */
76  void initAampDRMSession();
77  /**
78  * @fn _GetPROFromInitData
79  * @param f_pbInitData : Pointer to initdata
80  * @param f_cbInitData : size of initdata
81  * @param f_pibPRO : Gets updated with PRO
82  * @param f_pcbPRO : size of PRO
83  * @retval DRM_SUCCESS if no errors encountered
84  */
85  int _GetPROFromInitData(const DRM_BYTE *f_pbInitData,
86  DRM_DWORD f_cbInitData, DRM_DWORD *f_pibPRO, DRM_DWORD *f_pcbPRO);
87  /**
88  * @fn _ParseInitData
89  * @param f_pbInitData : Pointer to initdata
90  * @param f_cbInitData : size of init data
91  * @retval DRM_SUCCESS if no errors encountered
92  */
93  int _ParseInitData(const uint8_t *f_pbInitData, uint32_t f_cbInitData);
94 
95 
96 public:
97  /**
98  * @fn PlayReadyDRMSession
99  */
101  /**
102  * @fn ~PlayReadyDRMSession
103  */
105  /**
106  * @fn generateAampDRMSession
107  * @param f_pbInitData pointer to initdata
108  * @param f_cbInitData init data size
109  */
110  void generateAampDRMSession(const uint8_t *f_pbInitData,
111  uint32_t f_cbInitData, std::string &customData);
112  /**
113  * @fn aampGenerateKeyRequest
114  * @param destinationURL : gets updated with license server url
115  * @param timeout : max timeout untill which to wait for cdm key generation.
116  * @retval Pointer to DrmData containing license request, NULL if failure.
117  */
118  DrmData * aampGenerateKeyRequest(string& destinationURL, uint32_t timeout);
119  /**
120  * @fn aampDRMProcessKey
121  * @param key : License key from license server.
122  * @param timeout : max timeout untill which to wait for cdm key processing.
123  * @retval DRM_SUCCESS if no errors encountered
124  */
125  int aampDRMProcessKey(DrmData* key, uint32_t timeout);
126  /**
127  * @fn decrypt
128  * @param f_pbIV : Initialization vector.
129  * @param f_cbIV : Initialization vector length.
130  * @param payloadData : Data to decrypt.
131  * @param payloadDataSize : Size of data.
132  * @param ppOpaqueData : pointer to opaque buffer in case of SVP.
133  * @retval Returns 1 on success 0 on failure.
134  */
135  int decrypt(const uint8_t *f_pbIV, uint32_t f_cbIV,
136  const uint8_t *payloadData, uint32_t payloadDataSize, uint8_t **ppOpaqueData);
137  /**
138  * @fn getState
139  * @retval KeyState
140  */
141  KeyState getState();
142 
143  /**
144  * @fn clearDecryptContext
145  */
146  void clearDecryptContext();
147 
148 };
149 
150 #endif
151 
aampoutputprotection.h
Output protection management for Aamp.
DrmData
To hold DRM key, license request etc.
Definition: AampDrmData.h:32
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
PlayReadyDRMSession
Class for PlayReady DRM operations.
Definition: playreadydrmsession.h:48
AampOutputProtection
Class to enforce HDCP authentication.
Definition: aampoutputprotection.h:119
AampDrmSession
Base class for DRM sessions.
Definition: AampDrmSession.h:69
KeyState
KeyState
DRM session states.
Definition: AampDrmSession.h:54
AampDrmSession.h
Header file for AampDrmSession.