Zebediah Figura : winegstreamer: Implement IWMSyncReader::GetOutputProps().

Alexandre Julliard julliard at winehq.org
Thu Oct 28 16:07:45 CDT 2021


Module: wine
Branch: master
Commit: 0dc309ef6ac54484d92f6558d6ca2f8e50eb28e2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0dc309ef6ac54484d92f6558d6ca2f8e50eb28e2

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Thu Oct 28 11:45:57 2021 -0500

winegstreamer: Implement IWMSyncReader::GetOutputProps().

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winegstreamer/gst_private.h   |   2 +
 dlls/winegstreamer/wm_reader.c     | 133 +++++++++++++++++++++++++++++++++++++
 dlls/winegstreamer/wm_syncreader.c |  11 +--
 dlls/wmvcore/tests/wmvcore.c       |  51 +++++++-------
 4 files changed, 165 insertions(+), 32 deletions(-)

diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index 7d5828a15d6..db715a9ad70 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -153,6 +153,8 @@ struct wm_reader_ops
 
 void wm_reader_cleanup(struct wm_reader *reader);
 HRESULT wm_reader_close(struct wm_reader *reader);
+HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output,
+        IWMOutputMediaProps **props);
 void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops);
 HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream);
 
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c
index feb000c96ed..2a93e6e1d35 100644
--- a/dlls/winegstreamer/wm_reader.c
+++ b/dlls/winegstreamer/wm_reader.c
@@ -20,6 +20,122 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(wmvcore);
 
