8 #ifdef HAVE_VIDEO4LINUX2
10 #include "vdevicebase.h"
11 #include <linux/types.h>
12 #include <linux/videodev2.h>
13 #include "videodevice.inc"
14 #include "vdevicev4l2.inc"
18 #define BUFFER_TIMEOUT 250000
19 //#define BUFFER_TIMEOUT 1000000
22 // Isolate the application from the grabbing operation.
23 // Used by VDeviceV4L2 and VDeviceV4L2JPEG
24 // Color_model determines whether it uses compressed mode or not.
25 class VDeviceV4L2Thread
: public Thread
28 VDeviceV4L2Thread(VideoDevice
*device
, int color_model
);
33 VFrame
* get_buffer(int *timed_out
);
35 void allocate_buffers(int number
);
38 // Some of the drivers in 2.6.7 can't handle simultaneous QBUF and DQBUF calls.
40 Condition
*video_lock
;
42 VFrame
**device_buffers
;
47 int current_outbuffer
;
48 // Don't block if first frame not recieved yet.
49 // This frees up the GUI during driver initialization.
53 // COMPRESSED or another color model the device should use.
55 VDeviceV4L2Put
*put_thread
;
59 // Another thread which puts back buffers asynchronously of the buffer
60 // grabber. Because 2.6.7 drivers block the buffer enqueuer.
61 class VDeviceV4L2Put
: public Thread
64 VDeviceV4L2Put(VDeviceV4L2Thread
*thread
);
67 // Release buffer for capturing.
68 void put_buffer(int number
);
69 VDeviceV4L2Thread
*thread
;
70 // List of buffers to requeue
72 Condition
*more_buffers
;
80 class VDeviceV4L2
: public VDeviceBase
83 VDeviceV4L2(VideoDevice
*device
);
89 int get_best_colormodel(Asset
*asset
);
90 int read_buffer(VFrame
*frame
);
92 static int cmodel_to_device(int color_model
);
93 static int get_sources(VideoDevice
*device
,
96 VDeviceV4L2Thread
*thread
;