MediaDrmCDMCallbackProxy.h (2333B)
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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MediaDrmCDMCallbackProxy_h_ 8 #define MediaDrmCDMCallbackProxy_h_ 9 10 #include "mozilla/CDMProxy.h" 11 #include "mozilla/DecryptorProxyCallback.h" 12 13 namespace mozilla { 14 class CDMProxy; 15 class ErrorResult; 16 class MediaDrmCDMProxy; 17 18 // Proxies call backs from the MediaDrmProxy -> MediaDrmProxySupport back to the 19 // MediaKeys object on the main thread. We used annotation calledFrom = "gecko" 20 // to ensure running on main thread. 21 class MediaDrmCDMCallbackProxy final : public DecryptorProxyCallback { 22 public: 23 void SetSessionId(uint32_t aCreateSessionToken, 24 const nsCString& aSessionId) override; 25 26 void ResolveLoadSessionPromise(uint32_t aPromiseId, bool aSuccess) override; 27 28 void ResolvePromise(uint32_t aPromiseId) override; 29 30 void RejectPromise(uint32_t aPromiseId, ErrorResult&& aException, 31 const nsCString& aSessionId) override; 32 33 void SessionMessage(const nsCString& aSessionId, 34 dom::MediaKeyMessageType aMessageType, 35 const nsTArray<uint8_t>& aMessage) override; 36 37 void ExpirationChange(const nsCString& aSessionId, 38 UnixTime aExpiryTime) override; 39 40 void SessionClosed(const nsCString& aSessionId) override; 41 42 void SessionError(const nsCString& aSessionId, nsresult aException, 43 uint32_t aSystemCode, const nsCString& aMessage) override; 44 45 void Decrypted(uint32_t aId, DecryptStatus aResult, 46 const nsTArray<uint8_t>& aDecryptedData) override; 47 48 void BatchedKeyStatusChanged(const nsCString& aSessionId, 49 const nsTArray<CDMKeyInfo>& aKeyInfos) override; 50 51 ~MediaDrmCDMCallbackProxy(); 52 53 private: 54 friend class MediaDrmCDMProxy; 55 explicit MediaDrmCDMCallbackProxy(MediaDrmCDMProxy* aProxy); 56 57 void BatchedKeyStatusChangedInternal(const nsCString& aSessionId, 58 const nsTArray<CDMKeyInfo>& aKeyInfos); 59 const RefPtr<MediaDrmCDMProxy> mProxy; 60 }; 61 62 } // namespace mozilla 63 #endif