| 1 |
/* |
| 2 |
* Copyright (C) 2024 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "common/AdaptiveCencSampleDecrypter.h" |
| 10 |
#include "decrypters/IDecrypter.h" |
| 11 |
|
| 12 |
#include <map> |
| 13 |
|
| 14 |
class CClearKeyDecrypter; |
| 15 |
|
| 16 |
class CClearKeyCencSingleSampleDecrypter : public Adaptive_CencSingleSampleDecrypter |
| 17 |
{ |
| 18 |
public: |
| 19 |
CClearKeyCencSingleSampleDecrypter(std::string_view licenseUrl, |
| 20 |
const std::map<std::string, std::string>& licenseHeaders, |
| 21 |
const std::vector<uint8_t>& defaultKeyId, |
| 22 |
CClearKeyDecrypter* host); |
| 23 |
CClearKeyCencSingleSampleDecrypter(const std::vector<uint8_t>& initdata, |
| 24 |
const std::vector<uint8_t>& defaultKeyId, |
| 25 |
const std::map<std::string, std::string>& keys, |
| 26 |
CClearKeyDecrypter* host); |
| 27 |
virtual ~CClearKeyCencSingleSampleDecrypter(){}; |
| 28 |
void AddSessionKey(const std::vector<uint8_t>& keyId); |
| 29 |
bool HasKeyId(const std::vector<uint8_t>& keyid); |
| 30 |
virtual AP4_Result SetFragmentInfo(AP4_UI32 pool_id, |
| 31 |
const std::vector<uint8_t>& key, |
| 32 |
const AP4_UI08 nal_length_size, |
| 33 |
AP4_DataBuffer& annexb_sps_pps, |
| 34 |
AP4_UI32 flags, |
| 35 |
CryptoInfo cryptoInfo) override |
| 36 |
{ |
| 37 |
return AP4_SUCCESS; |
| 38 |
} |
| 39 |
virtual AP4_Result DecryptSampleData(AP4_UI32 pool_id, |
| 40 |
AP4_DataBuffer& data_in, |
| 41 |
AP4_DataBuffer& data_out, |
| 42 |
const AP4_UI08* iv, |
| 43 |
unsigned int subsample_count, |
| 44 |
const AP4_UI16* bytes_of_cleartext_data, |
| 45 |
const AP4_UI32* bytes_of_encrypted_data) override; |
| 46 |
std::string CreateLicenseRequest(const std::vector<uint8_t>& defaultKeyId); |
| 47 |
bool ParseLicenseResponse(std::string data); |
| 48 |
void SetDefaultKeyId(const std::vector<uint8_t>& keyId) override{}; |
| 49 |
void AddKeyId(const std::vector<uint8_t>& keyId) override{}; |
| 50 |
bool HasKeys() { return !m_keyIds.empty(); } |
| 51 |
|
| 52 |
private: |
| 53 |
AP4_CencSingleSampleDecrypter* m_singleSampleDecrypter{nullptr}; |
| 54 |
std::string m_strSession; |
| 55 |
std::string m_licenceDefaultKeyId; |
| 56 |
std::vector<std::vector<uint8_t>> m_keyIds; |
| 57 |
std::map<std::string, std::string> m_keyPairs; |
| 58 |
CClearKeyDecrypter* m_host; |
| 59 |
}; |