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

media / cdm / win / test / mock_media_protection_pmp_server.h [blame]

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_CDM_WIN_TEST_MOCK_MEDIA_PROTECTION_PMP_SERVER_H_
#define MEDIA_CDM_WIN_TEST_MOCK_MEDIA_PROTECTION_PMP_SERVER_H_

#include <mfidl.h>
#include <windows.media.protection.h>
#include <wrl/implements.h>

namespace media {

// Mock PMP server can be used under the situation where creating a real
// in-process PMP is not allowed or desired. PMP (Protected Media Path):
// https://learn.microsoft.com/en-us/windows/win32/medfound/protected-media-path
class MockMediaProtectionPMPServer final
    : public Microsoft::WRL::RuntimeClass<
          Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
          ABI::Windows::Media::Protection::IMediaProtectionPMPServer,
          IMFGetService,
          Microsoft::WRL::FtmBase> {
 public:
  MockMediaProtectionPMPServer();
  ~MockMediaProtectionPMPServer() override;
  MockMediaProtectionPMPServer(const MockMediaProtectionPMPServer&) = delete;
  MockMediaProtectionPMPServer& operator=(const MockMediaProtectionPMPServer&) =
      delete;

  HRESULT RuntimeClassInitialize(
      ABI::Windows::Foundation::Collections::IPropertySet* property_pmp);

  // IInspectable
  STDMETHODIMP GetIids(_COM_Outptr_ ULONG* iidCount,
                       _COM_Outptr_ IID** iids) override;
  STDMETHODIMP GetRuntimeClassName(_COM_Outptr_ HSTRING* className) override;
  STDMETHODIMP GetTrustLevel(_COM_Outptr_ TrustLevel* trustLevel) override;

  // IMediaProtectionPMPServer
  STDMETHODIMP get_Properties(
      _COM_Outptr_ ABI::Windows::Foundation::Collections::IPropertySet**
          ppProperties) override;

  // IMFGetService
  STDMETHODIMP GetService(__RPC__in REFGUID guid_service,
                          __RPC__in REFIID riid,
                          __RPC__deref_out_opt LPVOID* ppv_object) override;

 private:
  Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IPropertySet>
      property_pmp_;
  Microsoft::WRL::ComPtr<IMFPMPServer> pmp_server_;
  Microsoft::WRL::ComPtr<IMFPMPHost> pmp_host_;
  Microsoft::WRL::ComPtr<IMFMediaSession> media_session_;
};

}  // namespace media

#endif  // MEDIA_CDM_WIN_TEST_MOCK_MEDIA_PROTECTION_PMP_SERVER_H_