ClearKeyCDM.h (3641B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef ClearKeyCDM_h_ 8 #define ClearKeyCDM_h_ 9 10 // This include is required in order for content_decryption_module to work 11 // on Unix systems. 12 13 #include "content_decryption_module.h" 14 15 #include "ClearKeySessionManager.h" 16 17 #ifdef ENABLE_WMF 18 # include "VideoDecoder.h" 19 # include "WMFUtils.h" 20 #endif 21 22 class ClearKeyCDM final : public cdm::ContentDecryptionModule_11 { 23 private: 24 RefPtr<ClearKeySessionManager> mSessionManager; 25 #ifdef ENABLE_WMF 26 RefPtr<VideoDecoder> mVideoDecoder; 27 #endif 28 bool mIsProtectionQueryEnabled = false; 29 30 protected: 31 cdm::Host_11* mHost; 32 33 public: 34 explicit ClearKeyCDM(cdm::Host_11* aHost); 35 36 void Initialize(bool aAllowDistinctiveIdentifier, bool aAllowPersistentState, 37 bool aUseHardwareSecureCodecs) override; 38 39 void GetStatusForPolicy(uint32_t aPromiseId, 40 const cdm::Policy& aPolicy) override; 41 42 void SetServerCertificate(uint32_t aPromiseId, 43 const uint8_t* aServerCertificateData, 44 uint32_t aServerCertificateDataSize) override; 45 46 void CreateSessionAndGenerateRequest(uint32_t aPromiseId, 47 cdm::SessionType aSessionType, 48 cdm::InitDataType aInitDataType, 49 const uint8_t* aInitData, 50 uint32_t aInitDataSize) override; 51 52 void LoadSession(uint32_t aPromiseId, cdm::SessionType aSessionType, 53 const char* aSessionId, uint32_t aSessionIdSize) override; 54 55 void UpdateSession(uint32_t aPromiseId, const char* aSessionId, 56 uint32_t aSessionIdSize, const uint8_t* aResponse, 57 uint32_t aResponseSize) override; 58 59 void CloseSession(uint32_t aPromiseId, const char* aSessionId, 60 uint32_t aSessionIdSize) override; 61 62 void RemoveSession(uint32_t aPromiseId, const char* aSessionId, 63 uint32_t aSessionIdSize) override; 64 65 void TimerExpired(void* aContext) override; 66 67 cdm::Status Decrypt(const cdm::InputBuffer_2& aEncryptedBuffer, 68 cdm::DecryptedBlock* aDecryptedBuffer) override; 69 70 cdm::Status InitializeAudioDecoder( 71 const cdm::AudioDecoderConfig_2& aAudioDecoderConfig) override; 72 73 cdm::Status InitializeVideoDecoder( 74 const cdm::VideoDecoderConfig_2& aVideoDecoderConfig) override; 75 76 void DeinitializeDecoder(cdm::StreamType aDecoderType) override; 77 78 void ResetDecoder(cdm::StreamType aDecoderType) override; 79 80 cdm::Status DecryptAndDecodeFrame(const cdm::InputBuffer_2& aEncryptedBuffer, 81 cdm::VideoFrame* aVideoFrame) override; 82 83 cdm::Status DecryptAndDecodeSamples( 84 const cdm::InputBuffer_2& aEncryptedBuffer, 85 cdm::AudioFrames* aAudioFrame) override; 86 87 void OnPlatformChallengeResponse( 88 const cdm::PlatformChallengeResponse& aResponse) override; 89 90 void OnQueryOutputProtectionStatus(cdm::QueryResult aResult, 91 uint32_t aLinkMask, 92 uint32_t aOutputProtectionMask) override; 93 94 void OnStorageId(uint32_t aVersion, const uint8_t* aStorageId, 95 uint32_t aStorageIdSize) override; 96 97 void Destroy() override; 98 99 void EnableProtectionQuery(); 100 }; 101 102 #endif