首页 > 代码库 > 查找IFileSourceFilter上的Pin
查找IFileSourceFilter上的Pin
创建了IFileSourceFilter,可IFileSourceFilter好像不是从IBaseFilter继承来的,没有EnumPins,那应该怎么查找IFileSourceFilter上的pin啊?
IGraphBuilder *pigb = NULL; IMediaControl *pimc = NULL; IMediaEventEx *pimex = NULL; IVideoWindow *pivw = NULL; IMediaSeeking *pims = NULL; HRESULT AddSourceByFilterCLSID(IGraphBuilder *pGraph,const GUID& clsid, LPCWSTR wszName,LPCWSTR wszFileName) { if (!pGraph) return E_POINTER; IBaseFilter *pF = 0; HRESULT hr = S_OK; hr = CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&pF)); if (SUCCEEDED(hr)) { hr = pGraph->AddFilter(pF, wszName); if (SUCCEEDED(hr)) { IFileSourceFilter *pSF = NULL; hr = pF->QueryInterface(IID_IFileSourceFilter, (void**)&pSF); if (SUCCEEDED(hr)) { pSF->Load(wszFileName, NULL); pSF->Release(); } } if (SUCCEEDED(hr)) { IEnumPins *pEnum; IPin *pPin; hr = pF->EnumPins(&pEnum); if (SUCCEEDED(hr)) { while(pEnum->Next(1, &pPin, 0) == S_OK) { PIN_DIRECTION pinDirThis; pPin->QueryDirection(&pinDirThis); if (PINDIR_OUTPUT == pinDirThis) { hr = pGraph->Render(pPin); if (FAILED(hr)) { break; } } pPin->Release(); } pEnum->Release(); } } pF->Release(); } return hr; } HRESULT RenderAVI(LPCTSTR szFilePath,IGraphBuilder * gb) { LPCTSTR szExt = _tcsrchr(szFilePath,‘.‘);//过滤avi文件 if(!szExt) { return E_FAIL; } ++szExt; if(_tcsicmp(szExt,_T("avi"))!=0) return E_INVALIDARG; USES_CONVERSION; const GUID CLSID_AviSource={0xCEA8DEFF,0x0AF7,0x4DB9,{0x9A,0x38,0xFB,0x3C,0x3A,0xEF,0xC0,0xDE}}; CComPtr<IBaseFilter> spAviSource; HRESULT hr = AddSourceByFilterCLSID(gb,CLSID_AviSource,L"SOURCE FILTER",T2W(szFilePath)); if(spAviSource==NULL) return hr; /* CComQIPtr<IFileSourceFilter> FileSource(spAviSource); hr = FileSource->Load(T2W(szFilePath),NULL); if(FAILED(hr)) return hr; CComPtr<IEnumPins> ep; hr = spAviSource->EnumPins(&ep); if(FAILED(hr)) return hr; CComPtr<IPin> pin; DWORD dwCount; int i = 0; for(;;) { dwCount = 0; hr = ep->Next(1,&pin,&dwCount); if(hr!=NOERROR) { if(i) hr = NOERROR; break; } hr = gb->Render(pin); if(hr==NOERROR) ++i; pin = NULL; } return hr;*/ return NOERROR; } void CTestFilterDlg::OnButton4() { // TODO: Add your control notification handler code here CoInitialize(NULL); HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pigb); pigb->QueryInterface(IID_IMediaControl, (void **)&pimc); pigb->QueryInterface(IID_IMediaEventEx, (void **)&pimex); pigb->QueryInterface(IID_IMediaSeeking, (void **)&pims); pigb->QueryInterface(IID_IVideoWindow, (void **)&pivw); // hr = pigb->RenderFile(L"d:\\temp\\bmw.MPG", NULL);// hr = RenderAVI("F:\\FFOutput\\ff640480.avi",pigb); if (hr) { MessageBox("ERR RENDERAVI!"); } HWND m_hwndScreen = m_Screen2.GetSafeHwnd(); RECT rc; hr = pivw->put_Owner((OAHWND)m_hwndScreen); hr = pivw->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN); m_Screen2.GetClientRect(&rc); hr = pivw->SetWindowPosition(0, 0, (rc.right), (rc.bottom)); hr = pivw->put_Visible(OATRUE);//*/ hr = pimc->Run(); }
查找IFileSourceFilter上的Pin
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。