Opening and Closing a Device, Using VCUser.lib

When your user-mode driver receives a DRV_OPEN message it should call VC_OpenDevice to open a device. The following two restrictions apply to opening a video capture device:

1.A user-mode video capture driver can only allow one instance of a device to be open at time.

2.A kernel-mode video capture driver can only support one hardware device.

There are two ways to specify a device when calling VC_OpenDevice — by device name or by index number. Because a kernel-mode driver can only support one hardware device, you specify a device's name by specifying the kernel-mode driver's name, such as "bravado", without appending a device number.

Video capture device objects are assigned names of vidcap0, vidcap1, vidcap2, and so on. By specifying an index number instead of a device name, you can open any video capture device without knowing its name. For example, specifying an index of "1" opens the device "vidcap1". The sample video capture driver msyuv.dll uses this index number in order to search for a device that supports a specific data format. For more information about device objects, see the Kernel-Mode Drivers Design Guide.

Your driver receives a DRV_OPEN message for each video channel (VIDEO_EXTERNALIN, VIDEO_IN, VIDEO_OUT, VIDEO_EXTERNALOUT) that the client will be using, but VC_OpenDevice should only be called once.

If your hardware provides overlay capabilities, then prior to calling VC_OpenDevice your driver must determine characteristics of the user's display device, such as the display's horizontal and vertical resolutions, and bits per pixel. The kernel-mode driver needs this information when constructing and positioning an overlay image. The user-mode driver can obtain characteristics of the user's display device by calling GetDeviceCaps, which is described in the Win32 SDK. Your user-mode driver should call VC_WriteProfile to store the characteristics in the registry, where your kernel-mode driver can access them when needed.

Upon receipt of a DRV_CLOSE message, your driver should call VC_CloseDevice. Your driver will receive a DRV_CLOSE message for each open video channel, but VC_CloseDevice should only be called once.