35 const std::string AampWidevineDrmHelper::WIDEVINE_OCDM_ID =
"com.widevine.alpha";
39 this->mInitData.assign(initData, initData+initDataLen);
42 const char* keyIdBegin;
43 uint8_t keyIdSize = 0u;
44 uint8_t psshDataVer = initData[WIDEVINE_PSSH_DATA_VERSION_POSITION];
72 uint8_t contentIdSize = 0u;
73 uint8_t keyIdCount = 0;
74 const uint8_t* psshData;
76 if (initData[WIDEVINE_PSSH_KEYID_SIZE_OFFSET] == WIDEVINE_KEY_ID_SIZE_INDICATOR)
78 header = WIDEVINE_PSSH_KEYID_SIZE_OFFSET;
80 else if(initData[WIDEVINE_PSSH_KEYID_SIZE_OFFSET_WITH_AUTHOR] == WIDEVINE_KEY_ID_SIZE_INDICATOR)
82 header = WIDEVINE_PSSH_KEYID_SIZE_OFFSET_WITH_AUTHOR;
86 AAMPLOG_WARN(
"WV Version: %u, Keyid indicator byte not found using default logic", psshDataVer);
87 header = WIDEVINE_PSSH_KEYID_SIZE_OFFSET;
91 while (i < initDataLen)
93 if (KEYID_MARKER == psshData[i])
95 keyIdSize = psshData[i +1];
96 i += DATA_LENGTH_FIELD_SIZE;
98 keyIdBegin =
reinterpret_cast<const char*
>(psshData + i);
101 std::vector<uint8_t> keyId;
102 keyId.assign(keyIdBegin, keyIdBegin + keyIdSize);
103 mKeyIDs[keyIdCount]=keyId;
109 AAMPLOG_INFO(
"WV version: %u, KeyIdlen: %u", psshDataVer, keyIdSize);
114 else if (CONTENTID_MARKER == psshData[i])
119 const char* ContentIdBegin;
120 uint8_t ContentIDSize = psshData[i +1];
121 i += DATA_LENGTH_FIELD_SIZE;
122 ContentIdBegin =
reinterpret_cast<const char*
>(psshData + i);
123 if (ContentIDSize > 0)
125 std::vector<uint8_t> ContentId;
126 ContentId.assign(ContentIdBegin, ContentIdBegin + ContentIDSize);
127 mKeyIDs[keyIdCount]=ContentId;
136 keyIdSize = psshData[i +1];
137 AAMPLOG_INFO(
"WV Invalid type : %d size:%d", psshData[i], keyIdSize);
138 i += DATA_LENGTH_FIELD_SIZE;
143 else if (psshDataVer == 1)
149 uint32_t header = WIDEVINE_DASH_KEY_ID_OFFSET;
150 keyIdSize = WIDEVINE_PSSH_VER1_KEY_ID_SIZE;
151 keyIdBegin =
reinterpret_cast<const char*
>(initData + header);
155 std::vector<uint8_t> keyId;
156 keyId.assign(keyIdBegin, keyIdBegin + keyIdSize);
162 AAMPLOG_INFO(
"WV version: %u, KeyIdlen: %u", psshDataVer, keyIdSize);
167 AAMPLOG_ERR(
"Unsupported PSSH version: %u", psshDataVer);
175 mContentMetadata = metaData;
180 std::vector<uint8_t> defaultKeyID(cencData.begin(), cencData.end());
183 for(
auto& it : mKeyIDs)
185 if(defaultKeyID == it.second)
187 mDefaultKeySlot = it.first;
188 AAMPLOG_WARN(
"setDefaultKeyID : %s slot : %d", cencData.c_str(), mDefaultKeySlot);
197 return WIDEVINE_OCDM_ID;
202 initData = this->mInitData;
207 AAMPLOG_WARN(
"AampWidevineDrmHelper::getKey defaultkey: %d mKeyIDs.size:%d", mDefaultKeySlot, mKeyIDs.size());
208 if ((mDefaultKeySlot >= 0) && (mDefaultKeySlot < mKeyIDs.size()))
210 keyID = this->mKeyIDs.at(mDefaultKeySlot);
212 else if (mKeyIDs.size() > 0)
214 keyID = this->mKeyIDs.at(0);
218 AAMPLOG_ERR(
"No key");
224 keyIDs = this->mKeyIDs;
231 if (licenseRequest.url.empty())
233 licenseRequest.url = challengeInfo.
url;
236 licenseRequest.headers = {{
"Content-Type:", {
"application/octet-stream"}}};
238 licenseRequest.payload= challengeInfo.
data->getData();
243 return (((WIDEVINE_UUID == drmInfo.
systemUUID) || (AampWidevineDrmHelper::WIDEVINE_OCDM_ID == drmInfo.
keyFormat))
252 return std::make_shared<AampWidevineDrmHelper>(drmInfo,logObj);
259 systemIds.push_back(WIDEVINE_UUID);