I'm using two DirectShow graphs, running on separate threads, to display streaming video (using VMR 9 on a seperate) and capture frames (using Sample Grabber) from two webcams. One of them is a built-in webcam (HP TrueVision HD) and the other is a Creative VF0520 connected to a USB port. None of the other USB ports are in use.
The problem is that the Creative camera turns on (LED lights up), but no stream comes through. The problem persists even if I disabled the built-in webcam. However, the Creative cam works if running on a desktop where the Creative cam is the only camera connected.
The program works when each camera is the only one connected (the Creative VF0520 works when it is the only camera connected to a desktop), but when two cameras are connected, video display and frame-grabbing only work for the built-in webcam.
I suspect the problem may arise from moniker-binding with capture filters. I am using modified code from MSDN. Is this the correct way to bind monikers to capture filters for multiple cameras?
ULONG VideoPlayer::GetMonikers(IEnumMoniker *pEnum, std::vector<IMoniker *> *pListMonikers)
{
ULONG numRetrieved = 0;
IMoniker* pMoniker = NULL;
while (pEnum->Next(1, &pMoniker, &numRetrieved) == S_OK)
{
// Bind to vector
pListMonikers->push_back(pMoniker);
IPropertyBag *pPropBag;
HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
if (FAILED(hr))
{
(*ppMoniker)->Release();
continue;
}
// Get information to display
pPropBag->Release();
}
return numRetrieved;
}
The vector containing the monikers is then accessed to bind to the capture filter:
hr = listMonikers[CAMERA_ID]->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pCap);