From: "Gabriel Ivăncescu" Subject: [PATCH v4 3/9] qedit: Implement MediaDet_put_Filter. Message-Id: <9bb63fbb30dc283064dd1356d86a7630f0bf5f90.1587471285.git.gabrielopcode@gmail.com> Date: Tue, 21 Apr 2020 15:19:27 +0300 In-Reply-To: <7caadc4394fe7b68c2603e67ddd2c8f57932fa86.1587471285.git.gabrielopcode@gmail.com> References: <7caadc4394fe7b68c2603e67ddd2c8f57932fa86.1587471285.git.gabrielopcode@gmail.com> Signed-off-by: Gabriel Ivăncescu --- dlls/qedit/mediadet.c | 46 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/dlls/qedit/mediadet.c b/dlls/qedit/mediadet.c index 52090b8..56ecc2f 100644 --- a/dlls/qedit/mediadet.c +++ b/dlls/qedit/mediadet.c @@ -305,11 +305,51 @@ static HRESULT WINAPI MediaDet_get_Filter(IMediaDet *iface, IUnknown **filter) return S_OK; } -static HRESULT WINAPI MediaDet_put_Filter(IMediaDet* iface, IUnknown *newVal) +static HRESULT WINAPI MediaDet_put_Filter(IMediaDet* iface, IUnknown *filter) { MediaDetImpl *This = impl_from_IMediaDet(iface); - FIXME("(%p)->(%p): not implemented!\n", This, newVal); - return E_NOTIMPL; + IGraphBuilder *gb; + IBaseFilter *bf; + HRESULT hr; + + TRACE("detector %p, filter %p.\n", This, filter); + + if (!filter) + return E_POINTER; + + hr = IUnknown_QueryInterface(filter, &IID_IBaseFilter, (void **) &bf); + if (FAILED(hr)) + return hr; + + if (This->graph) + MD_cleanup(This); + + hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, + &IID_IGraphBuilder, (void **) &gb); + if (FAILED(hr)) + { + IBaseFilter_Release(bf); + return hr; + } + + if (FAILED(hr = IGraphBuilder_AddFilter(gb, bf, L"Source"))) + { + IGraphBuilder_Release(gb); + IBaseFilter_Release(bf); + return hr; + } + + This->graph = gb; + This->source = bf; + hr = get_splitter(This); + if (FAILED(hr)) + { + /* No splitter found, use the source directly */ + This->splitter = This->source; + IBaseFilter_AddRef(This->splitter); + } + + return IMediaDet_put_CurrentStream(&This->IMediaDet_iface, 0); } static HRESULT WINAPI MediaDet_get_OutputStreams(IMediaDet* iface, LONG *pVal) -- 2.21.0