Hi, Finally I have returned... Sorry for delayed response. I know if I use AddFilter to add to the capture graph, I can tell whether the device is there. However, I think that means I have to disrupt it, i.e., eliminate it from the capture graph and then reconnect it. That would interrupt the video. I tried your suggestion but it answers S_OK even when the camera is not attached! Like I said, this is a pathological case caused by the method used by this older QuickCam. It is set up so that you have to use "Unplug or Eject Hardware" to make the driver go away. Newer systems handle this automatically. Wonder if I can figure out what the "Unplug or Eject Hardware" function is doing? If I could, then maybe I could use that to determine the status. I will continue looking at functions that might be used to determine status. Your idea gave me some other ideas to try... Thanks, Howard Howard C. Anderson HTTP://www.astroshow.com
Howard Anderson
Posts
-
Enumerate (list) USB Webcams -
Enumerate (list) USB WebcamsI need to be able to list webcams that are plugged in. I can use DeviceChange to tell when a webcam is plugged or unplugged and I am then using the function shown below to create a list of all video devices. This works for all "normal" webcam devices since they appear and disappear from the list when I call the function after they are plugged in or unplugged. Unfortunately, I also have an older webcam, Logitech "Quickcam", that is ALWAYS listed regardless of whether it is plugged in or not... That represents a pathological case. I need a way to determine if it is really plugged in WITHOUT disrupting it in case my software is currently using it. I have scoured all 5 device driver and USB books I know of, scoured MSDN, scoured the internet, tried LOTS of code including USBView which ALMOST provides the information but DISPLAYS A DIFFERENT NAME (not the "FriendlyName" I expected!) so I cannot correlate the information. Anyone know of a solution? (I think this is a REALLY tough problem... I will be unavailable for a couple of weeks but I really need to find a solution and will respond as soon as possible...) VideoDeviceList *CMotionDetectDlg::GetVideoDeviceList() { static VideoDeviceList VideoList; USES_CONVERSION; UINT uIndex = 0; HRESULT hr; BOOL bCheck = FALSE; //Clear all previous video list entries for(int i = 0; i < NUMELMS(VideoList.videoMoniker); i++) { if(VideoList.videoMoniker[i]){ VideoList.videoMoniker[i]->Release(); VideoList.videoMoniker[i] = NULL; } } VideoList.videoString.RemoveAll(); VideoList.numberOfDevices = 0; // enumerate all video capture devices ICreateDevEnum *pCreateDevEnum = 0; hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum); if(hr != NOERROR) { MessageBox(NULL, "Error Creating Device Enumerator"); return NULL; } IEnumMoniker *pEm = 0; hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEm, 0); if(hr != NOERROR) { CString message; message = CString("No Video capture device was found.\r\n\r\n") + CString("Please plug in a webcam or other video capture device."); //MessageBox(message, "Notice"); if(pEm)pEm->Release(); return NULL; } pEm->Reset(); ULONG cFetched; IMoniker *pM; while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK) { IPropertyBag *pBag=0; hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag); if(SUCCEEDED(hr)) { //VARIANT vardes; //vardes.vt = VT_BSTR; //hr = pBag->Read(L"Description", &vardes, NULL);
-
Enumerate (list) USB webcamsI need to be able to list webcams that are plugged in. I can use DeviceChange to tell when a webcam is plugged or unplugged and I am then using the function shown below to create a list of all video devices. This works for all "normal" webcam devices since they appear and disappear from the list when I call the function after they are plugged in or unplugged. Unfortunately, I also have an older webcam, Logitech "Quickcam", that is ALWAYS listed regardless of whether it is plugged in or not... That represents a pathological case. I need a way to determine if it is really plugged in WITHOUT disrupting it in case my software is currently using it. I have scoured all 5 device driver and USB books I know of, scoured MSDN, scoured the internet, tried LOTS of code including USBView which ALMOST provides the information but DISPLAYS A DIFFERENT NAME (not the "FriendlyName" I expected!) so I cannot correlate the information. Anyone know of a solution? (I think this is a REALLY tough problem... I will be unavailable for a couple of weeks but I really need to find a solution and will respond as soon as possible...) VideoDeviceList *CMotionDetectDlg::GetVideoDeviceList() { static VideoDeviceList VideoList; USES_CONVERSION; UINT uIndex = 0; HRESULT hr; BOOL bCheck = FALSE; //Clear all previous video list entries for(int i = 0; i < NUMELMS(VideoList.videoMoniker); i++) { if(VideoList.videoMoniker[i]){ VideoList.videoMoniker[i]->Release(); VideoList.videoMoniker[i] = NULL; } } VideoList.videoString.RemoveAll(); VideoList.numberOfDevices = 0; // enumerate all video capture devices ICreateDevEnum *pCreateDevEnum = 0; hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum); if(hr != NOERROR) { MessageBox(NULL, "Error Creating Device Enumerator"); return NULL; } IEnumMoniker *pEm = 0; hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEm, 0); if(hr != NOERROR) { CString message; message = CString("No Video capture device was found.\r\n\r\n") + CString("Please plug in a webcam or other video capture device."); //MessageBox(message, "Notice"); if(pEm)pEm->Release(); return NULL; } pEm->Reset(); ULONG cFetched; IMoniker *pM; while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK) { IPropertyBag *pBag=0; hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag); if(SUCCEEDED(hr)) { //VARIA