static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream* iface, IGraphBuilder** ppGraphBuilder) { IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface); TRACE("(%p/%p)->(%p)\n", This, iface, ppGraphBuilder); if (!ppGraphBuilder) return E_POINTER; if (This->pFilterGraph) return IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)ppGraphBuilder); else *ppGraphBuilder = NULL; return S_OK; }
HRESULT WINAPI BaseRendererImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart) { HRESULT hr = S_OK; BaseRenderer *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%s)\n", This, wine_dbgstr_longlong(tStart)); EnterCriticalSection(&This->csRenderLock); This->filter.rtStreamStart = tStart; if (This->filter.state == State_Running) goto out; SetEvent(This->evComplete); ResetEvent(This->ThreadSignal); if (This->pInputPin->pin.pConnectedTo) { This->pInputPin->end_of_stream = 0; } else if (This->filter.filterInfo.pGraph) { IMediaEventSink *pEventSink; hr = IFilterGraph_QueryInterface(This->filter.filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink); if (SUCCEEDED(hr)) { hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, (LONG_PTR)This); IMediaEventSink_Release(pEventSink); } hr = S_OK; } if (SUCCEEDED(hr)) { QualityControlRender_Start(This->qcimpl, This->filter.rtStreamStart); if (This->pFuncsTable->pfnOnStartStreaming) This->pFuncsTable->pfnOnStartStreaming(This); if (This->filter.state == State_Stopped) BaseRendererImpl_ClearPendingSample(This); SetEvent(This->RenderEvent); This->filter.state = State_Running; } out: LeaveCriticalSection(&This->csRenderLock); return hr; }
static HRESULT WINAPI DSoundRender_InputPin_EndOfStream(IPin * iface) { BaseInputPin* This = (BaseInputPin*)iface; DSoundRenderImpl *me = (DSoundRenderImpl*)This->pin.pinInfo.pFilter; IMediaEventSink* pEventSink; HRESULT hr; EnterCriticalSection(This->pin.pCritSec); TRACE("(%p/%p)->()\n", This, iface); hr = BaseInputPinImpl_EndOfStream(iface); if (hr != S_OK) { ERR("%08x\n", hr); LeaveCriticalSection(This->pin.pCritSec); return hr; } hr = IFilterGraph_QueryInterface(me->filter.filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink); if (SUCCEEDED(hr)) { BYTE * silence; silence = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, me->buf_size); if (silence) { memset(silence, 0, me->buf_size); DSoundRender_SendSampleData((DSoundRenderImpl*)This->pin.pinInfo.pFilter, silence, me->buf_size); HeapFree(GetProcessHeap(), 0, silence); } hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0); IMediaEventSink_Release(pEventSink); } MediaSeekingPassThru_EOS(me->seekthru_unk); LeaveCriticalSection(This->pin.pCritSec); return hr; }
HRESULT WINAPI BaseRendererImpl_EndOfStream(BaseRenderer* iface) { IMediaEventSink* pEventSink; IFilterGraph *graph; HRESULT hr = S_OK; TRACE("(%p)\n", iface); graph = iface->filter.filterInfo.pGraph; if (graph) { hr = IFilterGraph_QueryInterface(iface->filter.filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink); if (SUCCEEDED(hr)) { hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, (LONG_PTR)iface); IMediaEventSink_Release(pEventSink); } } RendererPosPassThru_EOS(iface->pPosition); SetEvent(iface->evComplete); return hr; }
static HRESULT WINAPI NullRenderer_InputPin_EndOfStream(IPin * iface) { InputPin* This = (InputPin*)iface; IMediaEventSink* pEventSink; IFilterGraph *graph; HRESULT hr = S_OK; TRACE("(%p/%p)->()\n", This, iface); InputPin_EndOfStream(iface); graph = ((NullRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph; if (graph) { hr = IFilterGraph_QueryInterface(((NullRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink); if (SUCCEEDED(hr)) { hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0); IMediaEventSink_Release(pEventSink); } } return hr; }
static gboolean gst_dshowvideodec_create_graph_and_filters (GstDshowVideoDec * vdec) { HRESULT hres = S_FALSE; GstDshowVideoDecClass *klass = (GstDshowVideoDecClass *) G_OBJECT_GET_CLASS (vdec); /* create the filter graph manager object */ hres = CoCreateInstance (&CLSID_FilterGraph, NULL, CLSCTX_INPROC, &IID_IFilterGraph, (LPVOID *) & vdec->filtergraph); if (hres != S_OK || !vdec->filtergraph) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't create an instance " "of the directshow graph manager (error=%d)", hres), (NULL)); goto error; } hres = IFilterGraph_QueryInterface (vdec->filtergraph, &IID_IMediaFilter, (void **) &vdec->mediafilter); if (hres != S_OK || !vdec->mediafilter) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't get IMediacontrol interface " "from the graph manager (error=%d)", hres), (NULL)); goto error; } /* create fake src filter */ hres = CoCreateInstance (&CLSID_DshowFakeSrc, NULL, CLSCTX_INPROC, &IID_IBaseFilter, (LPVOID *) & vdec->srcfilter); if (hres != S_OK || !vdec->srcfilter) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't create an instance " "of the directshow fakesrc (error=%d)", hres), (NULL)); goto error; } /* search a decoder filter and create it */ if (!gst_dshow_find_filter (klass->entry->input_majortype, klass->entry->input_subtype, klass->entry->output_majortype, klass->entry->output_subtype, klass->entry->preferred_filter_substring, &vdec->decfilter)) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't create an instance " "of the decoder filter"), (NULL)); goto error; } /* create fake sink filter */ hres = CoCreateInstance (&CLSID_DshowFakeSink, NULL, CLSCTX_INPROC, &IID_IBaseFilter, (LPVOID *) & vdec->sinkfilter); if (hres != S_OK || !vdec->sinkfilter) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't create an instance " "of the directshow fakesink (error=%d)", hres), (NULL)); goto error; } /* add filters to the graph */ hres = IFilterGraph_AddFilter (vdec->filtergraph, vdec->srcfilter, L"src"); if (hres != S_OK) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't add fakesrc filter " "to the graph (error=%d)", hres), (NULL)); goto error; } hres = IFilterGraph_AddFilter (vdec->filtergraph, vdec->decfilter, L"decoder"); if (hres != S_OK) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't add decoder filter " "to the graph (error=%d)", hres), (NULL)); goto error; } hres = IFilterGraph_AddFilter (vdec->filtergraph, vdec->sinkfilter, L"sink"); if (hres != S_OK) { GST_ELEMENT_ERROR (vdec, STREAM, FAILED, ("Can't add fakesink filter " "to the graph (error=%d)", hres), (NULL)); goto error; } return TRUE; error: if (vdec->srcfilter) { IBaseFilter_Release (vdec->srcfilter); vdec->srcfilter = NULL; } if (vdec->decfilter) { IBaseFilter_Release (vdec->decfilter); vdec->decfilter = NULL; } if (vdec->sinkfilter) { IBaseFilter_Release (vdec->sinkfilter); vdec->sinkfilter = NULL; } if (vdec->mediafilter) { IMediaFilter_Release (vdec->mediafilter); vdec->mediafilter = NULL; } if (vdec->filtergraph) { IFilterGraph_Release (vdec->filtergraph); vdec->filtergraph = NULL; } return FALSE; }
static gboolean gst_dshowaudiosrc_open (GstAudioSrc * asrc) { HRESULT hres = S_FALSE; GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (asrc); hres = CoCreateInstance (&CLSID_FilterGraph, NULL, CLSCTX_INPROC, &IID_IFilterGraph, (LPVOID *) & src->filter_graph); if (hres != S_OK || !src->filter_graph) { GST_CAT_ERROR (dshowaudiosrc_debug, "Can't create an instance of the directshow graph manager (error=%d)", hres); goto error; } hres = IFilterGraph_QueryInterface (src->filter_graph, &IID_IMediaFilter, (void **) &src->media_filter); if (hres != S_OK || !src->media_filter) { GST_CAT_ERROR (dshowaudiosrc_debug, "Can't get IMediacontrol interface from the graph manager (error=%d)", hres); goto error; } hres = CoCreateInstance (&CLSID_DshowFakeSink, NULL, CLSCTX_INPROC, &IID_IBaseFilter, (LPVOID *) & src->dshow_fakesink); if (hres != S_OK || !src->dshow_fakesink) { GST_CAT_ERROR (dshowaudiosrc_debug, "Can't create an instance of the directshow fakesink (error=%d)", hres); goto error; } hres = IFilterGraph_AddFilter (src->filter_graph, src->audio_cap_filter, L"capture"); if (hres != S_OK) { GST_CAT_ERROR (dshowaudiosrc_debug, "Can't add the directshow capture filter to the graph (error=%d)", hres); goto error; } hres = IFilterGraph_AddFilter (src->filter_graph, src->dshow_fakesink, L"fakesink"); if (hres != S_OK) { GST_CAT_ERROR (dshowaudiosrc_debug, "Can't add our fakesink filter to the graph (error=%d)", hres); goto error; } return TRUE; error: if (src->dshow_fakesink) { IBaseFilter_Release (src->dshow_fakesink); src->dshow_fakesink = NULL; } if (src->media_filter) { IMediaFilter_Release (src->media_filter); src->media_filter = NULL; } if (src->filter_graph) { IFilterGraph_Release (src->filter_graph); src->filter_graph = NULL; } return FALSE; }
static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR pszFileName, DWORD dwFlags) { HRESULT ret; IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface); IFileSourceFilter *SourceFilter; IBaseFilter *BaseFilter; IEnumPins *EnumPins; IPin *ipin; PIN_DIRECTION pin_direction; TRACE("(%p/%p)->(%s,%x)\n", This, iface, debugstr_w(pszFileName), dwFlags); ret = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSourceFilter, (void**)&SourceFilter); if(ret != S_OK) return ret; ret = IFileSourceFilter_Load(SourceFilter, pszFileName, NULL); if(ret != S_OK) { IFileSourceFilter_Release(SourceFilter); return ret; } ret = IFileSourceFilter_QueryInterface(SourceFilter, &IID_IBaseFilter, (void**)&BaseFilter); if(ret != S_OK) { IFileSourceFilter_Release(SourceFilter); return ret; } ret = IBaseFilter_EnumPins(BaseFilter, &EnumPins); if(ret != S_OK) { goto end; } ret = IEnumPins_Next(EnumPins, 1, &ipin, NULL); if(ret == S_OK) { ret = IPin_QueryDirection(ipin, &pin_direction); IEnumPins_Release(EnumPins); if(ret == S_OK && pin_direction == PINDIR_OUTPUT) This->ipin = ipin; else goto end; } else { IEnumPins_Release(EnumPins); goto end; } /* If Initialize was not called before, we do it here */ if (!This->pFilterGraph) { ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL); if (FAILED(ret)) goto end; } ret = IFilterGraph_QueryInterface(This->pFilterGraph, &IID_IGraphBuilder, (void**)&This->GraphBuilder); if(ret != S_OK) { goto end; } ret = IGraphBuilder_AddSourceFilter(This->GraphBuilder, pszFileName, pszFileName, &BaseFilter); end: IBaseFilter_Release(BaseFilter); IFileSourceFilter_Release(SourceFilter); return ret; }