Get a frame from the video capture device.


#include <vcapture/capture.h>
int capture_get_frame( capture_context_t context,
    uint64_t timeout, uint_32_t flags )


Pointer to the video capture context.
Wait before timing out. Set to any of:
  • The number of nanoseconds the function should wait for a frame before timing out. The function may return in less time than the period specified by this argument.
  • CAPTURE_TIMEOUT_INFINITE to wait indefinitey for a frame (never time out).
  • CAPTURE_TIMEOUT_NO_WAIT to return immediately, even if there is no frame.
Flag specifying how to handled queued frames. Set to one of:
  • 0 (zero) to retrieve all queued frames in sequence.
  • CAPTURE_FLAG_LATEST_FRAME to retrieve the latest frame, discarding all the other queued frames.




The function capture_get_frame() retrieves frames from the device. If more than one frame is in the queue, depending on the behavior specified by the flags argument, this function will either retrieve all queued frames in sequence or retrieve only the latest frame, dropping the others. The function maintains the dropped frame counter.

The buffer used to get a frame is locked for exclusive use by the client app until capture_release_frame() releases it back to the capture driver.

To avoid overwriting a frame before it has been displayed, your application should use at least three capture buffers to:
  1. Call capture_get_frame() to get the index of the captured video frame.
  2. Hand the frame buffer over for display by a call to a Screen function such as screen_post_window().
  3. Call capture_get_frame() to get another frame.
  4. When the frame in Step 1 has been displayed, call capture_release_frame() to release the buffer for reuse by the capture driver.


Success: the index of the captured buffer.
An error occurred, or the function has timed out (errno is set).


The capture was disabled. This error occurs when one thread calls capture_get_frame() while capturing is enabled, then another thread disables capturing before capture_get_frame() has finished.
Invalid argument.
Hardware input or output error.
Capturing isn't possible because the client application has locked all buffers; it has not released any buffers for use by the capture library.
The request for a frame has timed out; no frame was captured.