Jack Buffington

After wading through Directshow in a smaller test program I am now integrating the working and tested code that I came up with into the main code that I am writing. I have hit a wall on this one though. I can create a filter graph and add filters to it and am not getting any errors but I have to add a video input device and and a crossbar. I am currently searching the system for them so that I can hopefully work with any video device that happens to be connected to the computer. My code is failing in this section. I am creating a system device enumerator successfully and creating a class enumerator but when I try to iterate through the various devices it fails.

The specific line that is causing the problem is:
hr = pEnum->Next(1, &pMoniker, NULL);

Alternately, I have tried:
hr = pEnum->Next(1, &pMoniker, &junkULONG);


I have tried putting the line inside of a try block and it is catching the error properly but when I call GetLastError I get a return value which means no error.

Does anyone have any ideas about what might be going wrong

Thanks,

-Jack


Re: DirectShow Development Problems with enumerating filters

Bowljoman

I forget where in the docs I read that next will return sok, meaning it successfully queried for the next device, even though there is no device present the query is ok.

Its the binding that will fail if the object is not present.

check out the AutoCap class from my fun page.

http://saladbowlguitar.com/code/





Re: DirectShow Development Problems with enumerating filters

rajesh_directshow

Hi try the while loop like

IMoniker *pMoniker = NULL;
ULONG cFetched;
while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
{

//write your code to read all devices by giving friendly name

}






Re: DirectShow Development Problems with enumerating filters

Jack Buffington

As it turns out, this was the line that was causing the program to fail but the problem was actually a line earlier in the program where I was creating an enumerator for video input devices. I was checking for success in the way that all of the reference code showed but that turns out to be incorrect. The reference code uses SUCCEEDED but really I needed to check for S_OK. Someone here turned off the power to my external capture device but it is in a location where I can't see the power light. The function returned true for SUCCEEDED because there were no errors executing that code but S_OK would be false because it didn't find any capture devices. If the device had been turned on then my code would have run properly. Because it wasn't turned on I learned something and can now tell the user that no input devices were found.

-Jack