Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/main.c | 19 +++++++++++++++++++ dlls/mf/mf.spec | 2 +- dlls/mf/tests/mf.c | 39 +++++++++++++++++++++++++++++++++++++++ include/mfidl.idl | 1 + 4 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/main.c b/dlls/mf/main.c index bf7066ad032..b59ad466c73 100644 --- a/dlls/mf/main.c +++ b/dlls/mf/main.c @@ -1460,3 +1460,22 @@ HRESULT WINAPI MFCreateSimpleTypeHandler(IMFMediaTypeHandler **handler)
return S_OK; } + +HRESULT WINAPI MFRequireProtectedEnvironment(IMFPresentationDescriptor *pd) +{ + BOOL selected, protected = FALSE; + unsigned int i = 0, value; + IMFStreamDescriptor *sd; + + TRACE("%p.\n", pd); + + while (SUCCEEDED(IMFPresentationDescriptor_GetStreamDescriptorByIndex(pd, i++, &selected, &sd))) + { + value = 0; + protected = SUCCEEDED(IMFStreamDescriptor_GetUINT32(sd, &MF_SD_PROTECTED, &value)) && value; + IMFStreamDescriptor_Release(sd); + if (protected) break; + } + + return protected ? S_OK : S_FALSE; +} diff --git a/dlls/mf/mf.spec b/dlls/mf/mf.spec index 2927d9f8a88..8f340243fc2 100644 --- a/dlls/mf/mf.spec +++ b/dlls/mf/mf.spec @@ -77,7 +77,7 @@ @ stdcall MFGetSupportedSchemes(ptr) @ stdcall MFGetTopoNodeCurrentType(ptr long long ptr) @ stub MFReadSequencerSegmentOffset -@ stub MFRequireProtectedEnvironment +@ stdcall MFRequireProtectedEnvironment(ptr) @ stdcall MFShutdownObject(ptr) @ stub MFTranscodeGetAudioOutputAvailableTypes @ stub MergePropertyStore diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 40d8561bb06..df286db6385 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5185,6 +5185,44 @@ static void init_functions(void) #undef X }
+static void test_MFRequireProtectedEnvironment(void) +{ + IMFPresentationDescriptor *pd; + IMFMediaType *mediatype; + IMFStreamDescriptor *sd; + HRESULT hr; + + hr = MFCreateMediaType(&mediatype); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFCreateStreamDescriptor(0, 1, &mediatype, &sd); + ok(hr == S_OK, "Failed to create stream descriptor, hr %#x.\n", hr); + + hr = MFCreatePresentationDescriptor(1, &sd, &pd); + ok(hr == S_OK, "Failed to create presentation descriptor, hr %#x.\n", hr); + + hr = IMFPresentationDescriptor_SelectStream(pd, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFRequireProtectedEnvironment(pd); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IMFStreamDescriptor_SetUINT32(sd, &MF_SD_PROTECTED, 1); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFRequireProtectedEnvironment(pd); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFPresentationDescriptor_DeselectStream(pd, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = MFRequireProtectedEnvironment(pd); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + IMFStreamDescriptor_Release(sd); + IMFPresentationDescriptor_Release(pd); +} + START_TEST(mf) { init_functions(); @@ -5216,4 +5254,5 @@ START_TEST(mf) test_sample_copier(); test_sample_copier_output_processing(); test_MFGetTopoNodeCurrentType(); + test_MFRequireProtectedEnvironment(); } diff --git a/include/mfidl.idl b/include/mfidl.idl index 46c715a3752..138b899ffdb 100644 --- a/include/mfidl.idl +++ b/include/mfidl.idl @@ -698,6 +698,7 @@ cpp_quote("MFTIME WINAPI MFGetSystemTime(void);") cpp_quote("HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOOL output, IMFMediaType **type);") cpp_quote("HRESULT WINAPI MFShutdownObject(IUnknown *object);") cpp_quote("HRESULT WINAPI MFCreateTrackedSample(IMFTrackedSample **sample);") +cpp_quote("HRESULT WINAPI MFRequireProtectedEnvironment(IMFPresentationDescriptor *pd);")
typedef enum _MFMEDIASOURCE_CHARACTERISTICS {