利用AddSourceFilter建立的智能连接播放视频文件

int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);


IGraphBuilder *pBuilder=NULL;
IMediaControl *pCtl=NULL;
::CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder,(void**)&pBuilder);


IBaseFilter *pFilter=NULL;
pBuilder->AddSourceFilter(L"E://1.AVI",L"source",&pFilter);


IPin *pPin=NULL;
IEnumPins *pEnum=NULL;
pFilter->EnumPins((IEnumPins**)&pEnum);
ULONG cFetched;
pEnum->Next(1,&pPin,&cFetched);


pBuilder->Render(pPin);
//pBuilder->RenderFile(L"e://1.AVI",NULL);


pBuilder->QueryInterface(IID_IMediaControl,(void**)&pCtl);
pCtl->Run();


IMediaEventEx *pEvent=NULL;
pBuilder->QueryInterface(IID_IMediaEventEx,(void **)&pEvent);
long EvCode=0;
pEvent->WaitForCompletion(INFINITE,&EvCode);


pFilter->Release();
pCtl->Release();
pBuilder->Release();
getchar();
::CoUninitialize();
return 0;
}

你可能感兴趣的:(filter)