directshow的滤波器如何与网络摄像机捆绑呢???
//把指定采集设备与滤波器捆绑
bool CCaptureClass::BindFilter(int deviceId, IBaseFilter **pFilter)
{
if (deviceId <0) return false;
//枚举所有的视频捕获设备
ICreateDevEnum *pCreateDevEnum;
//生成设备枚举器pCreateDevEnum
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum,
(void**)&pCreateDevEnum);
if (hr != NOERROR) return false;
IEnumMoniker *pEm;
//创建视频输入设备类枚举器
hr = pCreateDevEnum->CreateClassEnumerator
(CLSID_VideoInputDeviceCategory,
&pEm, 0);
if (hr != NOERROR) return false;
pEm->Reset(); //复位该设备
ULONG cFetched;
IMoniker *pM;
int index = 0;
//获取设备
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK, index <= deviceId)
{
IPropertyBag *pBag;
//获取该设备的属性集
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
if(SUCCEEDED(hr))
{
VARIANT var;
var.vt = VT_BSTR; //保存的是二进制的数据
hr = pBag->Read(L"FriendlyName", &var, NULL);
//获取FriendlyName形式的信息
if (hr == NOERROR)
{
//采集设备与捕获滤波器捆绑
if (index == deviceId)
pM->BindToObject(0, 0, IID_IBaseFilter, (void**)pFilter);
SysFreeString(var.bstrVal); //释放二进制数据资源,必须释放
}
pBag->Release();
}
pM->Release();
index++;
}
return true;
}