RDK Documentation (Open Sourced RDK Components)
AampVgdrmHelper.h
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 2020 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 #ifndef _AAMP_VGDRM_HELPER_H
20 #define _AAMP_VGDRM_HELPER_H
21 
22 #include <memory>
23 #include <set>
24 
25 #include "AampDrmHelper.h"
26 
27 #if USE_ION_MEMORY
28 #include "AampIonMemorySystem.h"
29 #elif USE_SHARED_MEMORY
30 #include "AampSharedMemorySystem.h"
31 #else
32 #error "No memory model for interchange"
33 #endif
34 
35 /**
36  * @class AampVgdrmHelper
37  * @brief Handles the operation for Vg DRM
38  */
40 {
41 public:
42  friend class AampVgdrmHelperFactory;
43 
44  const uint32_t TEN_SECONDS = 10000U;
45 
46  virtual const std::string& ocdmSystemId() const;
47 
48  void createInitData(std::vector<uint8_t>& initData) const;
49 
50  bool parsePssh(const uint8_t* initData, uint32_t initDataLen);
51 
52  bool isClearDecrypt() const { return true; }
53 
54  bool isHdcp22Required() const { return true; }
55 
56  uint32_t keyProcessTimeout() const { return TEN_SECONDS; }
57  uint32_t licenseGenerateTimeout() const { return TEN_SECONDS; }
58 
59  void getKey(std::vector<uint8_t>& keyID) const;
60 
61  virtual int getDrmCodecType() const { return CODEC_TYPE; }
62 
63  bool isExternalLicense() const { return true; };
64 
65  void generateLicenseRequest(const AampChallengeInfo& challengeInfo, AampLicenseRequest& licenseRequest) const;
66 
67  AAMPMemorySystem* getMemorySystem() override { return &memorySystem; };
68 
69  virtual const std::string& friendlyName() const override { return FRIENDLY_NAME; };
70 
71  AampVgdrmHelper(const struct DrmInfo& drmInfo, AampLogManager *logObj) : AampDrmHelper(drmInfo, logObj), mPsshStr(), memorySystem(logObj) {}
72  ~AampVgdrmHelper() { }
73 
74 private:
75  static const std::string VGDRM_OCDM_ID;
76  const std::string FRIENDLY_NAME{"VGDRM"};
77  const int CODEC_TYPE{4};
78  const int KEY_ID_OFFSET{12};
79  const int KEY_PAYLOAD_OFFSET{14};
80  const int BASE_16{16};
81  std::string mPsshStr;
82 #if USE_ION_MEMORY
83  AampIonMemorySystem memorySystem;
84 #elif USE_SHARED_MEMORY
85  AampSharedMemorySystem memorySystem;
86 #endif
87 };
88 
89 /**
90  * @class AampVgdrmHelperFactory
91  * @brief Helps to operate Vg DRM
92  */
94 {
95  std::shared_ptr<AampDrmHelper> createHelper(const struct DrmInfo& drmInfo, AampLogManager *logObj=NULL) const;
96 
97  void appendSystemId(std::vector<std::string>& systemIds) const;
98 
99  bool isDRM(const struct DrmInfo& drmInfo) const;
100 
101 private:
102  const std::string VGDRM_UUID{"A68129D3-575B-4F1A-9CBA-3223846CF7C3"};
103 
104  const std::set<std::string> VGDRM_URI_START = {
105  "80701500000810",
106  "81701500000810",
107  "8070110000080C",
108  "8170110000080C",
109  "8070110000080c", /* Lowercase version of above to avoid needing to do case insensative comparison */
110  "8170110000080c"
111  };
112 };
113 
114 #endif //_AAMP_VGDRM_HELPER_H
AampDrmHelper.h
Implented DRM helper functionalities.
AampVgdrmHelper::getDrmCodecType
virtual int getDrmCodecType() const
Returns the DRM codec type for the helper, used in trace.
Definition: AampVgdrmHelper.h:61
AampVgdrmHelper::licenseGenerateTimeout
uint32_t licenseGenerateTimeout() const
Get the amount of time in milliseconds to wait before aborting the wait for the license_challenge mes...
Definition: AampVgdrmHelper.h:57
AampVgdrmHelper::getKey
void getKey(std::vector< uint8_t > &keyID) const
Get the key ID.
Definition: AampVgdrmHelper.cpp:61
AampVgdrmHelper::parsePssh
bool parsePssh(const uint8_t *initData, uint32_t initDataLen)
Parse the optional PSSH data.
Definition: AampVgdrmHelper.cpp:55
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AampVgdrmHelperFactory
Helps to operate Vg DRM.
Definition: AampVgdrmHelper.h:93
AampIonMemorySystem.h
Controls the ION memory for aamp.
AampLicenseRequest
Holds the data to get the License.
Definition: AampDrmHelper.h:57
AampVgdrmHelper::generateLicenseRequest
void generateLicenseRequest(const AampChallengeInfo &challengeInfo, AampLicenseRequest &licenseRequest) const
Generate the request details for the DRM license.
Definition: AampVgdrmHelper.cpp:86
AampSharedMemorySystem
Handles the shared Memory operations.
Definition: AampSharedMemorySystem.h:50
DrmInfo
DRM information required to decrypt.
Definition: AampDrmInfo.h:47
AampVgdrmHelper::isClearDecrypt
bool isClearDecrypt() const
Determine if the DRM system needs to be in the clear or encrypted.
Definition: AampVgdrmHelper.h:52
AampVgdrmHelper::isHdcp22Required
bool isHdcp22Required() const
Determine whether HDCP 2.2 protection is required to be active.
Definition: AampVgdrmHelper.h:54
AampVgdrmHelper::ocdmSystemId
virtual const std::string & ocdmSystemId() const
Returns the OCDM system ID of the helper.
Definition: AampVgdrmHelper.cpp:37
AampVgdrmHelperFactory::isDRM
bool isDRM(const struct DrmInfo &drmInfo) const
Determines if a helper class provides the identified DRM.
Definition: AampVgdrmHelper.cpp:93
AampVgdrmHelper::keyProcessTimeout
uint32_t keyProcessTimeout() const
Get the amount of time in milliseconds to wait before aborting the wait for the key_updated message t...
Definition: AampVgdrmHelper.h:56
AampDrmHelperFactory
Helper class to Maintain DRM data.
Definition: AampDrmHelper.h:250
AampVgdrmHelper::getMemorySystem
AAMPMemorySystem * getMemorySystem() override
Get the memory system used to transform data for transmission.
Definition: AampVgdrmHelper.h:67
AampVgdrmHelper::createInitData
void createInitData(std::vector< uint8_t > &initData) const
Definition: AampVgdrmHelper.cpp:42
AampVgdrmHelper
Handles the operation for Vg DRM.
Definition: AampVgdrmHelper.h:39
AampVgdrmHelper::isExternalLicense
bool isExternalLicense() const
Determines if the DRM itself fetches the license or if AAMP should use its own internal HTTP client t...
Definition: AampVgdrmHelper.h:63
AampSharedMemorySystem.h
Handles the functionalities for shared memory communication.
AampVgdrmHelperFactory::appendSystemId
void appendSystemId(std::vector< std::string > &systemIds) const
Adds the system IDs supported by the DRM to a vector Used by the GStreamer plugins to advertise the D...
Definition: AampVgdrmHelper.cpp:121
AampDrmHelper
AampDRM helper to handle DRM operations.
Definition: AampDrmHelper.h:79
AampIonMemorySystem
Handles ION memory storage to store data.
Definition: AampIonMemorySystem.h:49
AAMPMemorySystem
Handles the operations for AAMP memory managemnts.
Definition: AampMemorySystem.h:37
AampChallengeInfo
Aamp challenge info to get the License.
Definition: AampDrmHelper.h:44
AampVgdrmHelper::friendlyName
virtual const std::string & friendlyName() const override
Gets the friendly display name of the DRM.
Definition: AampVgdrmHelper.h:69
AampVgdrmHelperFactory::createHelper
std::shared_ptr< AampDrmHelper > createHelper(const struct DrmInfo &drmInfo, AampLogManager *logObj=NULL) const
Build a helper class to support the identified DRM.
Definition: AampVgdrmHelper.cpp:112