| 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 |
#pragma once |
| 10 |
#include "decrypters/IDecrypter.h" |
| 11 |
|
| 12 |
#include <bento4/Ap4.h> |
| 13 |
|
| 14 |
using namespace DRM; |
| 15 |
|
| 16 |
class CClearKeyDecrypter : public IDecrypter |
| 17 |
{ |
| 18 |
public: |
| 19 |
CClearKeyDecrypter(){}; |
| 20 |
virtual ~CClearKeyDecrypter() override{}; |
| 21 |
virtual std::vector<std::string_view> SelectKeySystems(std::string_view keySystem) override; |
| 22 |
virtual bool OpenDRMSystem(std::string_view licenseURL, |
| 23 |
const std::vector<uint8_t>& serverCertificate, |
| 24 |
const uint8_t config) override; |
| 25 |
virtual Adaptive_CencSingleSampleDecrypter* CreateSingleSampleDecrypter( |
| 26 |
std::vector<uint8_t>& initData, |
| 27 |
std::string_view optionalKeyParameter, |
| 28 |
const std::vector<uint8_t>& defaultkeyid, |
| 29 |
std::string_view licenseUrl, |
| 30 |
bool skipSessionMessage, |
| 31 |
CryptoMode cryptoMode) override; |
| 32 |
virtual void DestroySingleSampleDecrypter(Adaptive_CencSingleSampleDecrypter* decrypter) override; |
| 33 |
virtual void GetCapabilities(Adaptive_CencSingleSampleDecrypter* decrypter, |
| 34 |
const std::vector<uint8_t>& keyid, |
| 35 |
uint32_t media, |
| 36 |
DRM::DecrypterCapabilites& caps) override |
| 37 |
{ |
| 38 |
} |
| 39 |
virtual bool HasLicenseKey(Adaptive_CencSingleSampleDecrypter* decrypter, |
| 40 |
const std::vector<uint8_t>& keyid) override; |
| 41 |
virtual bool IsInitialised() override { return true; } |
| 42 |
virtual std::string GetChallengeB64Data(Adaptive_CencSingleSampleDecrypter* decrypter) override |
| 43 |
{ |
| 44 |
return ""; |
| 45 |
} |
| 46 |
virtual bool OpenVideoDecoder(Adaptive_CencSingleSampleDecrypter* decrypter, |
| 47 |
const VIDEOCODEC_INITDATA* initData) override |
| 48 |
{ |
| 49 |
return false; |
| 50 |
} |
| 51 |
virtual VIDEOCODEC_RETVAL DecryptAndDecodeVideo(kodi::addon::CInstanceVideoCodec* hostInstance, |
| 52 |
const DEMUX_PACKET* sample) override |
| 53 |
{ |
| 54 |
return VC_NONE; |
| 55 |
} |
| 56 |
virtual VIDEOCODEC_RETVAL VideoFrameDataToPicture(kodi::addon::CInstanceVideoCodec* hostInstance, |
| 57 |
VIDEOCODEC_PICTURE* picture) override |
| 58 |
{ |
| 59 |
return VC_NONE; |
| 60 |
} |
| 61 |
virtual void ResetVideo() override {} |
| 62 |
virtual void SetLibraryPath(std::string_view libraryPath) override |
| 63 |
{ |
| 64 |
m_libraryPath = libraryPath; |
| 65 |
} |
| 66 |
|
| 67 |
virtual bool GetBuffer(void* instance, VIDEOCODEC_PICTURE& picture) { return false; } |
| 68 |
virtual void ReleaseBuffer(void* instance, void* buffer) {} |
| 69 |
virtual std::string_view GetLibraryPath() const override { return m_libraryPath; } |
| 70 |
|
| 71 |
void insertssd(AP4_CencSingleSampleDecrypter* ssd) { ssds.push_back(ssd); }; |
| 72 |
void removessd(AP4_CencSingleSampleDecrypter* ssd) |
| 73 |
{ |
| 74 |
std::vector<AP4_CencSingleSampleDecrypter*>::iterator res( |
| 75 |
std::find(ssds.begin(), ssds.end(), ssd)); |
| 76 |
if (res != ssds.end()) |
| 77 |
ssds.erase(res); |
| 78 |
}; |
| 79 |
|
| 80 |
private: |
| 81 |
std::vector<AP4_CencSingleSampleDecrypter*> ssds; |
| 82 |
std::string m_libraryPath; |
| 83 |
}; |