RDK Documentation (Open Sourced RDK Components)
AampDrmHelper.cpp
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 
20 /**
21  * @file AampDrmHelper.cpp
22  * @brief Implemented Aamp DRM helper function
23  */
24 
25 #include <algorithm>
26 #include <regex>
27 
28 #include "AampDrmHelper.h"
29 
30 bool AampDrmHelper::compare(std::shared_ptr<AampDrmHelper> other)
31 {
32  if (other == nullptr) return false;
33  if (mDrmInfo.systemUUID != other->mDrmInfo.systemUUID) return false;
34  if (mDrmInfo.mediaFormat != other->mDrmInfo.mediaFormat) return false;
35  if (ocdmSystemId() != other->ocdmSystemId()) return false;
36  if (getDrmMetaData() != other->getDrmMetaData()) return false;
37 
38  std::vector<uint8_t> thisKeyId;
39  getKey(thisKeyId);
40 
41  std::vector<uint8_t> otherKeyId;
42  other->getKey(otherKeyId);
43  std::map<int, std::vector<uint8_t>> otherKeyIds;
44  other->getKeys(otherKeyIds);
45  std::vector<std::vector<uint8_t>> keyIdVector;
46  if(otherKeyIds.empty())
47  {
48  keyIdVector.push_back(otherKeyId);
49  }
50  else
51  {
52  for(auto& keyId : otherKeyIds)
53  {
54  keyIdVector.push_back(keyId.second);
55  }
56  }
57 
58  if (!keyIdVector.empty() && (keyIdVector.end() == std::find(keyIdVector.begin(), keyIdVector.end(), thisKeyId))) return false;
59 
60  return true;
61 }
AampDrmHelper::compare
virtual bool compare(std::shared_ptr< AampDrmHelper > other)
Compare against another helper instance.
Definition: AampDrmHelper.cpp:34
AampDrmHelper.h
Implented DRM helper functionalities.
DrmInfo::systemUUID
std::string systemUUID
Definition: AampDrmInfo.h:89
AampDrmHelper::ocdmSystemId
virtual const std::string & ocdmSystemId() const =0
Returns the OCDM system ID of the helper.
AampDrmHelper::getDrmMetaData
virtual const std::string & getDrmMetaData() const
Returns the content specific DRM metadata.
Definition: AampDrmHelper.h:127
AampDrmHelper::getKey
virtual void getKey(std::vector< uint8_t > &keyID) const =0
Get the key ID.
DrmInfo::mediaFormat
MediaFormat mediaFormat
Definition: AampDrmInfo.h:80