1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
6 #define DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
12 #include "content_decryption_module.h"
13 #include "MFCDMExtra.h"
14 #include "RefCounted.h"
15 #include "WMFClearKeyUtils.h"
19 class SessionManagerWrapper
;
21 // This is the implementation for EME API's MediaKeySession.
22 // TODO : add a way to assert thread usage. It would only be used on the media
23 // supervisor thread pool.
24 class WMFClearKeySession final
25 : public Microsoft::WRL::RuntimeClass
<
26 Microsoft::WRL::RuntimeClassFlags
<Microsoft::WRL::ClassicCom
>,
27 IMFContentDecryptionModuleSession
, Microsoft::WRL::FtmBase
> {
29 WMFClearKeySession() = default;
30 ~WMFClearKeySession();
31 WMFClearKeySession(const WMFClearKeySession
&) = delete;
32 WMFClearKeySession
& operator=(const WMFClearKeySession
&) = delete;
34 HRESULT
RuntimeClassInitialize(
35 MF_MEDIAKEYSESSION_TYPE aSessionType
,
36 IMFContentDecryptionModuleSessionCallbacks
* aCallbacks
,
37 SessionManagerWrapper
* aManager
);
41 // IMFContentDecryptionModuleSession
42 STDMETHODIMP
GenerateRequest(LPCWSTR init_data_type
,
44 const BYTE
* init_data
,
45 DWORD init_data_size
) override
;
46 STDMETHODIMP
Load(LPCWSTR session_id
, BOOL
* loaded
) override
;
47 STDMETHODIMP
Update(const BYTE
* aResponse
, DWORD aResponseSize
) override
;
48 STDMETHODIMP
Close() override
;
49 STDMETHODIMP
Remove() override
;
50 STDMETHODIMP
GetSessionId(LPWSTR
* aSessionId
) override
;
51 STDMETHODIMP
GetExpiration(double* aExpiration
) override
;
52 STDMETHODIMP
GetKeyStatuses(MFMediaKeyStatus
** aKeyStatuses
,
53 UINT
* aKeyStatusesCount
) override
;
55 void OnKeyMessage(MF_MEDIAKEYSESSION_MESSAGETYPE aMessageType
,
56 const BYTE
* aMessage
, DWORD aMessageSize
);
57 void OnKeyStatusChanged(const cdm::KeyInformation
* aKeysInfo
,
58 uint32_t aKeysInfoCount
);
61 cdm::SessionType mSessionType
;
62 std::string mSessionId
;
63 Microsoft::WRL::ComPtr
<IMFContentDecryptionModuleSessionCallbacks
> mCallbacks
;
64 RefPtr
<SessionManagerWrapper
> mSessionManager
;
66 struct KeyInformation
{
67 KeyInformation(const uint8_t* aKeyId
, uint32_t aKeyIdSize
,
68 cdm::KeyStatus aKeyStatus
)
69 : mKeyId(aKeyId
, aKeyId
+ aKeyIdSize
), mKeyStatus(aKeyStatus
) {}
70 std::vector
<uint8_t> mKeyId
;
71 cdm::KeyStatus mKeyStatus
;
73 std::vector
<KeyInformation
> mKeyInfo
;
76 } // namespace mozilla
78 #endif // DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H