From 0b9c35edb49364e56b93fe46a98a4b8c4802a0eb Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Tue, 12 Apr 2022 09:32:06 +0300
Subject: [PATCH] evr: Add IAMFilterMiscFlags interface.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 dlls/evr/evr.c       | 42 ++++++++++++++++++++++++++++++++++++++++++
 dlls/evr/tests/evr.c | 21 ++++++++++++++++++++-
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/dlls/evr/evr.c b/dlls/evr/evr.c
index 5e6ca03ea3d..e64151b650c 100644
--- a/dlls/evr/evr.c
+++ b/dlls/evr/evr.c
@@ -34,6 +34,7 @@ struct evr
 {
     struct strmbase_renderer renderer;
     IEVRFilterConfig IEVRFilterConfig_iface;
+    IAMFilterMiscFlags IAMFilterMiscFlags_iface;
 };
 
 static struct evr *impl_from_strmbase_renderer(struct strmbase_renderer *iface)
@@ -47,6 +48,8 @@ static HRESULT evr_query_interface(struct strmbase_renderer *iface, REFIID iid,
 
     if (IsEqualGUID(iid, &IID_IEVRFilterConfig))
         *out = &filter->IEVRFilterConfig_iface;
+    else if (IsEqualGUID(iid, &IID_IAMFilterMiscFlags))
+        *out = &filter->IAMFilterMiscFlags_iface;
     else
         return E_NOINTERFACE;
 
@@ -132,6 +135,44 @@ static const IEVRFilterConfigVtbl filter_config_vtbl =
     filter_config_GetNumberOfStreams,
 };
 
+static struct evr *impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags *iface)
+{
+    return CONTAINING_RECORD(iface, struct evr, IAMFilterMiscFlags_iface);
+}
+
+static HRESULT WINAPI filter_misc_flags_QueryInterface(IAMFilterMiscFlags *iface, REFIID iid, void **out)
+{
+    struct evr *filter = impl_from_IAMFilterMiscFlags(iface);
+    return IUnknown_QueryInterface(filter->renderer.filter.outer_unk, iid, out);
+}
+
+static ULONG WINAPI filter_misc_flags_AddRef(IAMFilterMiscFlags *iface)
+{
+    struct evr *filter = impl_from_IAMFilterMiscFlags(iface);
+    return IUnknown_AddRef(filter->renderer.filter.outer_unk);
+}
+
+static ULONG WINAPI filter_misc_flags_Release(IAMFilterMiscFlags *iface)
+{
+    struct evr *filter = impl_from_IAMFilterMiscFlags(iface);
+    return IUnknown_Release(filter->renderer.filter.outer_unk);
+}
+
+static ULONG WINAPI filter_misc_flags_GetMiscFlags(IAMFilterMiscFlags *iface)
+{
+    TRACE("%p.\n", iface);
+
+    return AM_FILTER_MISC_FLAGS_IS_RENDERER;
+}
+
+static const IAMFilterMiscFlagsVtbl filter_misc_flags_vtbl =
+{
+    filter_misc_flags_QueryInterface,
+    filter_misc_flags_AddRef,
+    filter_misc_flags_Release,
+    filter_misc_flags_GetMiscFlags,
+};
+
 HRESULT evr_filter_create(IUnknown *outer, void **out)
 {
     struct evr *object;
@@ -142,6 +183,7 @@ HRESULT evr_filter_create(IUnknown *outer, void **out)
     strmbase_renderer_init(&object->renderer, outer,
             &CLSID_EnhancedVideoRenderer, L"EVR Input0", &renderer_ops);
     object->IEVRFilterConfig_iface.lpVtbl = &filter_config_vtbl;
+    object->IAMFilterMiscFlags_iface.lpVtbl = &filter_misc_flags_vtbl;
 
     TRACE("Created EVR %p.\n", object);
     *out = &object->renderer.filter.IUnknown_inner;
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index 93e262e52a3..fa9ad2a0b35 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -276,7 +276,7 @@ static void test_interfaces(void)
     IBaseFilter *filter = create_evr();
     ULONG ref;
 
-    todo_wine check_interface(filter, &IID_IAMFilterMiscFlags, TRUE);
+    check_interface(filter, &IID_IAMFilterMiscFlags, TRUE);
     check_interface(filter, &IID_IBaseFilter, TRUE);
     check_interface(filter, &IID_IEVRFilterConfig, TRUE);
     check_interface(filter, &IID_IMediaFilter, TRUE);
@@ -551,6 +551,24 @@ static void test_unconnected_eos(void)
     ok(!ref, "Got outstanding refcount %ld.\n", ref);
 }
 
+static void test_misc_flags(void)
+{
+    IBaseFilter *filter = create_evr();
+    IAMFilterMiscFlags *misc_flags;
+    ULONG ref, flags;
+    HRESULT hr;
+
+    hr = IBaseFilter_QueryInterface(filter, &IID_IAMFilterMiscFlags, (void **)&misc_flags);
+    ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+    flags = IAMFilterMiscFlags_GetMiscFlags(misc_flags);
+    ok(flags == AM_FILTER_MISC_FLAGS_IS_RENDERER, "Unexpected flags %#lx.\n", flags);
+    IAMFilterMiscFlags_Release(misc_flags);
+
+    ref = IBaseFilter_Release(filter);
+    ok(!ref, "Got outstanding refcount %ld.\n", ref);
+}
+
 static IMFMediaType * create_video_type(const GUID *subtype)
 {
     IMFMediaType *video_type;
@@ -3207,6 +3225,7 @@ START_TEST(evr)
     test_find_pin();
     test_pin_info();
     test_unconnected_eos();
+    test_misc_flags();
 
     test_default_mixer();
     test_default_mixer_type_negotiation();