[PATCH 12/17] winegstreamer: Implement ::SetOutputType for color conversion transform.

Derek Lesho dlesho at codeweavers.com
Thu Dec 3 15:56:00 CST 2020


Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
---
 dlls/winegstreamer/colorconvert.c | 70 ++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 2 deletions(-)

diff --git a/dlls/winegstreamer/colorconvert.c b/dlls/winegstreamer/colorconvert.c
index b80232e195b..e7e84690738 100644
--- a/dlls/winegstreamer/colorconvert.c
+++ b/dlls/winegstreamer/colorconvert.c
@@ -53,6 +53,7 @@ struct color_converter
     IMFTransform IMFTransform_iface;
     LONG refcount;
     IMFMediaType *input_type;
+    IMFMediaType *output_type;
     CRITICAL_SECTION cs;
 };
 
@@ -343,9 +344,74 @@ static HRESULT WINAPI color_converter_SetInputType(IMFTransform *iface, DWORD id
 
 static HRESULT WINAPI color_converter_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
 {
-    FIXME("%p, %u, %p, %#x.\n", iface, id, type, flags);
+    GstCaps *output_caps;
+    unsigned int i;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    struct color_converter *converter = impl_color_converter_from_IMFTransform(iface);
+
+    TRACE("%p, %u, %p, %#x.\n", iface, id, type, flags);
+
+    if (id != 0)
+        return MF_E_INVALIDSTREAMNUMBER;
+
+    if (type)
+    {
+        GUID major_type, subtype;
+
+        if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major_type)))
+            return MF_E_INVALIDTYPE;
+        if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
+            return MF_E_INVALIDTYPE;
+
+        if (!(IsEqualGUID(&major_type, &MFMediaType_Video)))
+            return MF_E_INVALIDTYPE;
+
+        for (i = 0; i < ARRAY_SIZE(raw_types); i++)
+        {
+            if (IsEqualGUID(&subtype, raw_types[i]))
+                break;
+        }
+
+        if (i == ARRAY_SIZE(raw_types))
+            return MF_E_INVALIDTYPE;
+
+        if (!(output_caps = caps_from_mf_media_type(type)))
+            return MF_E_INVALIDTYPE;
+
+        gst_caps_unref(output_caps);
+    }
+
+    if (flags & MFT_SET_TYPE_TEST_ONLY)
+        return S_OK;
+
+    EnterCriticalSection(&converter->cs);
+
+    hr = S_OK;
+
+    if (type)
+    {
+        if (!converter->output_type)
+            hr = MFCreateMediaType(&converter->output_type);
+
+        if (SUCCEEDED(hr))
+            hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *) converter->output_type);
+
+        if (FAILED(hr))
+        {
+            IMFMediaType_Release(converter->output_type);
+            converter->output_type = NULL;
+        }
+    }
+    else
+    {
+        IMFMediaType_Release(converter->output_type);
+        converter->output_type = NULL;
+    }
+
+    LeaveCriticalSection(&converter->cs);
+
+    return hr;
 }
 
 static HRESULT WINAPI color_converter_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
-- 
2.29.2




More information about the wine-devel mailing list