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"
17 // Short delay is necessary whenn capturing a lousy source.
18 //#define BUFFER_TIMEOUT 250000
20 // Long delay is necessary to avoid losing synchronization due to spurrious
22 #define BUFFER_TIMEOUT 10000000
25 // Isolate the application from the grabbing operation.
26 // Used by VDeviceV4L2 and VDeviceV4L2JPEG
27 // Color_model determines whether it uses compressed mode or not.
28 class VDeviceV4L2Thread
: public Thread
31 VDeviceV4L2Thread(VideoDevice
*device
, int color_model
);
36 VFrame
* get_buffer(int *timed_out
);
38 void allocate_buffers(int number
);
41 // Some of the drivers in 2.6.7 can't handle simultaneous QBUF and DQBUF calls.
43 Condition
*video_lock
;
45 VFrame
**device_buffers
;
50 int current_outbuffer
;
51 // Don't block if first frame not recieved yet.
52 // This frees up the GUI during driver initialization.
56 // COMPRESSED or another color model the device should use.
58 VDeviceV4L2Put
*put_thread
;
62 // Another thread which puts back buffers asynchronously of the buffer
63 // grabber. Because 2.6.7 drivers block the buffer enqueuer.
64 class VDeviceV4L2Put
: public Thread
67 VDeviceV4L2Put(VDeviceV4L2Thread
*thread
);
70 // Release buffer for capturing.
71 void put_buffer(int number
);
72 VDeviceV4L2Thread
*thread
;
73 // List of buffers to requeue
75 Condition
*more_buffers
;
83 class VDeviceV4L2
: public VDeviceBase
86 VDeviceV4L2(VideoDevice
*device
);
92 int get_best_colormodel(Asset_GC asset
);
93 int read_buffer(VFrame
*frame
);
95 static int cmodel_to_device(int color_model
);
96 static int get_sources(VideoDevice
*device
,
99 VDeviceV4L2Thread
*thread
;
107 // c-file-style: "linux"