/* * Copyright (C) 2023 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #pragma once #include "../IDecrypter.h" #include "common/AdaptiveCencSampleDecrypter.h" #include #include #include class CWVCdmAdapterA; class CWVDecrypterA; class ATTR_DLL_LOCAL CWVCencSingleSampleDecrypterA : public Adaptive_CencSingleSampleDecrypter { public: // methods CWVCencSingleSampleDecrypterA(CWVCdmAdapterA& drm, std::vector& pssh, std::string_view optionalKeyParameter, const std::vector& defaultKeyId, CWVDecrypterA* host); virtual ~CWVCencSingleSampleDecrypterA(); bool StartSession(bool skipSessionMessage) { return KeyUpdateRequest(true, skipSessionMessage); }; const std::vector& GetSessionIdRaw() { return m_sessionId; }; virtual const char* GetSessionId() override; std::vector GetChallengeData(); virtual bool HasLicenseKey(const std::vector& keyId); virtual AP4_Result SetFragmentInfo(AP4_UI32 poolId, const std::vector& keyId, const AP4_UI08 nalLengthSize, AP4_DataBuffer& annexbSpsPps, AP4_UI32 flags, CryptoInfo cryptoInfo) override; virtual AP4_UI32 AddPool() override; virtual void RemovePool(AP4_UI32 poolId) override; virtual AP4_Result DecryptSampleData( AP4_UI32 poolId, AP4_DataBuffer& dataIn, AP4_DataBuffer& dataOut, // always 16 bytes const AP4_UI08* iv, // pass 0 for full decryption unsigned int subsampleCount, // array of integers. NULL if subsample_count is 0 const AP4_UI16* bytesOfCleartextData, // array of integers. NULL if subsample_count is 0 const AP4_UI32* bytesOfEncryptedData) override; void GetCapabilities(const std::vector& keyId, uint32_t media, DRM::DecrypterCapabilites& caps); void RequestNewKeys() { m_isKeyUpdateRequested = true; }; private: bool ProvisionRequest(); bool GetKeyRequest(std::vector& keyRequestData); bool KeyUpdateRequest(bool waitForKeys, bool skipSessionMessage); bool SendSessionMessage(const std::vector& keyRequestData); CWVCdmAdapterA& m_mediaDrm; std::vector m_pssh; std::vector m_initialPssh; std::map m_optParams; CWVDecrypterA* m_host; std::vector m_sessionId; std::vector m_keySetId; std::vector m_keyRequestData; char m_sessionIdChar[128]; bool m_isProvisioningRequested; bool m_isKeyUpdateRequested; std::vector m_defaultKeyId; struct FINFO { std::vector m_key; AP4_UI08 m_nalLengthSize; AP4_UI16 m_decrypterFlags; AP4_DataBuffer m_annexbSpsPps; }; std::vector m_fragmentPool; int m_hdcpLimit; int m_resolutionLimit; };