资源预览内容
第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
第9页 / 共11页
第10页 / 共11页
亲,该文档总共11页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
CoInitialize(NULL); HRESULT hr; IGraphBuilder* pGraphBuilder=NULL; CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void *) IBaseFilter* pMpeg4PSFileStream; IBaseFilter* pMpegDemuxFilter; IBaseFilter* pMpeg4VideoDecoder; IBaseFilter* pOverlayMaxer2; IBaseFilter* pVideoRenderer; hr=CoCreateInstance(CLSID_Mpeg4PSFileStream, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void*) if (FAILED(hr) AfxMessageBox(err create CLSID_Mpeg4PSFileStream); hr=CoCreateInstance(CLSID_MpegDemuxFilter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void*) if (FAILED(hr) AfxMessageBox(err create CLSID_MpegDemuxFilter); hr=CoCreateInstance(CLSID_Mpeg4VideoDecoder, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void*) if (FAILED(hr) AfxMessageBox(err create CLSID_Mpeg4VideoDecoder); hr=CoCreateInstance(CLSID_OverlayMaxer2, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void*) if (FAILED(hr) AfxMessageBox(err create CLSID_OverlayMaxer2); hr=CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void*) if (FAILED(hr) AfxMessageBox(err create CLSID_VideoRenderer); pGraphBuilder-AddFilter(pMpeg4PSFileStream , NULL); pGraphBuilder-AddFilter(pMpegDemuxFilter , NULL); pGraphBuilder-AddFilter(pMpeg4VideoDecoder , NULL); pGraphBuilder-AddFilter(pOverlayMaxer2 , NULL); pGraphBuilder-AddFilter(pVideoRenderer , NULL); /set the source file IFileSourceFilter * pLoader; pMpeg4PSFileStream-QueryInterface(IID_IFileSourceFilter, (void *) hr=pLoader-Load(LE:tempmpeg4_ps.mpg,NULL); if (FAILED(hr) AfxMessageBox(装载文件出错!); /connect filter char *strPinName = new char; IEnumPins* EnumPins; IPin* OutPin; IPin* InPin; ULONG fetched; PIN_INFO pinfo; / find source output pMpeg4PSFileStream-EnumPins( EnumPins-Reset(); EnumPins-Next(1, / only 1 pin for source, so we know this is the one we need EnumPins-Release(); / find Demux Filter input pMpegDemuxFilter-EnumPins( EnumPins-Reset(); EnumPins-Next(1, InPin-QueryPinInfo( pinfo.pFilter-Release(); / make sure you release the returned IBaseFilter interface while (pinfo.dir = PINDIR_OUTPUT) / check if we have wrong pin (not input pin),2 output pin InPin-Release(); EnumPins-Next(1, / if so, get next pin InPin-QueryPinInfo( pinfo.pFilter-Release(); / connect - 1 pGraphBuilder-Connect(OutPin, InPin); InPin-Release(); OutPin-Release(); / find Demux Filter output EnumPins-Reset(); EnumPins-Next(1, OutPin-QueryPinInfo( pinfo.pFilter-Release(); if (pinfo.dir = PINDIR_INPUT) / check if we have wrong pin (not input pin),only 1 input pin InPin-Release(); EnumPins-Next(1, / if so, get next pin EnumPins-Release(); / find Vweb Mpeg4 Video Decoder input pMpeg4VideoDecoder-EnumPins( EnumPins-Reset(); EnumPins-Next(1, InPin-QueryPinInfo( pinfo.pFilter-Release(); / make sure you release the returned IBaseFilter interface if (pinfo.dir = PINDIR_OUTPUT) / check if we have wrong pin (not input pin),only 1 input pin InPin-Release(); EnumPins-Next(1, / if so, get next pin / connect - 2 pGraphBuilder-Connect(OutPin, InPin); InPin-Release(); OutPin-Release(); / find Vweb Mpeg4 Video Decoder output * EnumPins-Reset(); EnumPins-Next(1, OutPin-QueryPinInfo( pinfo.pFilter-Release(); / make sure you release the returned IBaseFilter interface if (pinfo.dir = PINDIR_INPUT) / check if we have wrong pin (not input pin),only 1 input pin OutPin-Release(); EnumPins-Next(1, / if so, get next pin OutPin-QueryPinInfo( pinfo.pFilter-Release(); WCHAR *s=pinfo.achName; EnumPins-Release(); / find Overlay Mixer2 input pOverlayMaxer2-EnumPins( EnumPins-Reset(); EnumPins-Next(1, InPin-QueryPinInfo( pinfo.pFilter-Release(); / make sure you release the returned IBaseFilter interface WCHAR *s=pinfo.achName; if (pinfo.dir = PINDIR_OUTPUT) / check if we have wrong pin (not input pin),2 input pin InPin-Release(); EnumPins-Next(1, / if so, get next pin / connect - 3 pGraphBuilder-Connect(OutPin, InPin); InPin-Release(); OutPin-Release(); / find Overlay Mixer2 output EnumPins-Reset(); EnumPins-Next(1, OutPin-QueryPinInfo( pinfo.pFilter-Release(); / make sure you release the returned IBaseFilter interface while (pinfo.dir = PINDIR_INPUT) / check if we have wrong pin (not input pin),2 input pin OutPin-Release(); EnumPins-Next(1, / if so, get next pin OutPin-QueryPinInfo( pinfo.pFilter-Release(); WCHAR *s=pinfo.achName; EnumPins-Release(); / find renderer input pVideoRenderer-EnumPins( EnumPins-Reset(); EnumPins-Next(1, / renderer has only 1 pin, so this is the pin we need EnumPins-Release(); / connect - 4 pGraphBuilder-Connect(OutPin, InPin); InPin-Release(); OutPin-Release();
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号