Bug 1795082 - Part 2/2: Drop post-processing from getURL() r=zombie
[gecko.git] / media / wmf-clearkey / WMFClearKeyInputTrustAuthority.cpp
blob3943c03e4d2e6d91c2c1387d212eccdd5836c117
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/. */
5 #include "WMFClearKeyInputTrustAuthority.h"
7 #include <mfapi.h>
8 #include <mferror.h>
10 #include "WMFClearKeyActivate.h"
11 #include "WMFClearKeyCDM.h"
12 // #include "WMFClearKeyDecryptor.h"
13 #include "WMFClearKeyUtils.h"
14 #include "WMFClearKeyOutputPolicy.h"
16 namespace mozilla {
18 using Microsoft::WRL::ComPtr;
19 using Microsoft::WRL::MakeAndInitialize;
21 HRESULT WMFClearKeyInputTrustAuthority::RuntimeClassInitialize(
22 UINT32 aStreamId, SessionManagerWrapper* aSessionManager) {
23 ENTRY_LOG();
24 mSessionManager = aSessionManager;
25 return S_OK;
28 STDMETHODIMP WMFClearKeyInputTrustAuthority::GetDecrypter(REFIID aRiid,
29 void** aPpv) {
30 ENTRY_LOG();
31 ComPtr<IMFTransform> decryptor;
32 // TODO : As currently we are still not able to make decryption working in the
33 // media foundation pipeline, we will finish the implementation for
34 // WMFClearKeyDecryptor later.
35 // RETURN_IF_FAILED((MakeAndInitialize<WMFClearKeyDecryptor, IMFTransform>(
36 // &decryptor, mSessionManager)));
37 RETURN_IF_FAILED(decryptor.CopyTo(aRiid, aPpv));
38 return S_OK;
41 STDMETHODIMP WMFClearKeyInputTrustAuthority::RequestAccess(
42 MFPOLICYMANAGER_ACTION aAction, IMFActivate** aContentEnablerActivate) {
43 ENTRY_LOG_ARGS("aAction=%d", aAction);
44 // The ITA only allows the PLAY, EXTRACT and NO actions
45 // NOTE: Topology created only on the basis of EXTRACT or NO action will NOT
46 // decrypt content.
47 if (PEACTION_EXTRACT == aAction || PEACTION_NO == aAction) {
48 return S_OK;
50 if (PEACTION_PLAY != aAction) {
51 ENTRY_LOG_ARGS("Unsupported action");
52 return MF_E_ITA_UNSUPPORTED_ACTION;
54 ComPtr<IMFActivate> activate;
55 RETURN_IF_FAILED(MakeAndInitialize<WMFClearKeyActivate>(&activate));
56 *aContentEnablerActivate = activate.Detach();
57 return S_OK;
60 STDMETHODIMP WMFClearKeyInputTrustAuthority::GetPolicy(
61 MFPOLICYMANAGER_ACTION aAction, IMFOutputPolicy** aPolicy) {
62 ENTRY_LOG();
63 // For testing purpose, we don't need to set the output policy/
64 *aPolicy = nullptr;
65 return S_OK;
68 STDMETHODIMP WMFClearKeyInputTrustAuthority::BindAccess(
69 MFINPUTTRUSTAUTHORITY_ACCESS_PARAMS* aParams) {
70 ENTRY_LOG();
71 if (aParams == nullptr || aParams->dwVer != 0) {
72 return E_INVALIDARG;
74 for (DWORD i = 0; i < aParams->cActions; ++i) {
75 MFPOLICYMANAGER_ACTION action = aParams->rgOutputActions[i].Action;
76 if (action != PEACTION_PLAY && action != PEACTION_EXTRACT &&
77 action != PEACTION_NO) {
78 ENTRY_LOG_ARGS("Unexpected action!");
79 return MF_E_UNEXPECTED;
82 return S_OK;
85 STDMETHODIMP WMFClearKeyInputTrustAuthority::UpdateAccess(
86 MFINPUTTRUSTAUTHORITY_ACCESS_PARAMS* aParams) {
87 ENTRY_LOG();
88 return BindAccess(aParams);
91 STDMETHODIMP WMFClearKeyInputTrustAuthority::Reset() {
92 NOT_IMPLEMENTED();
93 return E_NOTIMPL;
96 STDMETHODIMP WMFClearKeyInputTrustAuthority::GetShutdownStatus(
97 MFSHUTDOWN_STATUS* aStatus) {
98 ENTRY_LOG();
99 // https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imfshutdown-getshutdownstatus#return-value
100 if (mSessionManager->IsShutdown()) {
101 return MF_E_INVALIDREQUEST;
103 return S_OK;
106 STDMETHODIMP WMFClearKeyInputTrustAuthority::Shutdown() {
107 ENTRY_LOG();
108 if (mSessionManager->IsShutdown()) {
109 return MF_E_SHUTDOWN;
111 mSessionManager->Shutdown();
112 return S_OK;
115 } // namespace mozilla