From b8e003c0e0d9904e1279cafbaa034ad5899006e2 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 12 Oct 2020 14:17:28 +0300 Subject: [PATCH] evr/mixer: Implement SetOutputType(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/evr/mixer.c | 38 ++++++++++++++++++++++++++++++++++++-- dlls/evr/tests/evr.c | 11 +++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/dlls/evr/mixer.c b/dlls/evr/mixer.c index bb76fd88946..7cb35983f7b 100644 --- a/dlls/evr/mixer.c +++ b/dlls/evr/mixer.c @@ -738,9 +738,43 @@ static HRESULT WINAPI video_mixer_transform_SetInputType(IMFTransform *iface, DW static HRESULT WINAPI video_mixer_transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) { - FIXME("%p, %u, %p, %#x.\n", iface, id, type, flags); + const unsigned int equality_flags = MF_MEDIATYPE_EQUAL_MAJOR_TYPES | + MF_MEDIATYPE_EQUAL_FORMAT_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_DATA; + struct video_mixer *mixer = impl_from_IMFTransform(iface); + HRESULT hr = MF_E_INVALIDMEDIATYPE; + unsigned int i, compare_flags; - return E_NOTIMPL; + TRACE("%p, %u, %p, %#x.\n", iface, id, type, flags); + + if (id) + return MF_E_INVALIDSTREAMNUMBER; + + EnterCriticalSection(&mixer->cs); + + for (i = 0; i < mixer->output.type_count; ++i) + { + compare_flags = 0; + if (FAILED(IMFMediaType_IsEqual(type, mixer->output.media_types[i], &compare_flags))) + continue; + + if ((compare_flags & equality_flags) == equality_flags) + { + hr = S_OK; + break; + } + } + + if (SUCCEEDED(hr) && !(flags & MFT_SET_TYPE_TEST_ONLY)) + { + if (mixer->output.media_type) + IMFMediaType_Release(mixer->output.media_type); + mixer->output.media_type = type; + IMFMediaType_AddRef(mixer->output.media_type); + } + + LeaveCriticalSection(&mixer->cs); + + return hr; } static HRESULT WINAPI video_mixer_transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index 13a07c42c5d..58298159880 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -958,10 +958,11 @@ todo_wine hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMFTransform_SetOutputType(transform, 1, media_type, 0); + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr); + hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - IMFMediaType_Release(media_type); hr = IMFVideoProcessor_GetVideoProcessorMode(processor, &guid); todo_wine @@ -973,6 +974,12 @@ todo_wine if (SUCCEEDED(hr)) CoTaskMemFree(guids); + hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(media_type == media_type2, "Unexpected media type instance.\n"); + IMFMediaType_Release(media_type2); + IMFMediaType_Release(media_type); + IMFVideoProcessor_Release(processor); IMFVideoMediaType_Release(video_type);