[PATCH v2 3/4] qasf: Implement IFileSourceFilter_Load() for WM ASF reader.
Jactry Zeng
jzeng at codeweavers.com
Mon Apr 6 04:41:23 CDT 2020
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
dlls/qasf/asfreader.c | 26 +++++++-
dlls/qasf/tests/asfreader.c | 123 ++++++++++++++++++++++++++++++++++++
2 files changed, 147 insertions(+), 2 deletions(-)
diff --git a/dlls/qasf/asfreader.c b/dlls/qasf/asfreader.c
index 8388d79a31..6630d7badc 100644
--- a/dlls/qasf/asfreader.c
+++ b/dlls/qasf/asfreader.c
@@ -26,6 +26,9 @@ struct asf_reader
{
struct strmbase_filter filter;
IFileSourceFilter IFileSourceFilter_iface;
+
+ AM_MEDIA_TYPE type;
+ LPOLESTR filename;
};
static inline struct asf_reader *impl_reader_from_strmbase_filter(struct strmbase_filter *iface)
@@ -47,6 +50,9 @@ static void asf_reader_destroy(struct strmbase_filter *iface)
{
struct asf_reader *filter = impl_reader_from_strmbase_filter(iface);
+ free(filter->filename);
+ FreeMediaType(&filter->type);
+
strmbase_filter_cleanup(&filter->filter);
free(filter);
}
@@ -95,9 +101,25 @@ static ULONG WINAPI filesourcefilter_Release(IFileSourceFilter *iface)
static HRESULT WINAPI filesourcefilter_Load(IFileSourceFilter * iface, LPCOLESTR filename, const AM_MEDIA_TYPE *type)
{
- FIXME("(%p, %s, %p): stub.\n", iface, debugstr_w(filename), type);
+ struct asf_reader *This = impl_reader_from_IFileSourceFilter(iface);
- return E_NOTIMPL;
+ TRACE("(%p, %s, %p).\n", iface, debugstr_w(filename), type);
+ strmbase_dump_media_type(type);
+
+ if (!filename)
+ return E_POINTER;
+
+ if (This->filename)
+ return E_FAIL;
+
+ This->filename = wcsdup(filename);
+ if (!This->filename)
+ return E_OUTOFMEMORY;
+
+ if (type)
+ CopyMediaType(&This->type, type);
+
+ return S_OK;
}
static HRESULT WINAPI filesourcefilter_GetCurFile(IFileSourceFilter *iface, LPOLESTR *filename, AM_MEDIA_TYPE *type)
diff --git a/dlls/qasf/tests/asfreader.c b/dlls/qasf/tests/asfreader.c
index b3f61a352a..c90956c85e 100644
--- a/dlls/qasf/tests/asfreader.c
+++ b/dlls/qasf/tests/asfreader.c
@@ -27,6 +27,7 @@
#include "initguid.h"
+DEFINE_GUID(IID_TESTIID, 0x22222222, 0x2222, 0x2222, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22);
DEFINE_GUID(IID_IWMHeaderInfo, 0x96406bda, 0x2b2b, 0x11d3, 0xb3, 0x6b, 0x00, 0xc0, 0x4f, 0x61, 0x08, 0xff);
DEFINE_GUID(IID_IWMReaderAdvanced, 0x96406bea, 0x2b2b, 0x11d3, 0xb3, 0x6b, 0x00, 0xc0, 0x4f, 0x61, 0x08, 0xff);
DEFINE_GUID(IID_IWMReaderAdvanced2, 0xae14a945, 0xb90c, 0x4d0d, 0x91, 0x27, 0x80, 0xd6, 0x65, 0xf7, 0xd7, 0x3e);
@@ -181,12 +182,134 @@ static void test_aggregation(void)
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
}
+static void test_filesourcefilter(void)
+{
+ IFileSourceFilter *filesource;
+ IFilterGraph2 *graph;
+ IEnumPins *enumpins;
+ IBaseFilter *filter;
+ AM_MEDIA_TYPE type;
+ LPOLESTR olepath;
+ IPin *pins[4];
+ HRESULT hr;
+ ULONG ref;
+
+ hr = CoCreateInstance(&CLSID_WMAsfReader, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IBaseFilter, (void **)&filter);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ref = get_refcount(filter);
+ ok(ref == 1, "Got unexpected refcount %d.\n", ref);
+ hr = IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ref = get_refcount(filesource);
+ ok(ref == 2, "Got unexpected refcount %d.\n", ref);
+ ref = get_refcount(filter);
+ ok(ref == 2, "Got unexpected refcount %d.\n", ref);
+
+ hr = IFileSourceFilter_Load(filesource, NULL, NULL);
+ ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+ olepath = (void *)0xdeadbeef;
+ memset(&type, 0x22, sizeof(type));
+ hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &type);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ todo_wine ok(!olepath, "Got %s.\n", wine_dbgstr_w(olepath));
+ todo_wine ok(IsEqualGUID(&type.majortype, &MEDIATYPE_NULL), "Got majortype %s.\n",
+ wine_dbgstr_guid(&type.majortype));
+ todo_wine ok(IsEqualGUID(&type.subtype, &MEDIASUBTYPE_NULL), "Got subtype %s.\n",
+ wine_dbgstr_guid(&type.subtype));
+ ok(type.bFixedSizeSamples == 0x22222222, "Got fixed size %d.\n", type.bFixedSizeSamples);
+ ok(type.bTemporalCompression == 0x22222222, "Got temporal compression %d.\n", type.bTemporalCompression);
+ todo_wine ok(!type.lSampleSize, "Got sample size %u.\n", type.lSampleSize);
+ ok(IsEqualIID(&type.formattype, &IID_TESTIID), "Got format type %s.\n", wine_dbgstr_guid(&type.formattype));
+ todo_wine ok(!type.pUnk, "Got pUnk %p.\n", type.pUnk);
+ todo_wine ok(!type.cbFormat, "Got format size %u.\n", type.cbFormat);
+ ok(type.pbFormat == (BYTE *)0x22222222, "Got format block %p.\n", type.pbFormat);
+
+ hr = IFileSourceFilter_Load(filesource, L"nonexistent.wmv", NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFileSourceFilter_GetCurFile(filesource, NULL, NULL);
+ todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+ hr = IFileSourceFilter_Load(filesource, L"nonexistent2.wmv", NULL);
+ ok(hr == E_FAIL, "Got hr %#x.\n", hr);
+
+ olepath = (void *)0xdeadbeef;
+ memset(&type, 0x22, sizeof(type));
+ hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &type);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ ok(!wcscmp(olepath, L"nonexistent.wmv"), "Expected path %s, got %s.\n",
+ wine_dbgstr_w(L"nonexistent.wmv"), wine_dbgstr_w(olepath));
+ ok(IsEqualGUID(&type.majortype, &MEDIATYPE_NULL), "Got majortype %s.\n",
+ wine_dbgstr_guid(&type.majortype));
+ ok(IsEqualGUID(&type.subtype, &MEDIASUBTYPE_NULL), "Got subtype %s.\n",
+ wine_dbgstr_guid(&type.subtype));
+ ok(type.bFixedSizeSamples == 0x22222222, "Got fixed size %d.\n", type.bFixedSizeSamples);
+ ok(type.bTemporalCompression == 0x22222222, "Got temporal compression %d.\n", type.bTemporalCompression);
+ ok(!type.lSampleSize, "Got sample size %u.\n", type.lSampleSize);
+ ok(IsEqualIID(&type.formattype, &IID_TESTIID), "Got format type %s.\n", wine_dbgstr_guid(&type.formattype));
+ ok(!type.pUnk, "Got pUnk %p.\n", type.pUnk);
+ ok(!type.cbFormat, "Got format size %u.\n", type.cbFormat);
+ ok(type.pbFormat == (BYTE *)0x22222222, "Got format block %p.\n", type.pbFormat);
+ CoTaskMemFree(olepath);
+ }
+
+ hr = IBaseFilter_EnumPins(filter, &enumpins);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IEnumPins_Next(enumpins, 1, pins, NULL);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ IEnumPins_Release(enumpins);
+
+ hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IFilterGraph2, (void **)&graph);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_AddFilter(graph, filter, NULL);
+ todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
+ broken(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND)) /* win2008 */,
+ "Got hr %#x.\n", hr);
+
+ hr = IFileSourceFilter_Load(filesource, L"nonexistent2.wmv", NULL);
+ ok(hr == E_FAIL, "Got hr %#x.\n", hr);
+
+ olepath = (void *)0xdeadbeef;
+ memset(&type, 0x22, sizeof(type));
+ hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &type);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ ok(!wcscmp(olepath, L"nonexistent.wmv"), "Expected path %s, got %s.\n",
+ wine_dbgstr_w(L"nonexistent.wmv"), wine_dbgstr_w(olepath));
+ ok(IsEqualGUID(&type.majortype, &MEDIATYPE_NULL), "Got majortype %s.\n",
+ wine_dbgstr_guid(&type.majortype));
+ ok(IsEqualGUID(&type.subtype, &MEDIASUBTYPE_NULL), "Got subtype %s.\n",
+ wine_dbgstr_guid(&type.subtype));
+ ok(type.bFixedSizeSamples == 0x22222222, "Got fixed size %d.\n", type.bFixedSizeSamples);
+ ok(type.bTemporalCompression == 0x22222222, "Got temporal compression %d.\n", type.bTemporalCompression);
+ ok(!type.lSampleSize, "Got sample size %u.\n", type.lSampleSize);
+ ok(IsEqualIID(&type.formattype, &IID_TESTIID), "Got format type %s.\n", wine_dbgstr_guid(&type.formattype));
+ ok(!type.pUnk, "Got pUnk %p.\n", type.pUnk);
+ ok(!type.cbFormat, "Got format size %u.\n", type.cbFormat);
+ ok(type.pbFormat == (BYTE *)0x22222222, "Got format block %p.\n", type.pbFormat);
+ CoTaskMemFree(olepath);
+ }
+
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ IBaseFilter_Release(filter);
+ ref = IFileSourceFilter_Release(filesource);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
START_TEST(asfreader)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
test_interfaces();
test_aggregation();
+ test_filesourcefilter();
CoUninitialize();
}
--
2.26.0
More information about the wine-devel
mailing list