I am using a source filter of a webcam. When I use the filter in graphstudio it has two output pins. However in code the call to IEnumPins->next always returns S_FALSE. I also looked for another interface that could create pins but didn't find such a thing.
How do I add pins to the webcam filter? If they're available in graphstudio they should be in code too, right?
Here is my code.. I checked for return values and returned them if they are not ok. But everything seems to work fine except that the webcam filter doesn't return any pins
CoInitialize(NULL);
IGraphBuilder* graphBuilder = NULL;
IMediaControl* mediaControl = NULL;
IMediaEvent* mediaEvent = NULL;
HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IFilterGraph, (void **)&graphBuilder);
HANDLE fileHandle = CreateFile(L"D:\\TEMP\\debug1.log", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL);
graphBuilder->SetLogFile((DWORD_PTR)fileHandle);
graphBuilder->QueryInterface(IID_IMediaControl, (void **)&mediaControl);
graphBuilder->QueryInterface(IID_IMediaEvent, (void **)&mediaEvent);
IBaseFilter* source = NULL;
static const GUID CLSID_Webcam =
{ 0x17CCA71B, 0xECD7, 0x11D0, { 0xB9, 0x08, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 } };
hr = CoCreateInstance(CLSID_Webcam, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&source);
if (FAILED(hr))
return hr;
hr = graphBuilder->AddFilter(source, L"logitech");
if (FAILED(hr))
return hr;
IPin* camOut = GetPin(source, PINDIR_OUTPUT);
...
The GetPin function uses EnumPins method to find pin:
IPin *GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir)
{
BOOL bFound = FALSE;
IEnumPins *pEnum;
IPin *pPin;
pFilter->EnumPins(&pEnum);
while (pEnum->Next(1, &pPin, 0) == S_OK)
{
PIN_DIRECTION PinDirThis;
pPin->QueryDirection(&PinDirThis);
if (bFound = (PinDir == PinDirThis))
break;
pPin->Release();
}
pEnum->Release();
return (bFound ? pPin : 0);
}
Also, I don't think that this is 32/64bit problem. I compile to x64 and I also used the 64bit version of graphstudionext. And i also made sure that the guid of the webcam filter is correct. (At least if you can trust graphstudionext)