RDK Documentation (Open Sourced RDK Components)
AampPlayReadyHelper.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 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_PLAYREADY_HELPER_H
20 #define _AAMP_PLAYREADY_HELPER_H
21 
22 /**
23  * @file AampPlayReadyHelper.h
24  * @brief Handles the operation for Play ready DRM operations
25  */
26 
27 #include <memory>
28 
29 #include "AampDrmHelper.h"
30 #include "AampConfig.h"
31 
32 /**
33  * @class AampPlayReadyHelper
34  * @brief Handles the operation for Play ready DRM operations
35  */
36 
38 {
39 public:
40  friend class AampPlayReadyHelperFactory;
41 
42  const std::string& ocdmSystemId() const;
43 
44  void createInitData(std::vector<uint8_t>& initData) const;
45 
46  bool parsePssh(const uint8_t* initData, uint32_t initDataLen);
47 
48  bool isClearDecrypt() const { return false; }
49 
50  bool isHdcp22Required() const { return bOutputProtectionEnabled; }
51 
52  void setDrmMetaData( const std::string& metaData );
53 
54  void getKey(std::vector<uint8_t>& keyID) const;
55 
56  virtual int getDrmCodecType() const { return CODEC_TYPE; }
57 
58  void generateLicenseRequest(const AampChallengeInfo& challengeInfo, AampLicenseRequest& licenseRequest) const;
59 
60  const std::string& getDrmMetaData() const {return mContentMetaData;}
61 
62  virtual const std::string& friendlyName() const override { return FRIENDLY_NAME; };
63 
64  AampPlayReadyHelper(const struct DrmInfo& drmInfo, AampLogManager *logObj) : AampDrmHelper(drmInfo, logObj), FRIENDLY_NAME("PlayReady"), CODEC_TYPE(2),
65  PLAYREADY_DECODED_KEY_ID_LEN(16u), PLAYREADY_KEY_ID_LEN(37u), mPsshStr(),
66  mInitData(), mKeyID(), mContentMetaData(), mStrInitDataFormated()
67  {}
68 
70 
71 private:
72  std::string extractMetaData();
73  std::string extrackKeyID();
74  std::string findSubstr(std::string &data, std::string start, std::string end); /**< move to utiles */
75 
76  static const std::string PLAYREADY_OCDM_ID;
77  const size_t PLAYREADY_DECODED_KEY_ID_LEN; // Expected size of base64 decoded key ID from the PSSH
78  const size_t PLAYREADY_KEY_ID_LEN; // PlayReady ID key length. A NULL character is included at the end
79  const std::string FRIENDLY_NAME;
80  const int CODEC_TYPE;
81 
82  std::string mPsshStr;
83  std::vector<uint8_t> mInitData;
84  std::vector<uint8_t> mKeyID;
85  std::string mContentMetaData;
86  std::string mStrInitDataFormated; /**< String init data after clean up*/
87 };
88 
89 /**
90  * @class AampPlayReadyHelperFactory
91  * @brief Handles operations to support play ready DRM
92  */
94 {
95 public:
96  std::shared_ptr<AampDrmHelper> createHelper(const struct DrmInfo& drmInfo, AampLogManager *logObj=NULL) const;
97 
98  void appendSystemId(std::vector<std::string>& systemIds) const;
99 
100  bool isDRM(const struct DrmInfo& drmInfo) const;
101 };
102 
103 #endif //_AAMP_PLAYREADY_HELPER_H
AampPlayReadyHelper::isHdcp22Required
bool isHdcp22Required() const
Determine whether HDCP 2.2 protection is required to be active.
Definition: AampPlayReadyHelper.h:50
AampDrmHelper.h
Implented DRM helper functionalities.
AampPlayReadyHelper::generateLicenseRequest
void generateLicenseRequest(const AampChallengeInfo &challengeInfo, AampLicenseRequest &licenseRequest) const
Generate the request details for the DRM license.
Definition: AampPlayReadyHelper.cpp:253
AampPlayReadyHelper::getDrmMetaData
const std::string & getDrmMetaData() const
Returns the content specific DRM metadata.
Definition: AampPlayReadyHelper.h:60
AampPlayReadyHelperFactory
Handles operations to support play ready DRM.
Definition: AampPlayReadyHelper.h:93
AampPlayReadyHelperFactory::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: AampPlayReadyHelper.cpp:303
AampPlayReadyHelperFactory::createHelper
std::shared_ptr< AampDrmHelper > createHelper(const struct DrmInfo &drmInfo, AampLogManager *logObj=NULL) const
Build a helper class to support the identified DRM.
Definition: AampPlayReadyHelper.cpp:294
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AampPlayReadyHelper::createInitData
void createInitData(std::vector< uint8_t > &initData) const
AampPlayReadyHelper::mStrInitDataFormated
std::string mStrInitDataFormated
Definition: AampPlayReadyHelper.h:86
AampPlayReadyHelperFactory::isDRM
bool isDRM(const struct DrmInfo &drmInfo) const
Determines if a helper class provides the identified DRM.
Definition: AampPlayReadyHelper.cpp:287
AampLicenseRequest
Holds the data to get the License.
Definition: AampDrmHelper.h:57
DrmInfo
DRM information required to decrypt.
Definition: AampDrmInfo.h:47
AampPlayReadyHelper::parsePssh
bool parsePssh(const uint8_t *initData, uint32_t initDataLen)
Parse the optional PSSH data.
Definition: AampPlayReadyHelper.cpp:168
AampPlayReadyHelper::isClearDecrypt
bool isClearDecrypt() const
Determine if the DRM system needs to be in the clear or encrypted.
Definition: AampPlayReadyHelper.h:48
AampDrmHelperFactory
Helper class to Maintain DRM data.
Definition: AampDrmHelper.h:250
AampPlayReadyHelper::extractMetaData
std::string extractMetaData()
Extract content meta data from given PSSH data. For example for content meta data,...
Definition: AampPlayReadyHelper.cpp:163
AampConfig.h
Configurations for AAMP.
AampPlayReadyHelper::setDrmMetaData
void setDrmMetaData(const std::string &metaData)
Sets the content specific DRM metadata.
Definition: AampPlayReadyHelper.cpp:240
AampPlayReadyHelper::getKey
void getKey(std::vector< uint8_t > &keyID) const
Get the key ID.
Definition: AampPlayReadyHelper.cpp:248
AampPlayReadyHelper::ocdmSystemId
const std::string & ocdmSystemId() const
Returns the OCDM system ID of the helper.
Definition: AampPlayReadyHelper.cpp:43
AampPlayReadyHelper::findSubstr
std::string findSubstr(std::string &data, std::string start, std::string end)
find sub string inbetween string
Definition: AampPlayReadyHelper.cpp:59
AampPlayReadyHelper::friendlyName
virtual const std::string & friendlyName() const override
Gets the friendly display name of the DRM.
Definition: AampPlayReadyHelper.h:62
AampDrmHelper
AampDRM helper to handle DRM operations.
Definition: AampDrmHelper.h:79
AampPlayReadyHelper::getDrmCodecType
virtual int getDrmCodecType() const
Returns the DRM codec type for the helper, used in trace.
Definition: AampPlayReadyHelper.h:56
AampChallengeInfo
Aamp challenge info to get the License.
Definition: AampDrmHelper.h:44
AampPlayReadyHelper
Handles the operation for Play ready DRM operations.
Definition: AampPlayReadyHelper.h:37