xxxxx@gmail.com wrote:
Can the UVC driver drop video frames, if the Application doesn’t request it in time ? (say if thread is suspended for a time). i.e Once DMA is complete and the frame is in memory, is it guaranteed that the data reaches the application ?
Usbvideo.sys circulates its own pair of buffers to the device and back,
and copies from there to the user-mode buffers. If there is no empty
user-mode buffer waiting when a request is completed, then the data in
that request is lost. There is no buffering within the driver.
For most formats, each user-mode buffers is an entire frame, so you
aren’t going to run dry in mid-frame. If you have a buffer ready when
the first request for a new frame completes, then you’ll get that
frame. Otherwise, you’ll miss that frame.
Really, there’s no other way to do it.
A related question: Does the UVC driver send the most recent captured frame or is it a pull based model where the application uses media foundation to request a sample and that corresponds to one IRP and a single frame received by the Class driver.
It’s certainly not “one buffer == one IRP”. In DirectShow and Kernel
Streaming (and Media Foundation), the fundamental memory unit in the
graph is the frame. Each buffer is large enough to hold an entire frame.
But at the USB level, requests have to be managed in even multiples of
the endpoint’s packet size. That’s why usbvideo allocates its own pair
of buffers to circulate to the device. Each request is large enough to
hold a millisecond worth of data.
When the graph (or MF topology) starts up, the graph manager allocates a
certain number of empty buffers. The capture driver can suggest an
appropriate number, but it’s a negotiation. It sends those empty
buffers to the driver, where they are queued up. When the driver gets a
completion notice from the device, it pulls the next empty buffer from
the queue (called “the stream leading edge” in KS terms), and copies the
data into it.
So, there is continuous data exchange between usbvideo and the video
device, but data is only copies to the user mode app if an empty buffer
is waiting. There is no buffering anywhere in the USB stack. If you’re
ready when data arrives, you get it. Otherwise, you don’t.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.