tor-browser

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

MFCDMProxy.h (2530B)


      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_MFCDMPROXY_H
      6 #define DOM_MEDIA_PLATFORM_WMF_MFCDMPROXY_H
      7 
      8 #include <mfobjects.h>
      9 #include <unknwn.h>
     10 #include <windef.h>
     11 #include <wrl.h>
     12 
     13 #include <map>
     14 
     15 #include "MFCDMExtra.h"
     16 #include "nsISupportsImpl.h"
     17 
     18 namespace mozilla {
     19 
     20 /**
     21 * MFCDMProxy wraps a IMFContentDecryptionModule and provides some high level
     22 * helper methods in order to allow caller to interact with the wrapped CDM.
     23 */
     24 class MFCDMProxy {
     25  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MFCDMProxy);
     26 
     27  MFCDMProxy(IMFContentDecryptionModule* aCDM, uint64_t aCDMParentId);
     28 
     29 public:
     30  // Return a IMediaProtectionPMPServer from the existing CDM.
     31  HRESULT GetPMPServer(REFIID aRiid, LPVOID* aPMPServerOut);
     32 
     33  // Return a IMFInputTrustAuthority for given stream id, the same stream ID
     34  // always maps to the same IMFInputTrustAuthority. In addition,
     35  // `aContentInitData` is optional initialization data as in
     36  // https://www.w3.org/TR/encrypted-media/#initialization-data
     37  HRESULT GetInputTrustAuthority(uint32_t aStreamId,
     38                                 const uint8_t* aContentInitData,
     39                                 uint32_t aContentInitDataSize, REFIID aRiid,
     40                                 IUnknown** aInputTrustAuthorityOut);
     41 
     42  // Set IMFContentEnabler to the existing CDM, `aRequest` should be a inherited
     43  // class of `IMFContentEnabler`.
     44  HRESULT SetContentEnabler(IUnknown* aRequest, IMFAsyncResult* aResult);
     45 
     46  // Notify the CDM on DRM_E_TEE_INVALID_HWDRM_STATE (0x8004cd12), which happens
     47  // in cases like OS Sleep. In this case, the CDM should close all sessions
     48  // because they are in bad state.
     49  void OnHardwareContextReset();
     50 
     51  void Shutdown();
     52 
     53  // TODO : set last key id in order to let CDM use the key IDs information to
     54  // perform some optimization.
     55 
     56 private:
     57  ~MFCDMProxy();
     58 
     59  Microsoft::WRL::ComPtr<IMFContentDecryptionModule> mCDM;
     60 
     61  // The same ITA is always mapping to the same stream Id.
     62  std::map<uint32_t /* stream Id */,
     63           Microsoft::WRL::ComPtr<IMFInputTrustAuthority>>
     64      mInputTrustAuthorities;
     65 
     66  Microsoft::WRL::ComPtr<IMFTrustedInput> mTrustedInput;
     67 
     68  const uint64_t mCDMParentId;
     69 
     70  // TODO : need some events? (Eg. significant playback, error, hardware context
     71  // reset)
     72 };
     73 
     74 }  // namespace mozilla
     75 
     76 #endif  // DOM_MEDIA_PLATFORM_WMF_MFCDMPROXY_H