Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/mediatype.c | 19 ++++++++++++++++++ dlls/mfplat/mfplat.spec | 2 +- dlls/mfplat/tests/mfplat.c | 41 ++++++++++++++++++++++++++++++++++++++ include/mfapi.h | 1 + 4 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 4e6fa80f9c..a2e3a96902 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -1496,3 +1496,22 @@ HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height
return format ? S_OK : E_INVALIDARG; } + +/*********************************************************************** + * MFCompareFullToPartialMediaType (mfplat.@) + */ +BOOL WINAPI MFCompareFullToPartialMediaType(IMFMediaType *full_type, IMFMediaType *partial_type) +{ + BOOL result; + GUID major; + + TRACE("%p, %p.\n", full_type, partial_type); + + if (FAILED(IMFMediaType_GetMajorType(partial_type, &major))) + return FALSE; + + if (FAILED(IMFMediaType_Compare(partial_type, (IMFAttributes *)full_type, MF_ATTRIBUTES_MATCH_OUR_ITEMS, &result))) + return FALSE; + + return result; +} diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index d8ed5f90e5..8b340a2136 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -29,7 +29,7 @@ @ stdcall MFCalculateImageSize(ptr long long ptr) @ stub MFCancelCreateFile @ stdcall MFCancelWorkItem(int64) -@ stub MFCompareFullToPartialMediaType +@ stdcall MFCompareFullToPartialMediaType(ptr ptr) @ stub MFCompareSockaddrAddresses @ stub MFConvertColorInfoFromDXVA @ stub MFConvertColorInfoToDXVA diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index b420513e3f..2f8b1aaa3e 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -2480,6 +2480,46 @@ static void test_MFCalculateImageSize(void) } }
+static void test_MFCompareFullToPartialMediaType(void) +{ + IMFMediaType *full_type, *partial_type; + HRESULT hr; + BOOL ret; + + hr = MFCreateMediaType(&full_type); + ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr); + + hr = MFCreateMediaType(&partial_type); + ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr); + + ret = MFCompareFullToPartialMediaType(full_type, partial_type); + ok(!ret, "Unexpected result %d.\n", ret); + + hr = IMFMediaType_SetGUID(full_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Failed to set major type, hr %#x.\n", hr); + + hr = IMFMediaType_SetGUID(partial_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Failed to set major type, hr %#x.\n", hr); + + ret = MFCompareFullToPartialMediaType(full_type, partial_type); + ok(ret, "Unexpected result %d.\n", ret); + + hr = IMFMediaType_SetGUID(full_type, &MF_MT_SUBTYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Failed to set major type, hr %#x.\n", hr); + + ret = MFCompareFullToPartialMediaType(full_type, partial_type); + ok(ret, "Unexpected result %d.\n", ret); + + hr = IMFMediaType_SetGUID(partial_type, &MF_MT_SUBTYPE, &MFMediaType_Video); + ok(hr == S_OK, "Failed to set major type, hr %#x.\n", hr); + + ret = MFCompareFullToPartialMediaType(full_type, partial_type); + ok(!ret, "Unexpected result %d.\n", ret); + + IMFMediaType_Release(full_type); + IMFMediaType_Release(partial_type); +} + START_TEST(mfplat) { CoInitialize(NULL); @@ -2510,6 +2550,7 @@ START_TEST(mfplat) test_MFInvokeCallback(); test_stream_descriptor(); test_MFCalculateImageSize(); + test_MFCompareFullToPartialMediaType();
CoUninitialize(); } diff --git a/include/mfapi.h b/include/mfapi.h index 1b8eafa9ad..d8738d5ae1 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -188,6 +188,7 @@ HRESULT WINAPI MFAllocateWorkQueue(DWORD *queue); HRESULT WINAPI MFAllocateWorkQueueEx(MFASYNC_WORKQUEUE_TYPE queue_type, DWORD *queue); HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height, UINT32 *size); HRESULT WINAPI MFCancelWorkItem(MFWORKITEM_KEY key); +BOOL WINAPI MFCompareFullToPartialMediaType(IMFMediaType *full_type, IMFMediaType *partial_type); HRESULT WINAPI MFCopyImage(BYTE *dest, LONG deststride, const BYTE *src, LONG srcstride, DWORD width, DWORD lines); HRESULT WINAPI MFCreateAlignedMemoryBuffer(DWORD max_length, DWORD alignment, IMFMediaBuffer **buffer); HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size);