Asynchronous Data Flow and Buffer Management in Camera Drivers (Windows Embedded CE 6.0)
1/6/2010
The Windows Embedded CE Camera Device Driver Interface supports asynchronous operation through the use of message queues. The client creates a message queue using CreateMsgQueue and gives the driver a handle to the object. The driver uses this queue to send video frames to the client as they are completed. The will typically use a worker thread that blocks on the queue using either WaitForSingleObject or ReadMsgQueue. The worker thread can then process the video frames as appropriate, then resubmit the buffer for re-use using IOCTL_CS_BUFFERS.
The following code provides and example of the external interface for message queuing.
CSPROPERTY_CONNECTION_STATE/CSSTATE_PAUSE
HANDLE WINAPI CreateMsgQueue(LPCWSTR lpszName,
LPMSGQUEUEOPTIONS lpOptions);
BOOL WINAPI ReadMsgQueue(HANDLE hMsgQ, LPVOID lpBuffer,
DWORD cbBufferSize,
LPDWORD lpNumberOfBytesRead,
DWORD dwTimeout, DWORD *pdwFlags);
BOOL WINAPI WriteMsgQueue(HANDLE hMsgQ, LPVOID lpBuffer,
DWORD cbDataSize, DWORD dwTimeout,
DWORD dwFlags);