/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class SessionManagerWrapper; class WMFClearKeySession;
// This our customized MFCDM for supporting clearkey in our testing. It would // use ClearKeySessionManager via SessionManagerWrapper to perform decryption. class WMFClearKeyCDM final
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IMFContentDecryptionModule, IMFGetService, IMFShutdown,
Microsoft::WRL::FtmBase> { public:
WMFClearKeyCDM() = default;
~WMFClearKeyCDM();
WMFClearKeyCDM(const WMFClearKeyCDM&) = delete;
WMFClearKeyCDM& operator=(const WMFClearKeyCDM&) = delete;
// In order to reuse existing Gecko clearkey implementation, we need to // inherit the class `cdm::Host_11`. // TODO : add a way to assert thread usage. It would be used on MF thread pool // and the media supervisor thread pool. class SessionManagerWrapper final : public RefCounted, private cdm::Host_11 { public: explicit SessionManagerWrapper(WMFClearKeyCDM* aCDM);
// This is a RAII helper class to use ClearKeySessionManager::XXXSession // methods in a sync style, which is what MFCDM is required. // ClearKeySessionManager uses cdm::Host_11's OnResolve/RejectXXX as callback // to report whether those function calls relatd with specific promise id // succeed or not. As we only do temporary session for ClearKey testing, we // don't need to wait to setup the storage so calling those XXXsession // functions are actully a sync process. We guarantee that // ClearKeySessionManager will use OnResolve/Reject methods to notify us // result, right after we calling the session related method. // [How to to use this class, not thread-safe] // 1. create it on the stack // 2. use GetPromiseId() to generate a fake promise id for tracking // 3. in cdm::Host_11's callback function, check promise id to know what // result needs to be set // 4. check result to see if the session method succeed or not class SyncResultChecker final { public: using ResultType = std::variant<constchar*, bool>; explicit SyncResultChecker(SessionManagerWrapper& aOwner)
: mOwner(aOwner), mIdx(sIdx++), mKeySession(nullptr) {
mOwner.mActiveSyncResultChecker.insert({mIdx, this});
}
SyncResultChecker(SessionManagerWrapper& aOwner,
WMFClearKeySession* aKeySession)
: mOwner(aOwner), mIdx(sIdx++), mKeySession(aKeySession) {
mOwner.mActiveSyncResultChecker.insert({mIdx, this});
}
~SyncResultChecker() { mOwner.mActiveSyncResultChecker.erase(mIdx); }
uint32_t GetPromiseId() const { return mIdx; } const ResultType& GetResult() const { return mResult; }
WMFClearKeySession* GetKeySession() const { return mKeySession; }
private: // Only allow setting result from these callbacks. friendvoid SessionManagerWrapper::OnResolveNewSessionPromise(uint32_t, constchar*,
uint32_t); friendvoid SessionManagerWrapper::OnResolvePromise(uint32_t); friendvoid SessionManagerWrapper::OnRejectPromise(uint32_t, cdm::Exception,
uint32_t, constchar*,
uint32_t); void SetResultConstChar(constchar* aResult) {
mResult.emplace<constchar*>(aResult);
} void SetResultBool(bool aResult) { mResult.emplace<bool>(aResult); }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.