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

Alexandre Julliard julliard at winehq.org
Mon Nov 1 16:38:02 CDT 2021


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Sun Oct 31 19:03:32 2021 -0500

winegstreamer: Implement IWMSyncReader::SetOutputProps().

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

---

 dlls/winegstreamer/gst_private.h   |  3 +++
 dlls/winegstreamer/quartz_parser.c |  2 +-
 dlls/winegstreamer/wm_reader.c     | 47 ++++++++++++++++++++++++++++++++++++++
 dlls/winegstreamer/wm_syncreader.c | 10 ++++----
 dlls/wmvcore/tests/wmvcore.c       |  9 +-------
 5 files changed, 58 insertions(+), 13 deletions(-)

diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index 9219a86c094..278fc132ccf 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -102,6 +102,7 @@ HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
 HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
 
 bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format);
+bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format);
 
 BOOL init_gstreamer(void) DECLSPEC_HIDDEN;
 
@@ -160,5 +161,7 @@ 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);
+HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
+        IWMOutputMediaProps *props);
 
 #endif /* __GST_PRIVATE_INCLUDED__ */
diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c
index 0862a75b7ef..4e7e22a64ea 100644
--- a/dlls/winegstreamer/quartz_parser.c
+++ b/dlls/winegstreamer/quartz_parser.c
@@ -540,7 +540,7 @@ static bool amt_to_wg_format_video(const AM_MEDIA_TYPE *mt, struct wg_format *fo
     return false;
 }
 
-static bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format)
+bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format)
 {
     memset(format, 0, sizeof(*format));
 
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c
index 79a89c9a332..21e08b5834f 100644
--- a/dlls/winegstreamer/wm_reader.c
+++ b/dlls/winegstreamer/wm_reader.c
@@ -140,6 +140,14 @@ static const struct IWMOutputMediaPropsVtbl output_props_vtbl =
     output_props_GetConnectionName,
 };
 
+static struct output_props *unsafe_impl_from_IWMOutputMediaProps(IWMOutputMediaProps *iface)
+{
+    if (!iface)
+        return NULL;
+    assert(iface->lpVtbl == &output_props_vtbl);
+    return impl_from_IWMOutputMediaProps(iface);
+}
+
 static IWMOutputMediaProps *output_props_create(const struct wg_format *format)
 {
     struct output_props *object;
@@ -1382,6 +1390,45 @@ HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output,
     return *props ? S_OK : E_OUTOFMEMORY;
 }
 
+HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
+        IWMOutputMediaProps *props_iface)
+{
+    struct output_props *props = unsafe_impl_from_IWMOutputMediaProps(props_iface);
+    struct wg_format format, pref_format;
+    struct wm_stream *stream;
+
+    strmbase_dump_media_type(&props->mt);
+
+    if (!amt_to_wg_format(&props->mt, &format))
+    {
+        ERR("Failed to convert media type to winegstreamer format.\n");
+        return E_FAIL;
+    }
+
+    EnterCriticalSection(&reader->cs);
+
+    if (!(stream = get_stream_by_output_number(reader, output)))
+    {
+        LeaveCriticalSection(&reader->cs);
+        return E_INVALIDARG;
+    }
+
+    wg_parser_stream_get_preferred_format(stream->wg_stream, &pref_format);
+    if (pref_format.major_type != format.major_type)
+    {
+        /* R.U.S.E sets the type of the wrong stream, apparently by accident. */
+        LeaveCriticalSection(&reader->cs);
+        WARN("Major types don't match; returning NS_E_INCOMPATIBLE_FORMAT.\n");
+        return NS_E_INCOMPATIBLE_FORMAT;
+    }
+
+    stream->format = format;
+    wg_parser_stream_enable(stream->wg_stream, &format);
+
+    LeaveCriticalSection(&reader->cs);
+    return S_OK;
+}
+
 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 54c53dee3bd..f9728211661 100644
--- a/dlls/winegstreamer/wm_syncreader.c
+++ b/dlls/winegstreamer/wm_syncreader.c
@@ -186,11 +186,13 @@ static HRESULT WINAPI WMSyncReader_OpenStream(IWMSyncReader2 *iface, IStream *st
     return wm_reader_open_stream(&reader->reader, stream);
 }
 
-static HRESULT WINAPI WMSyncReader_SetOutputProps(IWMSyncReader2 *iface, DWORD output_num, IWMOutputMediaProps *output)
+static HRESULT WINAPI WMSyncReader_SetOutputProps(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_set_output_props(&reader->reader, output, props);
 }
 
 static HRESULT WINAPI WMSyncReader_SetOutputSetting(IWMSyncReader2 *iface, DWORD output_num, const WCHAR *name,
diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c
index ebfdfdf0107..e07e6241a4c 100644
--- a/dlls/wmvcore/tests/wmvcore.c
+++ b/dlls/wmvcore/tests/wmvcore.c
@@ -789,14 +789,7 @@ static void test_sync_reader_types(void)
                 check_video_type(mt);
 
             hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
-            todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
-            if (hr != S_OK)
-            {
-                ref = IWMOutputMediaProps_Release(output_props);
-                ok(!ref, "Got outstanding refcount %d.\n", ref);
-                winetest_pop_context();
-                continue;
-            }
+            ok(hr == S_OK, "Got hr %#x.\n", hr);
             hr = IWMSyncReader_SetOutputProps(reader, 1 - output_number, output_props);
             if (!i)
                 todo_wine ok(hr == ASF_E_BADMEDIATYPE, "Got hr %#x.\n", hr);




More information about the wine-cvs mailing list