Line data Source code
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 GMPCDMCallbackProxy_h_
8 : #define GMPCDMCallbackProxy_h_
9 :
10 : #include "mozilla/CDMProxy.h"
11 : #include "gmp-decryption.h"
12 : #include "GMPDecryptorProxy.h"
13 :
14 : namespace mozilla {
15 :
16 : // Proxies call backs from the CDM on the GMP thread back to the MediaKeys
17 : // object on the main thread.
18 : class GMPCDMCallbackProxy : public GMPDecryptorProxyCallback {
19 : public:
20 :
21 : void SetDecryptorId(uint32_t aId) override;
22 :
23 : void SetSessionId(uint32_t aCreateSessionToken,
24 : const nsCString& aSessionId) override;
25 :
26 : void ResolveLoadSessionPromise(uint32_t aPromiseId,
27 : bool aSuccess) override;
28 :
29 : void ResolvePromise(uint32_t aPromiseId) override;
30 :
31 : void RejectPromise(uint32_t aPromiseId,
32 : nsresult aException,
33 : const nsCString& aSessionId) override;
34 :
35 : void SessionMessage(const nsCString& aSessionId,
36 : dom::MediaKeyMessageType aMessageType,
37 : const nsTArray<uint8_t>& aMessage) override;
38 :
39 : void ExpirationChange(const nsCString& aSessionId,
40 : UnixTime aExpiryTime) override;
41 :
42 : void SessionClosed(const nsCString& aSessionId) override;
43 :
44 : void SessionError(const nsCString& aSessionId,
45 : nsresult aException,
46 : uint32_t aSystemCode,
47 : const nsCString& aMessage) override;
48 :
49 : void Decrypted(uint32_t aId,
50 : DecryptStatus aResult,
51 : const nsTArray<uint8_t>& aDecryptedData) override;
52 :
53 : void BatchedKeyStatusChanged(const nsCString& aSessionId,
54 : const nsTArray<CDMKeyInfo>& aKeyInfos) override;
55 :
56 : void Terminated() override;
57 :
58 0 : ~GMPCDMCallbackProxy() {}
59 :
60 : private:
61 : friend class GMPCDMProxy;
62 : GMPCDMCallbackProxy(CDMProxy* aProxy, nsIEventTarget* aMainThread);
63 :
64 : void BatchedKeyStatusChangedInternal(const nsCString& aSessionId,
65 : const nsTArray<CDMKeyInfo>& aKeyInfos);
66 : // Warning: Weak ref.
67 : CDMProxy* mProxy;
68 :
69 : const nsCOMPtr<nsIEventTarget> mMainThread;
70 : };
71 :
72 : } // namespace mozilla
73 :
74 : #endif // GMPCDMCallbackProxy_h_
|