RDK Documentation (Open Sourced RDK Components)
AampClearKeyHelper.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_CLEARKEY_HELPER_H
20 #define _AAMP_CLEARKEY_HELPER_H
21 
22 /**
23  * @file AampClearKeyHelper.cpp
24  * @brief Implemented Clear key helper functions
25  */
26 
27 #include <memory>
28 
29 #include "AampDrmHelper.h"
30 
31 /**
32  * @class AampClearKeyHelper
33  * @brief Class handles the clear key license operations
34  */
36 {
37 public:
38  const std::string& ocdmSystemId() const;
39 
40  void createInitData(std::vector<uint8_t>& initData) const;
41 
42  bool parsePssh(const uint8_t* initData, uint32_t initDataLen);
43 
44  bool isClearDecrypt() const { return true; }
45 
46  void getKey(std::vector<uint8_t>& keyID) const;
47 
48  virtual int getDrmCodecType() const { return CODEC_TYPE; }
49 
50  void generateLicenseRequest(const AampChallengeInfo& challengeInfo, AampLicenseRequest& licenseRequest) const;
51 
52  void transformLicenseResponse(std::shared_ptr<DrmData> licenseResponse) const;
53 
54  virtual const std::string& friendlyName() const override { return FRIENDLY_NAME; };
55 
56  AampClearKeyHelper(const struct DrmInfo& drmInfo, AampLogManager *logObj) : AampDrmHelper(drmInfo,logObj), mInitData(), mKeyID(), mPsshStr(),
57  CLEARKEY_KEY_ID("1"), FRIENDLY_NAME("Clearkey"), CODEC_TYPE(0), CLEARKEY_DASH_KEY_ID_OFFSET(32u),
58  CLEARKEY_DASH_KEY_ID_LEN(16u), KEY_ID_OFFSET(12), KEY_PAYLOAD_OFFSET(14), BASE_16(16)
59  {}
60 
61  ~AampClearKeyHelper() { }
62 
63 private:
64  static const std::string CLEARKEY_OCDM_ID;
65  const std::string CLEARKEY_KEY_ID;
66  const std::string FRIENDLY_NAME;
67  const int CODEC_TYPE;
68  const size_t CLEARKEY_DASH_KEY_ID_OFFSET; // Offset in the PSSH to find the key ID for DASH
69  const size_t CLEARKEY_DASH_KEY_ID_LEN; // Length of the key ID for DASH
70  const int KEY_ID_OFFSET;
71  const int KEY_PAYLOAD_OFFSET;
72  const int BASE_16;
73 
74  std::string mPsshStr;
75  std::vector<uint8_t> mInitData;
76  std::vector<uint8_t> mKeyID;
77 };
78 
79 /**
80  * @class AampClearKeyHelperFactory
81  * @brief Helper Factory class to maintain Aamp DRM data
82  */
83 
85 {
86 public:
87  static const int CLEARKEY_WEIGHTING = DEFAULT_WEIGHTING * 2;
88 
89  std::shared_ptr<AampDrmHelper> createHelper(const struct DrmInfo& drmInfo, AampLogManager *logObj=NULL) const;
90 
91  void appendSystemId(std::vector<std::string>& systemIds) const;
92 
93  bool isDRM(const struct DrmInfo& drmInfo) const;
94 
95 public:
96  AampClearKeyHelperFactory() : AampDrmHelperFactory(CLEARKEY_WEIGHTING) {};
97 };
98 
99 #endif //_AAMP_CLEARKEY_HELPER_H
AampClearKeyHelper::getDrmCodecType
virtual int getDrmCodecType() const
Returns the DRM codec type for the helper, used in trace.
Definition: AampClearKeyHelper.h:48
AampDrmHelper.h
Implented DRM helper functionalities.
AampClearKeyHelper
Class handles the clear key license operations.
Definition: AampClearKeyHelper.h:35
AampClearKeyHelperFactory::createHelper
std::shared_ptr< AampDrmHelper > createHelper(const struct DrmInfo &drmInfo, AampLogManager *logObj=NULL) const
Build a helper class to support the identified DRM.
Definition: AampClearKeyHelper.cpp:145
AampDrmHelperFactory::AampDrmHelperFactory
AampDrmHelperFactory(int weighting=DEFAULT_WEIGHTING)
AampDrmHelperFactory constructor.
Definition: AampDrmHelperFactory.cpp:86
AampClearKeyHelper::isClearDecrypt
bool isClearDecrypt() const
Determine if the DRM system needs to be in the clear or encrypted.
Definition: AampClearKeyHelper.h:44
AampDrmHelperFactory::DEFAULT_WEIGHTING
static const int DEFAULT_WEIGHTING
Default weighting of a helper factory. Nominal scale of 0 to DEFAULT_WEIGHTING * 2 Larger weightings ...
Definition: AampDrmHelper.h:258
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AampClearKeyHelperFactory::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: AampClearKeyHelper.cpp:154
AampLicenseRequest
Holds the data to get the License.
Definition: AampDrmHelper.h:57
AampClearKeyHelper::friendlyName
virtual const std::string & friendlyName() const override
Gets the friendly display name of the DRM.
Definition: AampClearKeyHelper.h:54
DrmInfo
DRM information required to decrypt.
Definition: AampDrmInfo.h:47
AampClearKeyHelper::transformLicenseResponse
void transformLicenseResponse(std::shared_ptr< DrmData > licenseResponse) const
Transform the license response from the server into the necessary format for OCDM.
Definition: AampClearKeyHelper.cpp:109
AampDrmHelperFactory
Helper class to Maintain DRM data.
Definition: AampDrmHelper.h:250
AampClearKeyHelperFactory
Helper Factory class to maintain Aamp DRM data.
Definition: AampClearKeyHelper.h:84
AampClearKeyHelper::ocdmSystemId
const std::string & ocdmSystemId() const
Returns the OCDM system ID of the helper.
Definition: AampClearKeyHelper.cpp:36
AampClearKeyHelperFactory::isDRM
bool isDRM(const struct DrmInfo &drmInfo) const
Determines if a helper class provides the identified DRM.
Definition: AampClearKeyHelper.cpp:137
AampDrmHelper
AampDRM helper to handle DRM operations.
Definition: AampDrmHelper.h:79
AampClearKeyHelper::getKey
void getKey(std::vector< uint8_t > &keyID) const
Get the key ID.
Definition: AampClearKeyHelper.cpp:70
AampClearKeyHelper::generateLicenseRequest
void generateLicenseRequest(const AampChallengeInfo &challengeInfo, AampLicenseRequest &licenseRequest) const
Generate the request details for the DRM license.
Definition: AampClearKeyHelper.cpp:85
AampChallengeInfo
Aamp challenge info to get the License.
Definition: AampDrmHelper.h:44
AampClearKeyHelper::parsePssh
bool parsePssh(const uint8_t *initData, uint32_t initDataLen)
Parse the optional PSSH data.
Definition: AampClearKeyHelper.cpp:61
AampClearKeyHelper::createInitData
void createInitData(std::vector< uint8_t > &initData) const
Definition: AampClearKeyHelper.cpp:41