Commit d6e828d5 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Implement IsMediaTypeSupported() for simple type handler.

parent b50c7c79
......@@ -1342,9 +1342,27 @@ static ULONG WINAPI simple_type_handler_Release(IMFMediaTypeHandler *iface)
static HRESULT WINAPI simple_type_handler_IsMediaTypeSupported(IMFMediaTypeHandler *iface, IMFMediaType *in_type,
IMFMediaType **out_type)
{
FIXME("%p, %p, %p.\n", iface, in_type, out_type);
struct simple_type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
DWORD flags = 0;
HRESULT hr;
return E_NOTIMPL;
TRACE("%p, %p, %p.\n", iface, in_type, out_type);
if (out_type)
*out_type = NULL;
EnterCriticalSection(&handler->cs);
if (!handler->media_type)
hr = MF_E_UNEXPECTED;
else
{
if (SUCCEEDED(hr = IMFMediaType_IsEqual(handler->media_type, in_type, &flags)))
hr = (flags & (MF_MEDIATYPE_EQUAL_MAJOR_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_TYPES)) ==
(MF_MEDIATYPE_EQUAL_MAJOR_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_TYPES) ? S_OK : E_FAIL;
}
LeaveCriticalSection(&handler->cs);
return hr;
}
static HRESULT WINAPI simple_type_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
......
......@@ -2656,7 +2656,7 @@ static void test_evr(void)
static void test_MFCreateSimpleTypeHandler(void)
{
IMFMediaType *media_type, *media_type2;
IMFMediaType *media_type, *media_type2, *media_type3;
IMFMediaTypeHandler *handler;
DWORD count;
HRESULT hr;
......@@ -2668,6 +2668,9 @@ static void test_MFCreateSimpleTypeHandler(void)
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, NULL, NULL);
ok(hr == MF_E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
count = 0;
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count);
ok(hr == S_OK, "Failed to get type count, hr %#x.\n", hr);
......@@ -2684,6 +2687,9 @@ static void test_MFCreateSimpleTypeHandler(void)
hr = MFCreateMediaType(&media_type);
ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type, NULL);
ok(hr == MF_E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, media_type);
ok(hr == S_OK, "Failed to set current type, hr %#x.\n", hr);
......@@ -2692,6 +2698,15 @@ static void test_MFCreateSimpleTypeHandler(void)
ok(media_type2 == media_type, "Unexpected type.\n");
IMFMediaType_Release(media_type2);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, NULL, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type, &media_type2);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 1, &media_type2);
ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#x.\n", hr);
......@@ -2700,11 +2715,78 @@ static void test_MFCreateSimpleTypeHandler(void)
ok(media_type == media_type2, "Unexpected pointer.\n");
IMFMediaType_Release(media_type2);
IMFMediaType_Release(media_type);
hr = IMFMediaTypeHandler_GetMajorType(handler, &guid);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMajorType(handler, &guid);
ok(hr == S_OK, "Failed to get major type, hr %#x.\n", hr);
ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type.\n");
hr = MFCreateMediaType(&media_type3);
ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_type3, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
/* Different major types. */
media_type2 = (void *)0xdeadbeef;
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, &media_type2);
ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
hr = IMFMediaType_SetGUID(media_type3, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
media_type2 = (void *)0xdeadbeef;
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, &media_type2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
/* Handler missing subtype. */
hr = IMFMediaType_SetGUID(media_type3, &MF_MT_SUBTYPE, &MFVideoFormat_RGB8);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
media_type2 = (void *)0xdeadbeef;
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, &media_type2);
ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
/* Different subtypes. */
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_RGB24);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
media_type2 = (void *)0xdeadbeef;
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, &media_type2);
ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
/* Same major/subtype. */
hr = IMFMediaType_SetGUID(media_type3, &MF_MT_SUBTYPE, &MFVideoFormat_RGB24);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
media_type2 = (void *)0xdeadbeef;
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, &media_type2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
/* Set one more attribute. */
hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)4 << 32 | 4);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
media_type2 = (void *)0xdeadbeef;
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type3, &media_type2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!media_type2, "Unexpected pointer.\n");
IMFMediaType_Release(media_type3);
IMFMediaType_Release(media_type);
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, NULL);
ok(hr == S_OK, "Failed to set current type, hr %#x.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment