Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
A Windows Embedded CE-based device can support more than one capture (camera) device. You can enumerate all the capture devices through calls to FindFirstDeviceand FindNextDevice. In your call to FindFirstDevice, set the searchTypeset to DeviceSearchByGuid and pvSearchParamset to DEVCLASS_CAMERA_GUID, which is the GUID value {0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E, 0x4D, 0x7E, 0x3C, 0x86}. It is possible to use other search types, but using the device class GUID is the most reliable way to find a capture device. Once you have obtained a search handle from FindFirstDevice, you can make successive calls to FindNextDeviceto locate all of the available capture devices. The following code shows how to
Copy Code | |
---|---|
GetFirstCameraDriver( WCHAR *pwzName ) { HRESULT hr = S_OK; HANDLE handle = NULL; DEVMGR_DEVICE_INFORMATION di; GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E, 0x4D, 0x7E, 0x3C, 0x86 }; if( pwzName == NULL ) { return E_POINTER; } di.dwSize = sizeof(di); handle = FindFirstDevice( DeviceSearchByGuid, &guidCamera, &di ); if(( handle == NULL ) || ( di.hDevice == NULL )) { ERR( HRESULT_FROM_WIN32( GetLastError() )); } StringCchCopy( pwzName, MAX_PATH, di.szLegacyName ); Cleanup: FindClose( handle ); return hr; } |
After choosing one of the available capture devices, you must attach it to a filter graph to read data from it. You do this by finding the capture device's name and then attaching that name to the filter graph through a property bag when you initialize the filter. A capture device's name is stored in the szLegacyNamemember of the DEVMGR_DEVICE_INFORMATIONstructure returned by FindFirstDeviceor FindNextDevice. When the filter captures data it uses the capture device name stored in the property bag to identify the source of the data.
The following code shows how to pass the name of the capture device, varCamName, to a filter through an object, PropBag, that implements an IPropertyBaginterface.
Copy Code | |
---|---|
// Initialize the video capture filter pVideoCap.CoCreateInstance( CLSID_VideoCapture ); pVideoCap.QueryInterface( &pPropertyBag ); varCamName = L"CAM1:"; if(( varCamName.vt == VT_BSTR ) == NULL ) { return E_OUTOFMEMORY; } PropBag.Write( L"VCapName", &varCamName ); pPropertyBag->Load( &PropBag, NULL ); pPropertyBag.Release(); pGraph->AddFilter( pVideoCap, L"Video capture source" ); |
The string
L"VCapName"
identifies the filter property for the name
of the video capture device.