Initialization Sequence for Camera Drivers (Windows Embedded CE 6.0)
1/6/2010
The initialization sequence for camera devices is as follows:
All camera drivers must be registered under the same GUID. The following code shows the stream interface driver registry entry for a camera driver.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\CameraDriver] "Prefix"="<Driver prefix>" "Dll"="<Driver DLL name>" "Order"=dword:10 "Index"=dword:1 "IClass"=multi_sz: "{CB998A05-122C-4166-846A-933E4D7E3C86}"
The Windows Embedded CE Device Manager loads the camera driver and calls the driver's entry point, CAM_Init. Upon receiving the call, the camera driver detects and initializes the hardware, allocates and initializes its data structures, and returns device instance identifier. This device identifier will be used in subsequent calls to CAM_Open.
DirectShow calls CreateFile using the appropriate device name. Applications should use FindFirstDevice to retrieve the actual name based on the appropriate device class GUID. For more information, see Capture Device Selection.
DirectShow queries the camera driver for the number of pins it supports using CSPROPERTY_PIN_CTYPES (see CSPROPERTY_PIN). It then queries for the type (preview, capture, or still) of each of these pins using CSPROPERTY_PIN_CATEGORY.
DirectShow queries the camera driver for the name of the pin device using CSPROPERTY_PIN_DEVICENAME. This will commonly be PIN1:, but drivers are free to use whatever name they wish.
DirectShow calls CreateFile on the pin driver for each pin type the camera driver supports.
The driver initializes the stream by setting its properties and data formats and by allocating buffers for it.
The client sets the stream type for the given pin handle using IOCTL_STREAM_INSTANTIATE by passing, as input, the identifier of the pin and a handle to the message queue that will be used for transferring asynchronous bundles between the driver and the DirectShow middleware. For example, if CSPROPERTY_PIN_CTYPES returned 3 and if the CSPROPERTY_PIN_CATEGORY for Id = 0 returned PINNAME_VIDEO_PREVIEW, then calling IOCTL_STREAM_INSTANTIATE with PinId = 0 would associate the given handle to preview stream.
Begin streaming data through the pins
From the perspective of the camera driver, there are at least two objects to instantiate: one for the adapter and one for the stream. If the camera supports more than one stream then driver must instantiate additional pins. The camera adapter entry points are referred to as CAM_XXX and stream entry points are referred to as PIN_XXX. For a complete list of entry point functions, see Camera Driver Functions.