diff --git a/media/gmp-clearkey/0.1/ClearKeyCDM.cpp b/media/gmp-clearkey/0.1/ClearKeyCDM.cpp index 9991f5b851e0..20a032cbb1b0 100644 --- a/media/gmp-clearkey/0.1/ClearKeyCDM.cpp +++ b/media/gmp-clearkey/0.1/ClearKeyCDM.cpp @@ -4,14 +4,17 @@ using namespace cdm; -ClearKeyCDM::ClearKeyCDM(Host_9* aHost) { +ClearKeyCDM::ClearKeyCDM(Host_10* aHost) { mHost = aHost; mSessionManager = new ClearKeySessionManager(mHost); } void ClearKeyCDM::Initialize(bool aAllowDistinctiveIdentifier, - bool aAllowPersistentState) { + bool aAllowPersistentState, + bool aUseHardwareSecureCodecs) { mSessionManager->Init(aAllowDistinctiveIdentifier, aAllowPersistentState); + // We call mHost->OnInitialized() in the session manager once it has + // initialized. } void ClearKeyCDM::GetStatusForPolicy(uint32_t aPromiseId, @@ -66,13 +69,13 @@ void ClearKeyCDM::TimerExpired(void* aContext) { assert(false); } -Status ClearKeyCDM::Decrypt(const InputBuffer_1& aEncryptedBuffer, +Status ClearKeyCDM::Decrypt(const InputBuffer_2& aEncryptedBuffer, DecryptedBlock* aDecryptedBuffer) { return mSessionManager->Decrypt(aEncryptedBuffer, aDecryptedBuffer); } Status ClearKeyCDM::InitializeAudioDecoder( - const AudioDecoderConfig_1& aAudioDecoderConfig) { + const AudioDecoderConfig_2& aAudioDecoderConfig) { // Audio decoding is not supported by Clearkey because Widevine doesn't // support it and Clearkey's raison d'etre is to provide test coverage // for paths that Widevine will exercise in the wild. @@ -80,7 +83,7 @@ Status ClearKeyCDM::InitializeAudioDecoder( } Status ClearKeyCDM::InitializeVideoDecoder( - const VideoDecoderConfig_1& aVideoDecoderConfig) { + const VideoDecoderConfig_2& aVideoDecoderConfig) { #ifdef ENABLE_WMF mVideoDecoder = new VideoDecoder(mHost); return mVideoDecoder->InitDecode(aVideoDecoderConfig); @@ -106,7 +109,7 @@ void ClearKeyCDM::ResetDecoder(StreamType aDecoderType) { #endif } -Status ClearKeyCDM::DecryptAndDecodeFrame(const InputBuffer_1& aEncryptedBuffer, +Status ClearKeyCDM::DecryptAndDecodeFrame(const InputBuffer_2& aEncryptedBuffer, VideoFrame* aVideoFrame) { #ifdef ENABLE_WMF return mVideoDecoder->Decode(aEncryptedBuffer, aVideoFrame); @@ -116,7 +119,7 @@ Status ClearKeyCDM::DecryptAndDecodeFrame(const InputBuffer_1& aEncryptedBuffer, } Status ClearKeyCDM::DecryptAndDecodeSamples( - const InputBuffer_1& aEncryptedBuffer, AudioFrames* aAudioFrame) { + const InputBuffer_2& aEncryptedBuffer, AudioFrames* aAudioFrame) { // Audio decoding is not supported by Clearkey because Widevine doesn't // support it and Clearkey's raison d'etre is to provide test coverage // for paths that Widevine will exercise in the wild. diff --git a/media/gmp-clearkey/0.1/ClearKeyCDM.h b/media/gmp-clearkey/0.1/ClearKeyCDM.h index 5fd280015839..ff75d65a9c3e 100644 --- a/media/gmp-clearkey/0.1/ClearKeyCDM.h +++ b/media/gmp-clearkey/0.1/ClearKeyCDM.h @@ -13,7 +13,7 @@ #include "VideoDecoder.h" #endif -class ClearKeyCDM : public cdm::ContentDecryptionModule_9 { +class ClearKeyCDM : public cdm::ContentDecryptionModule_10 { private: RefPtr mSessionManager; #ifdef ENABLE_WMF @@ -21,13 +21,13 @@ class ClearKeyCDM : public cdm::ContentDecryptionModule_9 { #endif protected: - cdm::Host_9* mHost; + cdm::Host_10* mHost; public: - explicit ClearKeyCDM(cdm::Host_9* mHost); + explicit ClearKeyCDM(cdm::Host_10* aHost); - void Initialize(bool aAllowDistinctiveIdentifier, - bool aAllowPersistentState) override; + void Initialize(bool aAllowDistinctiveIdentifier, bool aAllowPersistentState, + bool aUseHardwareSecureCodecs) override; void GetStatusForPolicy(uint32_t aPromiseId, const cdm::Policy& aPolicy) override; @@ -57,24 +57,24 @@ class ClearKeyCDM : public cdm::ContentDecryptionModule_9 { void TimerExpired(void* aContext) override; - cdm::Status Decrypt(const cdm::InputBuffer_1& aEncryptedBuffer, + cdm::Status Decrypt(const cdm::InputBuffer_2& aEncryptedBuffer, cdm::DecryptedBlock* aDecryptedBuffer) override; cdm::Status InitializeAudioDecoder( - const cdm::AudioDecoderConfig_1& aAudioDecoderConfig) override; + const cdm::AudioDecoderConfig_2& aAudioDecoderConfig) override; cdm::Status InitializeVideoDecoder( - const cdm::VideoDecoderConfig_1& aVideoDecoderConfig) override; + const cdm::VideoDecoderConfig_2& aVideoDecoderConfig) override; void DeinitializeDecoder(cdm::StreamType aDecoderType) override; void ResetDecoder(cdm::StreamType aDecoderType) override; - cdm::Status DecryptAndDecodeFrame(const cdm::InputBuffer_1& aEncryptedBuffer, + cdm::Status DecryptAndDecodeFrame(const cdm::InputBuffer_2& aEncryptedBuffer, cdm::VideoFrame* aVideoFrame) override; cdm::Status DecryptAndDecodeSamples( - const cdm::InputBuffer_1& aEncryptedBuffer, + const cdm::InputBuffer_2& aEncryptedBuffer, cdm::AudioFrames* aAudioFrame) override; void OnPlatformChallengeResponse( diff --git a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.h b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.h index 3c06dba8f3d7..e61e09cfc9ff 100644 --- a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.h +++ b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.h @@ -32,11 +32,11 @@ class CryptoMetaData { public: CryptoMetaData() {} - explicit CryptoMetaData(const cdm::InputBuffer_1* aInputBuffer) { + explicit CryptoMetaData(const cdm::InputBuffer_2* aInputBuffer) { Init(aInputBuffer); } - void Init(const cdm::InputBuffer_1* aInputBuffer) { + void Init(const cdm::InputBuffer_2* aInputBuffer) { if (!aInputBuffer) { assert(!IsValid()); return; diff --git a/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp b/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp index 897512d85727..613549703d16 100644 --- a/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp +++ b/media/gmp-clearkey/0.1/ClearKeyPersistence.cpp @@ -89,7 +89,9 @@ void ClearKeyPersistence::WriteIndex() { WriteData(mHost, filename, data, move(onIndexSuccess), move(onIndexFail)); } -ClearKeyPersistence::ClearKeyPersistence(Host_9* aHost) { this->mHost = aHost; } +ClearKeyPersistence::ClearKeyPersistence(Host_10* aHost) { + this->mHost = aHost; +} void ClearKeyPersistence::EnsureInitialized(bool aPersistentStateAllowed, function&& aOnInitialized) { diff --git a/media/gmp-clearkey/0.1/ClearKeyPersistence.h b/media/gmp-clearkey/0.1/ClearKeyPersistence.h index a740456bf75f..28cabd6bbcd9 100644 --- a/media/gmp-clearkey/0.1/ClearKeyPersistence.h +++ b/media/gmp-clearkey/0.1/ClearKeyPersistence.h @@ -35,7 +35,7 @@ enum PersistentKeyState { UNINITIALIZED, LOADING, LOADED }; class ClearKeyPersistence : public RefCounted { public: - explicit ClearKeyPersistence(cdm::Host_9* aHost); + explicit ClearKeyPersistence(cdm::Host_10* aHost); void EnsureInitialized(bool aPersistentStateAllowed, std::function&& aOnInitialized); @@ -49,7 +49,7 @@ class ClearKeyPersistence : public RefCounted { void PersistentSessionRemoved(std::string& aSid); private: - cdm::Host_9* mHost = nullptr; + cdm::Host_10* mHost = nullptr; PersistentKeyState mPersistentKeyState = PersistentKeyState::UNINITIALIZED; diff --git a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp index 1609a1615705..7d6c05e01a84 100644 --- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp +++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp @@ -33,7 +33,7 @@ using namespace std; using namespace cdm; -ClearKeySessionManager::ClearKeySessionManager(Host_9* aHost) +ClearKeySessionManager::ClearKeySessionManager(Host_10* aHost) : mDecryptionManager(ClearKeyDecryptionManager::Get()) { CK_LOGD("ClearKeySessionManager ctor %p", this); AddRef(); @@ -58,6 +58,11 @@ void ClearKeySessionManager::Init(bool aDistinctiveIdentifierAllowed, func(); } + if (self->mHost) { + // The session manager should be the last thing the ClearKey CDM is + // waiting on to be initialized. + self->mHost->OnInitialized(true); + } }; mPersistence->EnsureInitialized(aPersistentStateAllowed, @@ -529,7 +534,7 @@ void ClearKeySessionManager::SetServerCertificate(uint32_t aPromiseId, nullptr /* message */, 0 /* messageLen */); } -Status ClearKeySessionManager::Decrypt(const InputBuffer_1& aBuffer, +Status ClearKeySessionManager::Decrypt(const InputBuffer_2& aBuffer, DecryptedBlock* aDecryptedBlock) { CK_LOGD("ClearKeySessionManager::Decrypt"); diff --git a/media/gmp-clearkey/0.1/ClearKeySessionManager.h b/media/gmp-clearkey/0.1/ClearKeySessionManager.h index ead6ef056b45..012ff693ceab 100644 --- a/media/gmp-clearkey/0.1/ClearKeySessionManager.h +++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.h @@ -35,7 +35,7 @@ class ClearKeySessionManager final : public RefCounted { public: - explicit ClearKeySessionManager(cdm::Host_9* aHost); + explicit ClearKeySessionManager(cdm::Host_10* aHost); void Init(bool aDistinctiveIdentifierAllowed, bool aPersistentStateAllowed); @@ -59,7 +59,7 @@ class ClearKeySessionManager final : public RefCounted { void SetServerCertificate(uint32_t aPromiseId, const uint8_t* aServerCert, uint32_t aServerCertSize); - cdm::Status Decrypt(const cdm::InputBuffer_1& aBuffer, + cdm::Status Decrypt(const cdm::InputBuffer_2& aBuffer, cdm::DecryptedBlock* aDecryptedBlock); void DecryptingComplete(); @@ -80,7 +80,7 @@ class ClearKeySessionManager final : public RefCounted { RefPtr mDecryptionManager; RefPtr mPersistence; - cdm::Host_9* mHost = nullptr; + cdm::Host_10* mHost = nullptr; std::set mKeyIds; std::map mSessions; diff --git a/media/gmp-clearkey/0.1/ClearKeyStorage.cpp b/media/gmp-clearkey/0.1/ClearKeyStorage.cpp index e11b2507e58d..4736d68b241e 100644 --- a/media/gmp-clearkey/0.1/ClearKeyStorage.cpp +++ b/media/gmp-clearkey/0.1/ClearKeyStorage.cpp @@ -36,7 +36,7 @@ class WriteRecordClient : public FileIOClient { * This function will take the memory ownership of the parameters and * delete them when done. */ - static void Write(Host_9* aHost, string& aRecordName, + static void Write(Host_10* aHost, string& aRecordName, const vector& aData, function&& aOnSuccess, function&& aOnFailure) { WriteRecordClient* client = @@ -71,7 +71,7 @@ class WriteRecordClient : public FileIOClient { mOnFailure(move(aOnFailure)), mData(aData) {} - void Do(const string& aName, Host_9* aHost) { + void Do(const string& aName, Host_10* aHost) { // Initialize the FileIO. mFileIO = aHost->CreateFileIO(this); mFileIO->Open(aName.c_str(), aName.size()); @@ -104,8 +104,9 @@ class WriteRecordClient : public FileIOClient { const vector mData; }; -void WriteData(Host_9* aHost, string& aRecordName, const vector& aData, - function&& aOnSuccess, function&& aOnFailure) { +void WriteData(Host_10* aHost, string& aRecordName, + const vector& aData, function&& aOnSuccess, + function&& aOnFailure) { WriteRecordClient::Write(aHost, aRecordName, aData, move(aOnSuccess), move(aOnFailure)); } @@ -116,7 +117,7 @@ class ReadRecordClient : public FileIOClient { * This function will take the memory ownership of the parameters and * delete them when done. */ - static void Read(Host_9* aHost, string& aRecordName, + static void Read(Host_10* aHost, string& aRecordName, function&& aOnSuccess, function&& aOnFailure) { (new ReadRecordClient(move(aOnSuccess), move(aOnFailure))) @@ -150,7 +151,7 @@ class ReadRecordClient : public FileIOClient { mOnSuccess(move(aOnSuccess)), mOnFailure(move(aOnFailure)) {} - void Do(const string& aName, Host_9* aHost) { + void Do(const string& aName, Host_10* aHost) { mFileIO = aHost->CreateFileIO(this); mFileIO->Open(aName.c_str(), aName.size()); } @@ -181,9 +182,9 @@ class ReadRecordClient : public FileIOClient { function mOnFailure; }; -void ReadData(Host_9* mHost, string& aRecordName, +void ReadData(Host_10* aHost, string& aRecordName, function&& aOnSuccess, function&& aOnFailure) { - ReadRecordClient::Read(mHost, aRecordName, move(aOnSuccess), + ReadRecordClient::Read(aHost, aRecordName, move(aOnSuccess), move(aOnFailure)); } diff --git a/media/gmp-clearkey/0.1/ClearKeyStorage.h b/media/gmp-clearkey/0.1/ClearKeyStorage.h index ce5f6d0cd503..2f964abdd570 100644 --- a/media/gmp-clearkey/0.1/ClearKeyStorage.h +++ b/media/gmp-clearkey/0.1/ClearKeyStorage.h @@ -28,13 +28,13 @@ #define IO_FAILED(x) ((x) != cdm::FileIOClient::Status::kSuccess) // Writes data to a file and fires the appropriate callback when complete. -void WriteData(cdm::Host_9* aHost, std::string& aRecordName, +void WriteData(cdm::Host_10* aHost, std::string& aRecordName, const std::vector& aData, std::function&& aOnSuccess, std::function&& aOnFailure); // Reads data from a file and fires the appropriate callback when complete. -void ReadData(cdm::Host_9* aHost, std::string& aRecordName, +void ReadData(cdm::Host_10* aHost, std::string& aRecordName, std::function&& aOnSuccess, std::function&& aOnFailure); diff --git a/media/gmp-clearkey/0.1/VideoDecoder.cpp b/media/gmp-clearkey/0.1/VideoDecoder.cpp index 8d108a3dc0ed..ce2faf3b7f68 100644 --- a/media/gmp-clearkey/0.1/VideoDecoder.cpp +++ b/media/gmp-clearkey/0.1/VideoDecoder.cpp @@ -27,7 +27,7 @@ using namespace wmf; using namespace cdm; -VideoDecoder::VideoDecoder(Host_9* aHost) : mHost(aHost), mHasShutdown(false) { +VideoDecoder::VideoDecoder(Host_10* aHost) : mHost(aHost), mHasShutdown(false) { CK_LOGD("VideoDecoder created"); // We drop the ref in DecodingComplete(). @@ -42,7 +42,7 @@ VideoDecoder::VideoDecoder(Host_9* aHost) : mHost(aHost), mHasShutdown(false) { VideoDecoder::~VideoDecoder() { CK_LOGD("VideoDecoder destroyed"); } -Status VideoDecoder::InitDecode(const VideoDecoderConfig_1& aConfig) { +Status VideoDecoder::InitDecode(const VideoDecoderConfig_2& aConfig) { CK_LOGD("VideoDecoder::InitDecode"); if (!mDecoder) { @@ -54,7 +54,7 @@ Status VideoDecoder::InitDecode(const VideoDecoderConfig_1& aConfig) { return Status::kSuccess; } -Status VideoDecoder::Decode(const InputBuffer_1& aInputBuffer, +Status VideoDecoder::Decode(const InputBuffer_2& aInputBuffer, VideoFrame* aVideoFrame) { CK_LOGD("VideoDecoder::Decode"); // If the input buffer we have been passed has a null buffer, it means we diff --git a/media/gmp-clearkey/0.1/VideoDecoder.h b/media/gmp-clearkey/0.1/VideoDecoder.h index b41914750018..1f7b2ea5f4b9 100644 --- a/media/gmp-clearkey/0.1/VideoDecoder.h +++ b/media/gmp-clearkey/0.1/VideoDecoder.h @@ -29,11 +29,11 @@ class VideoDecoder : public RefCounted { public: - explicit VideoDecoder(cdm::Host_9* aHost); + explicit VideoDecoder(cdm::Host_10* aHost); - cdm::Status InitDecode(const cdm::VideoDecoderConfig_1& aConfig); + cdm::Status InitDecode(const cdm::VideoDecoderConfig_2& aConfig); - cdm::Status Decode(const cdm::InputBuffer_1& aEncryptedBuffer, + cdm::Status Decode(const cdm::InputBuffer_2& aEncryptedBuffer, cdm::VideoFrame* aVideoFrame); void Reset(); @@ -60,7 +60,7 @@ class VideoDecoder : public RefCounted { int32_t aFrameHeight, cdm::VideoFrame* aVideoFrame); - cdm::Host_9* mHost; + cdm::Host_10* mHost; wmf::AutoPtr mDecoder; std::queue> mOutputQueue; diff --git a/media/gmp-clearkey/0.1/gmp-clearkey.cpp b/media/gmp-clearkey/0.1/gmp-clearkey.cpp index c450cf215d40..a0727005a28d 100644 --- a/media/gmp-clearkey/0.1/gmp-clearkey.cpp +++ b/media/gmp-clearkey/0.1/gmp-clearkey.cpp @@ -50,7 +50,7 @@ void* CreateCdmInstance(int cdm_interface_version, const char* key_system, GetCdmHostFunc get_cdm_host_func, void* user_data) { CK_LOGE("ClearKey CreateCDMInstance"); - if (cdm_interface_version != cdm::ContentDecryptionModule_9::kVersion) { + if (cdm_interface_version != cdm::ContentDecryptionModule_10::kVersion) { CK_LOGE( "ClearKey CreateCDMInstance failed due to requesting unsupported " "version %d.", @@ -71,7 +71,7 @@ void* CreateCdmInstance(int cdm_interface_version, const char* key_system, } #endif - cdm::Host_9* host = static_cast( + cdm::Host_10* host = static_cast( get_cdm_host_func(cdm_interface_version, user_data)); ClearKeyCDM* clearKey = new ClearKeyCDM(host); diff --git a/media/gmp-clearkey/0.1/manifest.json.in b/media/gmp-clearkey/0.1/manifest.json.in index 3393f6e1b770..dd36af855660 100644 --- a/media/gmp-clearkey/0.1/manifest.json.in +++ b/media/gmp-clearkey/0.1/manifest.json.in @@ -3,8 +3,8 @@ "description": "ClearKey Gecko Media Plugin", "version": "1", "x-cdm-module-versions": "4", - "x-cdm-interface-versions": "9", - "x-cdm-host-versions": "9", + "x-cdm-interface-versions": "10", + "x-cdm-host-versions": "10", #ifdef ENABLE_WMF "x-cdm-codecs": "avc1" #else