Click to Rate and Give Feedback
MSDN
MSDN Library
Encoded Media
DirectShow
Video Capture
 Capture Device Selection

  Switch on low bandwidth view
Capture Device Selection
Windows Mobile SupportedWindows Embedded CE Supported
8/28/2008

A Windows Embedded CE-based device can supports more than one capture (camera) device. You can enumerate all the capture devices through calls to FindFirstDevice and FindNextDevice. In your call to FindFirstDevice, set the searchType set to DeviceSearchByGuid and pvSearchParam set 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 FindNextDevice to locate all of the available capture devices. The following code shows how to

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 szLegacyName member of the DEVMGR_DEVICE_INFORMATION structure returned by FindFirstDevice or 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 IPropertyBag interface.

// 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.

Concepts

Video Capture

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker