1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/* 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/. */
#ifndef DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
#define DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
#include <mfidl.h>
#include <windows.h>
#include <wrl.h>
#include "content_decryption_module.h"
#include "MFCDMExtra.h"
#include "RefCounted.h"
#include "WMFClearKeyUtils.h"
namespace mozilla {
class SessionManagerWrapper;
// This is the implementation for EME API's MediaKeySession.
// TODO : add a way to assert thread usage. It would only be used on the media
// supervisor thread pool.
class WMFClearKeySession final
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IMFContentDecryptionModuleSession, Microsoft::WRL::FtmBase> {
public:
WMFClearKeySession() = default;
~WMFClearKeySession();
WMFClearKeySession(const WMFClearKeySession&) = delete;
WMFClearKeySession& operator=(const WMFClearKeySession&) = delete;
HRESULT RuntimeClassInitialize(
MF_MEDIAKEYSESSION_TYPE aSessionType,
IMFContentDecryptionModuleSessionCallbacks* aCallbacks,
SessionManagerWrapper* aManager);
void Shutdown();
// IMFContentDecryptionModuleSession
STDMETHODIMP GenerateRequest(LPCWSTR init_data_type,
const BYTE* init_data,
DWORD init_data_size) override;
STDMETHODIMP Load(LPCWSTR session_id, BOOL* loaded) override;
STDMETHODIMP Update(const BYTE* aResponse, DWORD aResponseSize) override;
STDMETHODIMP Close() override;
STDMETHODIMP Remove() override;
STDMETHODIMP GetSessionId(LPWSTR* aSessionId) override;
STDMETHODIMP GetExpiration(double* aExpiration) override;
STDMETHODIMP GetKeyStatuses(MFMediaKeyStatus** aKeyStatuses,
UINT* aKeyStatusesCount) override;
void OnKeyMessage(MF_MEDIAKEYSESSION_MESSAGETYPE aMessageType,
const BYTE* aMessage, DWORD aMessageSize);
void OnKeyStatusChanged(const cdm::KeyInformation* aKeysInfo,
uint32_t aKeysInfoCount);
private:
cdm::SessionType mSessionType;
std::string mSessionId;
Microsoft::WRL::ComPtr<IMFContentDecryptionModuleSessionCallbacks> mCallbacks;
RefPtr<SessionManagerWrapper> mSessionManager;
struct KeyInformation {
KeyInformation(const uint8_t* aKeyId, uint32_t aKeyIdSize,
cdm::KeyStatus aKeyStatus)
: mKeyId(aKeyId, aKeyId + aKeyIdSize), mKeyStatus(aKeyStatus) {}
std::vector<uint8_t> mKeyId;
cdm::KeyStatus mKeyStatus;
};
std::vector<KeyInformation> mKeyInfo;
};
} // namespace mozilla
#endif // DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
|