/src/mozilla-central/dom/media/gmp/ChromiumCDMChild.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef ChromiumCDMChild_h_ |
7 | | #define ChromiumCDMChild_h_ |
8 | | |
9 | | #include "content_decryption_module.h" |
10 | | #include "mozilla/gmp/PChromiumCDMChild.h" |
11 | | #include "SimpleMap.h" |
12 | | #include "WidevineVideoFrame.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace gmp { |
16 | | |
17 | | class GMPContentChild; |
18 | | |
19 | | class ChromiumCDMChild |
20 | | : public PChromiumCDMChild |
21 | | , public cdm::Host_9 |
22 | | , public cdm::Host_10 |
23 | | { |
24 | | public: |
25 | | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChromiumCDMChild); |
26 | | |
27 | | explicit ChromiumCDMChild(GMPContentChild* aPlugin); |
28 | | |
29 | | void Init(cdm::ContentDecryptionModule_10* aCDM, const nsCString& aStorageId); |
30 | | |
31 | | void TimerExpired(void* aContext); |
32 | | |
33 | | // Shared cdm::Host_9 and cdm::Host10 implementation |
34 | | cdm::Buffer* Allocate(uint32_t aCapacity) override; |
35 | | void SetTimer(int64_t aDelayMs, void* aContext) override; |
36 | | cdm::Time GetCurrentWallTime() override; |
37 | | void OnResolveKeyStatusPromise(uint32_t aPromiseId, |
38 | | cdm::KeyStatus aKeyStatus) override; |
39 | | void OnResolveNewSessionPromise(uint32_t aPromiseId, |
40 | | const char* aSessionId, |
41 | | uint32_t aSessionIdSize) override; |
42 | | void OnResolvePromise(uint32_t aPromiseId) override; |
43 | | void OnRejectPromise(uint32_t aPromiseId, |
44 | | cdm::Exception aException, |
45 | | uint32_t aSystemCode, |
46 | | const char* aErrorMessage, |
47 | | uint32_t aErrorMessageSize) override; |
48 | | void OnSessionMessage(const char* aSessionId, |
49 | | uint32_t aSessionIdSize, |
50 | | cdm::MessageType aMessageType, |
51 | | const char* aMessage, |
52 | | uint32_t aMessageSize) override; |
53 | | void OnSessionKeysChange(const char* aSessionId, |
54 | | uint32_t aSessionIdSize, |
55 | | bool aHasAdditionalUsableKey, |
56 | | const cdm::KeyInformation* aKeysInfo, |
57 | | uint32_t aKeysInfoCount) override; |
58 | | void OnExpirationChange(const char* aSessionId, |
59 | | uint32_t aSessionIdSize, |
60 | | cdm::Time aNewExpiryTime) override; |
61 | | void OnSessionClosed(const char* aSessionId, |
62 | | uint32_t aSessionIdSize) override; |
63 | | void SendPlatformChallenge(const char* aServiceId, |
64 | | uint32_t aServiceIdSize, |
65 | | const char* aChallenge, |
66 | 0 | uint32_t aChallengeSize) override {} |
67 | 0 | void EnableOutputProtection(uint32_t aDesiredProtectionMask) override {} |
68 | 0 | void QueryOutputProtectionStatus() override {} |
69 | | void OnDeferredInitializationDone(cdm::StreamType aStreamType, |
70 | 0 | cdm::Status aDecoderStatus) override {} |
71 | | void RequestStorageId(uint32_t aVersion) override; |
72 | | cdm::FileIO* CreateFileIO(cdm::FileIOClient* aClient) override; |
73 | | // End shared cdm::Host_9 and cdm::Host10 implementation |
74 | | // cdm::Host_10 specific |
75 | 0 | void OnInitialized(bool success) override {} |
76 | | // end cdm::Host_10 specific |
77 | | |
78 | | void GiveBuffer(ipc::Shmem&& aBuffer); |
79 | | |
80 | | protected: |
81 | | ~ChromiumCDMChild(); |
82 | | |
83 | | bool OnResolveNewSessionPromiseInternal(uint32_t aPromiseId, |
84 | | const nsCString& aSessionId); |
85 | | |
86 | | bool IsOnMessageLoopThread(); |
87 | | |
88 | | ipc::IPCResult RecvGiveBuffer(ipc::Shmem&& aShmem) override; |
89 | | ipc::IPCResult RecvPurgeShmems() override; |
90 | | void PurgeShmems(); |
91 | | ipc::IPCResult RecvInit(const bool& aAllowDistinctiveIdentifier, |
92 | | const bool& aAllowPersistentState) override; |
93 | | ipc::IPCResult RecvSetServerCertificate( |
94 | | const uint32_t& aPromiseId, |
95 | | nsTArray<uint8_t>&& aServerCert) override; |
96 | | ipc::IPCResult RecvCreateSessionAndGenerateRequest( |
97 | | const uint32_t& aPromiseId, |
98 | | const uint32_t& aSessionType, |
99 | | const uint32_t& aInitDataType, |
100 | | nsTArray<uint8_t>&& aInitData) override; |
101 | | ipc::IPCResult RecvLoadSession(const uint32_t& aPromiseId, |
102 | | const uint32_t& aSessionType, |
103 | | const nsCString& aSessionId) override; |
104 | | ipc::IPCResult RecvUpdateSession(const uint32_t& aPromiseId, |
105 | | const nsCString& aSessionId, |
106 | | nsTArray<uint8_t>&& aResponse) override; |
107 | | ipc::IPCResult RecvCloseSession(const uint32_t& aPromiseId, |
108 | | const nsCString& aSessionId) override; |
109 | | ipc::IPCResult RecvRemoveSession(const uint32_t& aPromiseId, |
110 | | const nsCString& aSessionId) override; |
111 | | ipc::IPCResult RecvGetStatusForPolicy(const uint32_t& aPromiseId, |
112 | | const nsCString& aMinHdcpVersion) override; |
113 | | ipc::IPCResult RecvDecrypt(const uint32_t& aId, |
114 | | const CDMInputBuffer& aBuffer) override; |
115 | | ipc::IPCResult RecvInitializeVideoDecoder( |
116 | | const CDMVideoDecoderConfig& aConfig) override; |
117 | | ipc::IPCResult RecvDeinitializeVideoDecoder() override; |
118 | | ipc::IPCResult RecvResetVideoDecoder() override; |
119 | | ipc::IPCResult RecvDecryptAndDecodeFrame( |
120 | | const CDMInputBuffer& aBuffer) override; |
121 | | ipc::IPCResult RecvDrain() override; |
122 | | ipc::IPCResult RecvDestroy() override; |
123 | | |
124 | | void ReturnOutput(WidevineVideoFrame& aFrame); |
125 | | bool HasShmemOfSize(size_t aSize) const; |
126 | | |
127 | | template <typename MethodType, typename... ParamType> |
128 | | void CallMethod(MethodType, ParamType&&...); |
129 | | |
130 | | template<typename MethodType, typename... ParamType> |
131 | | void CallOnMessageLoopThread(const char* const, MethodType, ParamType&&...); |
132 | | |
133 | | GMPContentChild* mPlugin = nullptr; |
134 | | cdm::ContentDecryptionModule_10* mCDM = nullptr; |
135 | | |
136 | | typedef SimpleMap<uint64_t> DurationMap; |
137 | | DurationMap mFrameDurations; |
138 | | nsTArray<uint32_t> mLoadSessionPromiseIds; |
139 | | |
140 | | cdm::Size mCodedSize = { 0, 0 }; |
141 | | nsTArray<ipc::Shmem> mBuffers; |
142 | | |
143 | | bool mDecoderInitialized = false; |
144 | | bool mPersistentStateAllowed = false; |
145 | | bool mDestroyed = false; |
146 | | nsCString mStorageId; |
147 | | }; |
148 | | |
149 | | } // namespace gmp |
150 | | } // namespace mozilla |
151 | | |
152 | | #endif // ChromiumCDMChild_h_ |