1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_RENDERERS_WIN_MEDIA_FOUNDATION_PROTECTION_MANAGER_H_ 6 #define MEDIA_RENDERERS_WIN_MEDIA_FOUNDATION_PROTECTION_MANAGER_H_ 7 8 #include <mfapi.h> 9 #include <mfidl.h> 10 #include <windows.media.protection.h> 11 #include <wrl.h> 12 13 #include "media/base/win/mf_cdm_proxy.h" 14 15 namespace media { 16 17 // Implements IMFContentProtectionManager 18 // (https://docs.microsoft.com/en-us/windows/win32/api/mfidl/nn-mfidl-imfcontentprotectionmanager) 19 // and ABI::Windows::Media::Protection::IMediaProtectionManager 20 // (https://docs.microsoft.com/en-us/uwp/api/windows.media.protection.mediaprotectionmanager) 21 // required by IMFMediaEngineProtectedContent::SetContentProtectionManager in 22 // https://docs.microsoft.com/en-us/windows/win32/api/mfmediaengine/nf-mfmediaengine-imfmediaengineprotectedcontent-setcontentprotectionmanager. 23 // 24 class MediaFoundationProtectionManager 25 : public Microsoft::WRL::RuntimeClass< 26 Microsoft::WRL::RuntimeClassFlags< 27 Microsoft::WRL::RuntimeClassType::WinRtClassicComMix | 28 Microsoft::WRL::RuntimeClassType::InhibitRoOriginateError>, 29 IMFContentProtectionManager, 30 ABI::Windows::Media::Protection::IMediaProtectionManager> { 31 public: 32 MediaFoundationProtectionManager(); 33 ~MediaFoundationProtectionManager() override; 34 35 HRESULT RuntimeClassInitialize(); 36 HRESULT SetCdmProxy(IMFCdmProxy* cdm_proxy); 37 38 // IMFContentProtectionManager. 39 IFACEMETHODIMP BeginEnableContent(IMFActivate* enabler_activate, 40 IMFTopology* topology, 41 IMFAsyncCallback* callback, 42 IUnknown* state) override; 43 IFACEMETHODIMP EndEnableContent(IMFAsyncResult* async_result) override; 44 45 // IMediaProtectionManager. 46 // MFMediaEngine can query this interface to invoke get_Properties(). 47 IFACEMETHODIMP add_ServiceRequested( 48 ABI::Windows::Media::Protection::IServiceRequestedEventHandler* handler, 49 EventRegistrationToken* cookie) override; 50 IFACEMETHODIMP remove_ServiceRequested( 51 EventRegistrationToken cookie) override; 52 IFACEMETHODIMP add_RebootNeeded( 53 ABI::Windows::Media::Protection::IRebootNeededEventHandler* handler, 54 EventRegistrationToken* cookie) override; 55 IFACEMETHODIMP remove_RebootNeeded(EventRegistrationToken cookie) override; 56 IFACEMETHODIMP add_ComponentLoadFailed( 57 ABI::Windows::Media::Protection::IComponentLoadFailedEventHandler* 58 handler, 59 EventRegistrationToken* cookie) override; 60 IFACEMETHODIMP remove_ComponentLoadFailed( 61 EventRegistrationToken cookie) override; 62 IFACEMETHODIMP get_Properties( 63 ABI::Windows::Foundation::Collections::IPropertySet** value) override; 64 65 protected: 66 Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> 67 property_set_; 68 Microsoft::WRL::ComPtr<IMFCdmProxy> cdm_proxy_; 69 70 HRESULT SetPMPServer( 71 ABI::Windows::Media::Protection::IMediaProtectionPMPServer* pmp_server); 72 }; 73 74 } // namespace media 75 76 #endif // MEDIA_RENDERERS_WIN_MEDIA_FOUNDATION_PROTECTION_MANAGER_H_ 77