当前位置: 代码迷 >> 多媒体/流媒体开发 >> 构建directshow graph时找不到input pin,该如何处理
  详细解决方案

构建directshow graph时找不到input pin,该如何处理

热度:3060   发布时间:2013-02-26 00:00:00.0
构建directshow graph时找不到input pin
我是刚刚接触dircetshow,需要写一个source filter接收通过网络传来的视频流,
我刚刚做了一个source filter的框架,本来想放到一个现有的graph中测试一下,结果发现有些filter的pin找不到,

具体过程是这样的,
我先调用pGraph->RenderFile(L"E:\\skiing.avi", NULL);播放一段视频,
然后使用pGraph->EnumFilters(&filters)枚举了里面所有使用到的filter,

一共是四个,没别是:
{B87BEB7B-8D29-423F-AE4D-6582C10175AC} render filter
{CF49D4E0-1115-11CE-B03A-0020AF0BA770} decompress filter
{9736D831-9D6C-4E72-B6E7-560EF9181001} split filter
{E436EBB5-524F-11CE-9F53-0020AF0BA770} file source filter

然后我想用我的source filter替换掉最后一个,做个实验,
为了保证正确我打算先不做替换,直接构建一个graph,看看结果,但是有些filter的pin没有找到,构建graph的代码是这样的:
void testgraph()
{
HRESULT hr;

GUID clsid1 = {0};
GUID clsid2 = {0};
GUID clsid3 = {0};
GUID clsid4 = {0};

if( NOERROR != CLSIDFromString( L"{B87BEB7B-8D29-423F-AE4D-6582C10175AC}" , &clsid1 ) ) _CrtDbgBreak();
if( NOERROR != CLSIDFromString( L"{CF49D4E0-1115-11CE-B03A-0020AF0BA770}" , &clsid2 ) ) _CrtDbgBreak();
if( NOERROR != CLSIDFromString( L"{9736D831-9D6C-4E72-B6E7-560EF9181001}" , &clsid3 ) ) _CrtDbgBreak();
if( NOERROR != CLSIDFromString( L"{E436EBB5-524F-11CE-9F53-0020AF0BA770}" , &clsid4 ) ) _CrtDbgBreak();

//SockSrcFilter testsrcf;

IGraphBuilder *pGraph = NULL;
{ //初始化 pGraph============================================================
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return;
}
}

IBaseFilter* srcf = NULL; // file source filter
IBaseFilter* splitf = NULL; // split filter
IBaseFilter* decf = NULL; // decompress filter
IBaseFilter* renf = NULL; // render filter
{ // 创建所有的filter srcf splitf decf renf ==================================================================
hr = CoCreateInstance(clsid1, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&renf);
if (FAILED(hr)) _CrtDbgBreak();
hr = CoCreateInstance(clsid2, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&decf);
if (FAILED(hr)) _CrtDbgBreak();
hr = CoCreateInstance(clsid3, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&splitf);
if (FAILED(hr)) _CrtDbgBreak();
hr = CoCreateInstance(clsid4, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&srcf);
if (FAILED(hr)) _CrtDbgBreak();
}

IPin* opinsrcf = NULL; // file source filter 的输出 pin // 失败,不知道为什么,请好心人帮忙?????????
IPin* ipinsplitf = NULL; // split filter 的输入 pin
IPin* opinsplitf = NULL; // split filter 的输出 pin // 失败,不知道为什么,请好心人帮忙?????????
IPin* ipindecf = NULL; // decompress filter 的输入 pin
IPin* opindecf = NULL; // decompress filter 的输出 pin
IPin* ipinrenf = NULL; // render filter 的输入 pin
{ //=========================================================================
IEnumPins* pins = NULL;
IPin* pin = NULL;
PIN_INFO pinfo = {0};

if( S_OK != renf->EnumPins(&pins) ) _CrtDbgBreak();
pins->Reset();
while( S_OK == pins->Next(1,&pin,NULL) )
{
if( S_OK != pin->QueryPinInfo(&pinfo) ) _CrtDbgBreak();
if( pinfo.dir == PINDIR_INPUT ) ipinrenf = pin;
}

if( S_OK != decf->EnumPins(&pins) ) _CrtDbgBreak();
pins->Reset();
while( S_OK == pins->Next(1,&pin,NULL) )
{
if( S_OK != pin->QueryPinInfo(&pinfo) ) _CrtDbgBreak();
if( pinfo.dir == PINDIR_INPUT ) ipindecf = pin;
if( pinfo.dir == PINDIR_OUTPUT ) opindecf = pin;
}

if( S_OK != splitf->EnumPins(&pins) ) _CrtDbgBreak();
pins->Reset();
while( S_OK == pins->Next(1,&pin,NULL) )
  相关解决方案