Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/qedit/mediadet.c | 15 ++++++++++-- dlls/qedit/tests/mediadet.c | 48 ++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/dlls/qedit/mediadet.c b/dlls/qedit/mediadet.c index 1883a12..c2cc33e 100644 --- a/dlls/qedit/mediadet.c +++ b/dlls/qedit/mediadet.c @@ -147,8 +147,19 @@ static ULONG WINAPI MediaDet_Release(IMediaDet *iface) static HRESULT WINAPI MediaDet_get_Filter(IMediaDet* iface, IUnknown **pVal) { MediaDetImpl *This = impl_from_IMediaDet(iface); - FIXME("(%p)->(%p): not implemented!\n", This, pVal); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, pVal); + + if (!pVal) + return E_POINTER; + + *pVal = (IUnknown*)This->source; + if (*pVal) + IUnknown_AddRef(*pVal); + else + return S_FALSE; + + return S_OK; }
static HRESULT WINAPI MediaDet_put_Filter(IMediaDet* iface, IUnknown *newVal) diff --git a/dlls/qedit/tests/mediadet.c b/dlls/qedit/tests/mediadet.c index 596171b..ccf7f0b 100644 --- a/dlls/qedit/tests/mediadet.c +++ b/dlls/qedit/tests/mediadet.c @@ -188,13 +188,19 @@ static BOOL init_tests(void) static void test_mediadet(void) { HRESULT hr; + FILTER_INFO filter_info; + IEnumMediaTypes *type; IMediaDet *pM = NULL; BSTR filename = NULL; + IBaseFilter *filter; + IEnumPins *pins; LONG nstrms = 0; LONG strm; GUID guid; BSTR bstr; - AM_MEDIA_TYPE mt; + IPin *pin; + AM_MEDIA_TYPE mt, *pmt; + IUnknown *unk; double fps; int flags; int i; @@ -256,6 +262,14 @@ static void test_mediadet(void) hr = IMediaDet_get_StreamTypeB(pM, NULL); ok(hr == E_INVALIDARG, "IMediaDet_get_StreamTypeB failed: %08x\n", hr);
+ hr = IMediaDet_get_Filter(pM, NULL); + ok(hr == E_POINTER, "IMediaDet_get_Filter failed: %08x\n", hr); + + unk = (IUnknown*)0xdeadbeef; + hr = IMediaDet_get_Filter(pM, &unk); + ok(hr == S_FALSE, "IMediaDet_get_Filter failed: %08x\n", hr); + ok(unk == NULL, "Wrong filter %p\n", unk); + filename = SysAllocString(test_avi_filename); hr = IMediaDet_put_Filename(pM, filename); ok(hr == S_OK, "IMediaDet_put_Filename failed: %08x\n", hr); @@ -427,6 +441,38 @@ static void test_mediadet(void) ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr); ok(strm == 1, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
+ hr = IMediaDet_get_Filter(pM, &unk); + ok(hr == S_OK, "IMediaDet_get_Filter failed: %08x\n", hr); + ok(unk != NULL, "NULL filter\n"); + hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void**)&filter); + IUnknown_Release(unk); + ok(hr == S_OK, "Could not get IBaseFilter interface: %08x\n", hr); + + hr = IBaseFilter_EnumPins(filter, &pins); + ok(hr == S_OK, "IBaseFilter_EnumPins failed: %08x\n", hr); + hr = IEnumPins_Next(pins, 1, &pin, NULL); + ok(hr == S_OK, "IEnumPins_Next failed: %08x\n", hr); + hr = IPin_EnumMediaTypes(pin, &type); + ok(hr == S_OK, "IPin_EnumMediaTypes failed: %08x\n", hr); + hr = IEnumMediaTypes_Next(type, 1, &pmt, NULL); + ok(hr == S_OK, "IEnumMediaTypes_Next failed: %08x\n", hr); + ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Stream), "Wrong GUID %s\n", wine_dbgstr_guid(&pmt->majortype)); + IEnumMediaTypes_Release(type); + CoTaskMemFree(pmt->pbFormat); + CoTaskMemFree(pmt); + IPin_Release(pin); + + hr = IEnumPins_Next(pins, 1, &pin, NULL); + ok(hr == S_FALSE, "IEnumPins_Next failed: %08x\n", hr); + IEnumPins_Release(pins); + + hr = IBaseFilter_QueryFilterInfo(filter, &filter_info); + ok(hr == S_OK, "IBaseFilter_QueryFilterInfo failed: %08x\n", hr); +todo_wine + ok(!wcscmp(filter_info.achName, L"Source"), "Wrong filter name: %s\n", wine_dbgstr_w(filter_info.achName)); + IFilterGraph_Release(filter_info.pGraph); + IBaseFilter_Release(filter); + hr = IMediaDet_Release(pM); ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);