Retrieving the Filter
Top  Previous  Next

To instantiate ActiveUSB Video Capture Filter, you need to enumerate all video capture filters using the system device enumerator and match the filter name with "USB3 Vision compliant camera":


IBaseFilter* pFilter;
HRESULT hr;

//locate the camera filter using system device enumerator

CComPtr< ICreateDevEnum > pCreateDevEnum;
pCreateDevEnum.CoCreateInstance( CLSID_SystemDeviceEnum );
if( !pCreateDevEnum )
return E_FAIL;
// enumerate video capture devices
CComPtr< IEnumMoniker > pEm;
pCreateDevEnum->CreateClassEnumerator( CLSID_VideoInputDeviceCategory, &pEm, 0 );
if( !pEm )
return E_FAIL;

pCreateDevEnum.Release();
pEm->Reset();
int noCapDevice=0;

while(true)
{
ULONG ulFetched = 0;
CComPtr< IMoniker > pM;
hr = pEm->Next( 1, &pM, &ulFetched );
if( hr != S_OK )
break;
//get the property bag interface from the moniker
CComPtr< IPropertyBag >pBag;
hr = pM->BindToStorage( 0, 0, IID_IPropertyBag, (void**)&pBag );
if( hr != S_OK )
{
pBag.Release();
continue;
}

//retrieve the name of the device
CComVariant var;
var.vt = VT_BSTR;
hr = pBag->Read(L"FriendlyName", &var, NULL );
if( hr != S_OK )
{
SysFreeString(var.bstrVal);
pBag.Release();
continue;
}

//is this ActiveUSB filter?
if( !memcmp( W2CA(var.bstrVal), "USB3 Vision compliant camera", 26 ) )
{
hr = pM->BindToObject( 0, 0, IID_IBaseFilter, (void**)pFilter );
}
noCapDevice++;
pM.Release();
pBag.Release();
SysFreeString( var.bstrVal );
}
pEm.Release();