tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WMFClearKeySession.h (2860B)


      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/. */
      4 
      5 #ifndef DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
      6 #define DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H
      7 
      8 #include <mfidl.h>
      9 #include <windows.h>
     10 #include <wrl.h>
     11 
     12 #include "content_decryption_module.h"
     13 #include "MFCDMExtra.h"
     14 #include "RefCounted.h"
     15 #include "WMFClearKeyUtils.h"
     16 
     17 namespace mozilla {
     18 
     19 class SessionManagerWrapper;
     20 
     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> {
     28 public:
     29  WMFClearKeySession() = default;
     30  ~WMFClearKeySession();
     31  WMFClearKeySession(const WMFClearKeySession&) = delete;
     32  WMFClearKeySession& operator=(const WMFClearKeySession&) = delete;
     33 
     34  HRESULT RuntimeClassInitialize(
     35      MF_MEDIAKEYSESSION_TYPE aSessionType,
     36      IMFContentDecryptionModuleSessionCallbacks* aCallbacks,
     37      SessionManagerWrapper* aManager);
     38 
     39  void Shutdown();
     40 
     41  // IMFContentDecryptionModuleSession
     42  STDMETHODIMP GenerateRequest(LPCWSTR init_data_type,
     43 
     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;
     54 
     55  void OnKeyMessage(MF_MEDIAKEYSESSION_MESSAGETYPE aMessageType,
     56                    const BYTE* aMessage, DWORD aMessageSize);
     57  void OnKeyStatusChanged(const cdm::KeyInformation* aKeysInfo,
     58                          uint32_t aKeysInfoCount);
     59 
     60 private:
     61  cdm::SessionType mSessionType;
     62  std::string mSessionId;
     63  Microsoft::WRL::ComPtr<IMFContentDecryptionModuleSessionCallbacks> mCallbacks;
     64  RefPtr<SessionManagerWrapper> mSessionManager;
     65 
     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;
     72  };
     73  std::vector<KeyInformation> mKeyInfo;
     74 };
     75 
     76 }  // namespace mozilla
     77 
     78 #endif  // DOM_MEDIA_PLATFORM_WMF_CLEARKEY_WMFCLEARKEYSESSION_H