On 3/31/20 11:02 AM, Jactry Zeng wrote:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/qasf/tests/wmasf.c | 30 +++++++++++++++++- dlls/qasf/wmasf.c | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/dlls/qasf/tests/wmasf.c b/dlls/qasf/tests/wmasf.c index b82aa3a053..3bf1e4ce4e 100644 --- a/dlls/qasf/tests/wmasf.c +++ b/dlls/qasf/tests/wmasf.c @@ -68,7 +68,7 @@ static void test_interfaces(void)
check_interface(filter, &IID_IBaseFilter, TRUE); check_interface(filter, &IID_IMediaFilter, TRUE);
- todo_wine check_interface(filter, &IID_IFileSourceFilter, TRUE);
- check_interface(filter, &IID_IFileSourceFilter, TRUE); check_interface(filter, &IID_IPersist, TRUE); check_interface(filter, &IID_IUnknown, TRUE);
@@ -171,12 +171,40 @@ static void test_aggregation(void) ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); }
+static void test_filesourcefilter(void) +{
- IFileSourceFilter *filesource;
- IBaseFilter *filter;
- HRESULT hr;
- hr = CoCreateInstance(&CLSID_WMAsfReader, NULL, CLSCTX_INPROC_SERVER,
&IID_IBaseFilter, (void **)&filter);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- expected_ref(filter, 1);
- hr = IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- expected_ref(filesource, 2);
- expected_ref(filter, 2);
- IFileSourceFilter_Release(filesource);
- IBaseFilter_Release(filter);
- hr = CoCreateInstance(&CLSID_WMAsfReader, NULL, CLSCTX_INPROC_SERVER,
&IID_IFileSourceFilter, (void **)&filesource);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- expected_ref(filesource, 1);
- IFileSourceFilter_Release(filesource);
+}
It's not a big deal since you add to this later, but as it is this test is essentially just duplicating test_interfaces().
START_TEST(wmasf) { CoInitializeEx(NULL, COINIT_MULTITHREADED);
test_interfaces(); test_aggregation();
test_filesourcefilter();
CoUninitialize();
} diff --git a/dlls/qasf/wmasf.c b/dlls/qasf/wmasf.c index 04aaf21367..ad7bb5be8f 100644 --- a/dlls/qasf/wmasf.c +++ b/dlls/qasf/wmasf.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qasf); struct wmasf_reader { struct strmbase_filter filter;
- IFileSourceFilter IFileSourceFilter_iface;
};
static inline struct wmasf_reader *impl_reader_from_strmbase_filter(struct strmbase_filter *iface) @@ -32,6 +33,11 @@ static inline struct wmasf_reader *impl_reader_from_strmbase_filter(struct strmb return CONTAINING_RECORD(iface, struct wmasf_reader, filter); }
+static inline struct wmasf_reader *impl_reader_from_IFileSourceFilter(IFileSourceFilter *iface) +{
- return CONTAINING_RECORD(iface, struct wmasf_reader, IFileSourceFilter_iface);
+}
static struct strmbase_pin *wmasf_reader_get_pin(struct strmbase_filter *iface, unsigned int index) { return NULL; @@ -45,10 +51,69 @@ static void wmasf_reader_destroy(struct strmbase_filter *iface) free(filter); }
+static HRESULT wmasf_reader_query_interface(struct strmbase_filter *iface, REFIID iid, void **out) +{
- struct wmasf_reader *filter = impl_reader_from_strmbase_filter(iface);
- if (IsEqualGUID(iid, &IID_IFileSourceFilter))
- {
*out = &filter->IFileSourceFilter_iface;
IUnknown_AddRef((IUnknown *)*out);
return S_OK;
- }
- return E_NOINTERFACE;
+}
static struct strmbase_filter_ops filter_ops = { .filter_get_pin = wmasf_reader_get_pin, .filter_destroy = wmasf_reader_destroy,
- .filter_query_interface = wmasf_reader_query_interface,
+};
+static HRESULT WINAPI filesourcefilter_QueryInterface(IFileSourceFilter *iface, REFIID riid, void **out) +{
- struct wmasf_reader *This = impl_reader_from_IFileSourceFilter(iface);
- return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, out);
+}
+static ULONG WINAPI filesourcefilter_AddRef(IFileSourceFilter *iface) +{
- struct wmasf_reader *This = impl_reader_from_IFileSourceFilter(iface);
- return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
+}
+static ULONG WINAPI filesourcefilter_Release(IFileSourceFilter *iface) +{
- struct wmasf_reader *This = impl_reader_from_IFileSourceFilter(iface);
- return IBaseFilter_Release(&This->filter.IBaseFilter_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);
- return E_NOTIMPL;
+}
+static HRESULT WINAPI filesourcefilter_GetCurFile(IFileSourceFilter *iface, LPOLESTR *filename, AM_MEDIA_TYPE *type) +{
- FIXME("(%p, %p, %p): stub.\n", iface, filename, type);
- return E_NOTIMPL;
+}
+static const IFileSourceFilterVtbl filesourcefilter_vtbl = +{
- filesourcefilter_QueryInterface,
- filesourcefilter_AddRef,
- filesourcefilter_Release,
- filesourcefilter_Load,
- filesourcefilter_GetCurFile
};
HRESULT wmasf_reader_create(IUnknown *outer, IUnknown **out) @@ -60,6 +125,8 @@ HRESULT wmasf_reader_create(IUnknown *outer, IUnknown **out)
strmbase_filter_init(&object->filter, outer, &CLSID_WMAsfReader, &filter_ops);
- object->IFileSourceFilter_iface.lpVtbl = &filesourcefilter_vtbl;
- TRACE("Created WM ASF reader %p.\n", object); *out = &object->filter.IUnknown_inner;