1) 视频捕捉Graph的构建
这里要重点了解捕捉Graph图和一般回放Graph图的定义。
一个能够捕捉音频或者视频的graph图都称之为捕捉graph图。捕捉graph图比一般的文件回放graph图要复杂许多,Directshow提供了一个Capture Graph Builder COM组件使得捕捉graph图的生成更加简单。Capture Graph Builder提供了一个ICaptureGraphBuilder2接口,这个接口提供了一些方法用来构建和控制捕捉graph图。首先创建一个Capture Graph Builder对象和一个graph manger对象(图对象的管理器),然后用filter graph manager 作参数,调用ICaptureGraphBuilder2::SetFiltergraph来初始化Capture Graph Builder。看下面的代码吧:
HRESULT InitCaptureGraphBuilder(IGraphBuilder **ppGraph, //Receives the pointer ICaptureGraphBuilder2 **ppBuilder) //Receives the pointer { if(!ppGraph || !ppBuilder) { return E_POINTER; } IGraphBuilder *pGraph = NULL; ICaptureGraphBuilder2 *pBuild = NULL; //Create the Capture Graph Builder HRESULT hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild ); if(SECCEEDED(hr)) { //Create the Filter Graph Manager hr = CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph); if(SECCEEDED(hr)) { //Initialize the Capture Graph Builder pBuild->SetFiltergraph(pGraph); //Return both interface pointers to the caller *ppBuild = pBuild; *ppGraph = pGraph; //The caller must release both interface return S_OK; } else { pBuild->Release(); } } return hr; //Failed }
未完,待续。。。。。哈哈,如有问题可以联系我:QQ:1906733710,我是从事电子签到软件、电子白板、互动投影软件、查询软件开发的,现在要开发视频录制的功能,在对Directshow 研究的过程当中。希望一起研究提高。有需要软件的也可以联系我。