Capturing Video

Once the stream is in the KSSTATE_RUN state, the capture process begins. Based on the frame interval specified by the AvgTimePerFrame member of the KS_VIDEOINFOHEADER structure passed when the stream is opened, the stream transfers images into buffers passed through SRB_READ_DATA. Additional information about the image captured is returned in the KS_FRAME_INFO structure that is appended to the end of the KSSTREAM_HEADER structure.

The following example code obtains the appended KS_FRAME_INFO structure:

PKSSTREAM_HEADER pDataPacket = pSrb->CommandData.DataBufferArray;
PKS_FRAME_INFO pFrameInfo = (PKS_FRAME_INFO) (pDataPacket + 1); 

A minidriver should set additional information fields about the data captured, such as frames captured, frames dropped, and field polarity. The frame information is generally stored in a member of the driver-writer defined stream extension.

*pFrameInfo = pStrmEx->FrameInfo; // Get the frame info from the minidriver-defined stream extension

It is optimal to update the PictureNumber or DropCount members of KS_FRAME_INFO, KS_VBI_FRAME_INFO, or KSPROPERTY_DROPPEDFRAMES_CURRENT_S at transition into the KSSTATE_ACQUIRE state.

It is acceptable to update these members on transition from the KSSTATE_ACQUIRE state into the KSSTATE_PAUSE state.

Do not update PictureNumber or DropCount on transition from the KSSTATE_PAUSE state to the KSSTATE_RUN state or the KSSTATE_RUN state to the KSSTATE_PAUSE state.

If frames have been previously dropped, the minidriver should set the discontinuity flag and then reset its internal flag. The following code demonstrates setting the data discontinuity flag:

if (pStrmEx->fDiscontinuity) {
    pDataPacket->OptionsFlags |= KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY;
    pStrmEx->fDiscontinuity = FALSE;
}

Finally, the minidriver should relinquish control of the SRB, completing the frame capture.

CompleteStreamSRB (pSrb);