Transferring Streams of Captured Data
Video capture drivers must provide the capability of handling video capture input streams. Video capture drivers do not support output streams. Output streams are handled by Video Compression Manager drivers.
To transfer a stream of captured video input data, a client must:
1.Establish settings for video format, source or destination rectangles, and color palettes.
2.Initialize the appropriate video channels.
3.Allocate data buffers, prepare them for use, and pass them to the driver to be filled.
4.Request the driver to start filling and returning the data buffers.
5.Copy data from the buffers and pass them back to the driver for re-use.
6.Request the driver to end the transfer operation.
The first streaming message a user-mode video capture driver should receive a is DVM_STREAM_INIT, along with a channel specification. The following table lists the operations that a driver should perform, based on the specified channel.
Channel | Operation to Perform for DMV_STREAM_INIT Message |
VIDEO_EXTERNALIN | Set up hardware to allow capture operations. |
VIDEO_IN | Save client-specified capture rate and event notification information. |
VIDEO_OUT | Not used. |
VIDEO_EXTERNALOUT | Set up hardware to allow overlay operations. |
Clients dynamically allocate buffers to receive captured data. Before a client can use a data buffer in a streaming operation, it must pass the buffer's address to the user-mode driver by calling DVM_STREAM_PREPAREHEADER, so the driver can prepare the buffer for use. The client then sends a DVM_STREAM_ADDBUFFER message for each prepared buffer, which requests the driver to add the buffer's address to a queue of buffers waiting to be filled.
To start the input operation, the clients sends a DVM_STREAM_START message. The user-mode driver passes the request to the kernel-mode driver, which causes input operations to begin, typically by enabling device interrupts so that an interrupt occurs each time the frame buffer has been filled. Each time the frame buffer is filled, its contents are copied into the next available client buffer. The user-mode driver then sends the client an MM_DRVM_DATA callback message. The client copies the data from the buffer and re-adds the buffer to the user-mode driver's buffer queue by sending another DVM_STREAM_ADDBUFFER message. The client can send a DVM_STREAM_GETERROR message to determine if the driver has dropped any captured frames because of a lack of available buffers.
When the client is ready to stop the input stream, it sends a DVM_STREAM_STOP message. It can also send DVM_STREAM_RESET, which indicates to the user-mode driver that it should not fill any remaining data buffers. The client can then send a DVM_STREAM_UNPREPAREHEADER message for each buffer and de-allocate the buffers. Finally, the client sends a DVM_STREAM_FINI message to close the streaming session.
For all stream messages except DVM_STREAM_INIT and DVM_STREAM_FINI, the client-specified channel should always be VIDEO_IN.