Rémi Bernon : qasf: Implement ASF Reader filter pin_get_media_type.

Alexandre Julliard julliard at winehq.org
Tue Aug 9 15:18:51 CDT 2022


Module: wine
Branch: master
Commit: 80004974e9f706ee20ce5034ecb83646bcff2c58
URL:    https://gitlab.winehq.org/wine/wine/-/commit/80004974e9f706ee20ce5034ecb83646bcff2c58

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Mon May 23 13:20:51 2022 +0200

qasf: Implement ASF Reader filter pin_get_media_type.

And name pins accordingly.

---

 dlls/qasf/asfreader.c       | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 dlls/qasf/tests/asfreader.c |  4 +---
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/dlls/qasf/asfreader.c b/dlls/qasf/asfreader.c
index 8f97667752c..738b6e63548 100644
--- a/dlls/qasf/asfreader.c
+++ b/dlls/qasf/asfreader.c
@@ -99,6 +99,39 @@ static HRESULT asf_stream_query_accept(struct strmbase_pin *iface, const AM_MEDI
     return hr;
 }
 
+static HRESULT asf_stream_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *media_type)
+{
+    struct asf_stream *stream = impl_from_strmbase_pin(iface);
+    struct asf_reader *filter = asf_reader_from_asf_stream(stream);
+    IWMOutputMediaProps *props;
+    WM_MEDIA_TYPE *mt;
+    DWORD size;
+    HRESULT hr;
+
+    TRACE("iface %p, index %u, media_type %p.\n", iface, index, media_type);
+
+    if (FAILED(IWMReader_GetOutputFormat(filter->reader, stream->index, index, &props)))
+        return VFW_S_NO_MORE_ITEMS;
+    if (FAILED(hr = IWMOutputMediaProps_GetMediaType(props, NULL, &size)))
+    {
+        IWMOutputMediaProps_Release(props);
+        return hr;
+    }
+    if (!(mt = malloc(size)))
+    {
+        IWMOutputMediaProps_Release(props);
+        return E_OUTOFMEMORY;
+    }
+
+    hr = IWMOutputMediaProps_GetMediaType(props, mt, &size);
+    if (SUCCEEDED(hr))
+        hr = CopyMediaType(media_type, (AM_MEDIA_TYPE *)mt);
+
+    free(mt);
+    IWMOutputMediaProps_Release(props);
+    return hr;
+}
+
 static inline struct asf_reader *impl_from_strmbase_filter(struct strmbase_filter *iface)
 {
     return CONTAINING_RECORD(iface, struct asf_reader, filter);
@@ -172,6 +205,7 @@ static HRESULT WINAPI asf_reader_DecideBufferSize(struct strmbase_source *iface,
 static const struct strmbase_source_ops source_ops =
 {
     .base.pin_query_accept = asf_stream_query_accept,
+    .base.pin_get_media_type = asf_stream_get_media_type,
     .pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
     .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
     .pfnDecideBufferSize = asf_reader_DecideBufferSize,
@@ -327,6 +361,7 @@ static HRESULT WINAPI reader_callback_OnStatus(IWMReaderCallback *iface, WMT_STA
         WMT_ATTR_DATATYPE type, BYTE *value, void *context)
 {
     struct asf_reader *filter = impl_from_IWMReaderCallback(iface)->filter;
+    AM_MEDIA_TYPE stream_media_type = {0};
     DWORD i, stream_count;
     WCHAR name[MAX_PATH];
 
@@ -356,7 +391,15 @@ static HRESULT WINAPI reader_callback_OnStatus(IWMReaderCallback *iface, WMT_STA
             for (i = 0; i < stream_count; ++i)
             {
                 struct asf_stream *stream = filter->streams + i;
-                swprintf(name, ARRAY_SIZE(name), L"Raw Stream %u", stream->index);
+
+                if (FAILED(hr = asf_stream_get_media_type(&stream->source.pin, 0, &stream_media_type)))
+                    WARN("Failed to get stream media type, hr %#lx.\n", hr);
+                if (IsEqualGUID(&stream_media_type.majortype, &MEDIATYPE_Video))
+                    swprintf(name, ARRAY_SIZE(name), L"Raw Video %u", stream->index);
+                else
+                    swprintf(name, ARRAY_SIZE(name), L"Raw Audio %u", stream->index);
+                FreeMediaType(&stream_media_type);
+
                 strmbase_source_init(&stream->source, &filter->filter, name, &source_ops);
             }
             filter->stream_count = stream_count;
diff --git a/dlls/qasf/tests/asfreader.c b/dlls/qasf/tests/asfreader.c
index 494d0384ac8..ed78a856003 100644
--- a/dlls/qasf/tests/asfreader.c
+++ b/dlls/qasf/tests/asfreader.c
@@ -231,13 +231,11 @@ static void check_pin(IPin *pin, IBaseFilter *expect_filter, PIN_DIRECTION expec
     ok(hr == S_OK, "Got hr %#lx.\n", hr);
     ok(info.pFilter == expect_filter, "Got filter %p.\n", info.pFilter);
     ok(info.dir == expect_dir, "Got dir %#x.\n", info.dir);
-    todo_wine
     ok(!wcscmp(info.achName, expect_name), "Got name %s.\n", debugstr_w(info.achName));
     IBaseFilter_Release(info.pFilter);
 
     hr = IPin_QueryId(pin, &id);
     ok(hr == S_OK, "Got hr %#lx.\n", hr);
-    todo_wine
     ok(!wcscmp(id, expect_id), "Got id %s.\n", debugstr_w(id));
     CoTaskMemFree(id);
 
@@ -253,7 +251,7 @@ static void check_pin(IPin *pin, IBaseFilter *expect_filter, PIN_DIRECTION expec
         FreeMediaType(mt);
         CoTaskMemFree(mt);
     }
-    todo_wine
+    todo_wine_if(IsEqualGUID(&expect_mt[0].majortype, &MEDIATYPE_Video))
     ok(i == expect_mt_count, "Got %u types.\n", i);
     ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
     IEnumMediaTypes_Release(enum_mt);




More information about the wine-cvs mailing list