+static struct wm_stream *get_stream_by_output_number(struct wm_reader *reader, DWORD output)
+{
+    if (output < reader->stream_count)
+        return &reader->streams[output];
+    WARN("Invalid output number %u.\n", output);
+    return NULL;
+}
+
+struct output_props
+{
+    IWMOutputMediaProps IWMOutputMediaProps_iface;
+    LONG refcount;
+};
+
+static inline struct output_props *impl_from_IWMOutputMediaProps(IWMOutputMediaProps *iface)
+{
+    return CONTAINING_RECORD(iface, struct output_props, IWMOutputMediaProps_iface);
+}
+
+static HRESULT WINAPI output_props_QueryInterface(IWMOutputMediaProps *iface, REFIID iid, void **out)
+{
+    struct output_props *props = impl_from_IWMOutputMediaProps(iface);
+
+    TRACE("props %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
+
+    if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IWMOutputMediaProps))
+        *out = &props->IWMOutputMediaProps_iface;
+    else
+    {
+        *out = NULL;
+        WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
+        return E_NOINTERFACE;
+    }
+
+    IUnknown_AddRef((IUnknown *)*out);
+    return S_OK;
+}
+
+static ULONG WINAPI output_props_AddRef(IWMOutputMediaProps *iface)
+{
+    struct output_props *props = impl_from_IWMOutputMediaProps(iface);
+    ULONG refcount = InterlockedIncrement(&props->refcount);
+
+    TRACE("%p increasing refcount to %u.\n", props, refcount);
+
+    return refcount;
+}
+
+static ULONG WINAPI output_props_Release(IWMOutputMediaProps *iface)
+{
+    struct output_props *props = impl_from_IWMOutputMediaProps(iface);
+    ULONG refcount = InterlockedDecrement(&props->refcount);
+
+    TRACE("%p decreasing refcount to %u.\n", props, refcount);
+
+    if (!refcount)
+        free(props);
+
+    return refcount;
+}
+
+static HRESULT WINAPI output_props_GetType(IWMOutputMediaProps *iface, GUID *major_type)
+{
+    FIXME("iface %p, major_type %p, stub!\n", iface, major_type);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI output_props_GetMediaType(IWMOutputMediaProps *iface, WM_MEDIA_TYPE *mt, DWORD *size)
+{
+    FIXME("iface %p, mt %p, size %p, stub!\n", iface, mt, size);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI output_props_SetMediaType(IWMOutputMediaProps *iface, WM_MEDIA_TYPE *mt)
+{
+    FIXME("iface %p, mt %p, stub!\n", iface, mt);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI output_props_GetStreamGroupName(IWMOutputMediaProps *iface, WCHAR *name, WORD *len)
+{
+    FIXME("iface %p, name %p, len %p, stub!\n", iface, name, len);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI output_props_GetConnectionName(IWMOutputMediaProps *iface, WCHAR *name, WORD *len)
+{
+    FIXME("iface %p, name %p, len %p, stub!\n", iface, name, len);
+    return E_NOTIMPL;
+}
+
+static const struct IWMOutputMediaPropsVtbl output_props_vtbl =
+{
+    output_props_QueryInterface,
+    output_props_AddRef,
+    output_props_Release,
+    output_props_GetType,
+    output_props_GetMediaType,
+    output_props_SetMediaType,
+    output_props_GetStreamGroupName,
+    output_props_GetConnectionName,
+};
+
+static IWMOutputMediaProps *output_props_create(void)
+{
+    struct output_props *object;
+
+    if (!(object = calloc(1, sizeof(*object))))
+        return NULL;
+    object->IWMOutputMediaProps_iface.lpVtbl = &output_props_vtbl;
+    object->refcount = 1;
+
+    TRACE("Created output properties %p.\n", object);
+    return &object->IWMOutputMediaProps_iface;
+}
+
 struct stream_config
 {
     IWMStreamConfig IWMStreamConfig_iface;
@@ -1116,6 +1232,23 @@ HRESULT wm_reader_close(struct wm_reader *reader)
     return S_OK;
 }
 
+HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output, IWMOutputMediaProps **props)
+{
+    struct wm_stream *stream;
+
+    EnterCriticalSection(&reader->cs);
+
+    if (!(stream = get_stream_by_output_number(reader, output)))
+    {
+        LeaveCriticalSection(&reader->cs);
+        return E_INVALIDARG;
+    }
+
+    *props = output_props_create();
+    LeaveCriticalSection(&reader->cs);
+    return *props ? S_OK : E_OUTOFMEMORY;
+}
+
 void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops)
 {
     reader->IWMHeaderInfo3_iface.lpVtbl = &header_info_vtbl;
diff --git a/dlls/winegstreamer/wm_syncreader.c b/dlls/winegstreamer/wm_syncreader.c
index cb2e61a25bc..c89fb782a11 100644
--- a/dlls/winegstreamer/wm_syncreader.c
+++ b/dlls/winegstreamer/wm_syncreader.c
@@ -123,11 +123,14 @@ static HRESULT WINAPI WMSyncReader_GetOutputNumberForStream(IWMSyncReader2 *ifac
     return S_OK;
 }
 
-static HRESULT WINAPI WMSyncReader_GetOutputProps(IWMSyncReader2 *iface, DWORD output_num, IWMOutputMediaProps **output)
+static HRESULT WINAPI WMSyncReader_GetOutputProps(IWMSyncReader2 *iface,
+        DWORD output, IWMOutputMediaProps **props)
 {
-    struct sync_reader *This = impl_from_IWMSyncReader2(iface);
-    FIXME("(%p)->(%u %p): stub!\n", This, output_num, output);
-    return E_NOTIMPL;
+    struct sync_reader *reader = impl_from_IWMSyncReader2(iface);
+
+    TRACE("reader %p, output %u, props %p.\n", reader, output, props);
+
+    return wm_reader_get_output_props(&reader->reader, output, props);
 }
 
 static HRESULT WINAPI WMSyncReader_GetOutputSetting(IWMSyncReader2 *iface, DWORD output_num, const WCHAR *name,
diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c
index 031a1841360..22184c98dc5 100644
--- a/dlls/wmvcore/tests/wmvcore.c
+++ b/dlls/wmvcore/tests/wmvcore.c
@@ -724,30 +724,28 @@ static void test_sync_reader_types(void)
         ok(stream_number2 == stream_number, "Expected stream number %u, got %u.\n", stream_number, stream_number2);
 
         hr = IWMSyncReader_GetOutputProps(reader, output_number, &output_props);
-        todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
-        if (hr != S_OK)
-        {
-            winetest_pop_context();
-            continue;
-        }
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
 
         ret_size = sizeof(mt_buffer);
         hr = IWMOutputMediaProps_GetMediaType(output_props, mt, &ret_size);
-        ok(hr == S_OK, "Got hr %#x.\n", hr);
+        todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
 
         ref = IWMOutputMediaProps_Release(output_props);
         ok(!ref, "Got outstanding refcount %d.\n", ref);
 
-        if (IsEqualGUID(&majortype, &MEDIATYPE_Audio))
-        {
-            got_audio = true;
-            check_audio_type(mt);
-        }
-        else
+        if (hr == S_OK)
         {
-            ok(IsEqualGUID(&majortype, &MEDIATYPE_Video), "Got major type %s.\n", debugstr_guid(&majortype));
-            got_video = true;
-            check_video_type(mt);
+            if (IsEqualGUID(&majortype, &MEDIATYPE_Audio))
+            {
+                got_audio = true;
+                check_audio_type(mt);
+            }
+            else
+            {
+                ok(IsEqualGUID(&majortype, &MEDIATYPE_Video), "Got major type %s.\n", debugstr_guid(&majortype));
+                got_video = true;
+                check_video_type(mt);
+            }
         }
 
         count = 0;
@@ -832,19 +830,16 @@ static void test_sync_reader_types(void)
         todo_wine ok(hr == NS_E_INVALID_OUTPUT_FORMAT, "Got hr %#x.\n", hr);
 
         hr = IWMSyncReader_GetOutputProps(reader, output_number, &output_props);
-        todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
 
-        if (hr == S_OK)
-        {
-            hr = IWMSyncReader_GetOutputProps(reader, output_number, &output_props2);
-            ok(hr == S_OK, "Got hr %#x.\n", hr);
-            ok(output_props2 != output_props, "Expected different objects.\n");
+        hr = IWMSyncReader_GetOutputProps(reader, output_number, &output_props2);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
+        ok(output_props2 != output_props, "Expected different objects.\n");
 
-            ref = IWMOutputMediaProps_Release(output_props2);
-            ok(!ref, "Got outstanding refcount %d.\n", ref);
-            ref = IWMOutputMediaProps_Release(output_props);
-            ok(!ref, "Got outstanding refcount %d.\n", ref);
-        }
+        ref = IWMOutputMediaProps_Release(output_props2);
+        ok(!ref, "Got outstanding refcount %d.\n", ref);
+        ref = IWMOutputMediaProps_Release(output_props);
+        ok(!ref, "Got outstanding refcount %d.\n", ref);
 
         winetest_pop_context();
     }
@@ -859,7 +854,7 @@ static void test_sync_reader_types(void)
 
     output_props = (void *)0xdeadbeef;
     hr = IWMSyncReader_GetOutputProps(reader, 2, &output_props);
-    todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
     ok(output_props == (void *)0xdeadbeef, "Got output props %p.\n", output_props);
 
     output_props = (void *)0xdeadbeef;




More information about the wine-cvs mailing list