r820: Move from x-devb to xorg-dev
[cinelerra_cv/mob.git] / cinelerra / vdevicev4l2.h
blob0eb174ad78011335326dff8c22014159b27b80a0
1 #ifndef VDEVICEV4L2_H
2 #define VDEVICEV4L2_H
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif
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
27 public:
28 VDeviceV4L2Thread(VideoDevice *device, int color_model);
29 ~VDeviceV4L2Thread();
31 void start();
32 void run();
33 VFrame* get_buffer(int *timed_out);
34 void put_buffer();
35 void allocate_buffers(int number);
37 Mutex *buffer_lock;
38 // Some of the drivers in 2.6.7 can't handle simultaneous QBUF and DQBUF calls.
39 Mutex *ioctl_lock;
40 Condition *video_lock;
41 VideoDevice *device;
42 VFrame **device_buffers;
43 int *buffer_valid;
44 int total_valid;
45 int total_buffers;
46 int current_inbuffer;
47 int current_outbuffer;
48 // Don't block if first frame not recieved yet.
49 // This frees up the GUI during driver initialization.
50 int first_frame;
51 int done;
52 int input_fd;
53 // COMPRESSED or another color model the device should use.
54 int color_model;
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
63 public:
64 VDeviceV4L2Put(VDeviceV4L2Thread *thread);
65 ~VDeviceV4L2Put();
66 void run();
67 // Release buffer for capturing.
68 void put_buffer(int number);
69 VDeviceV4L2Thread *thread;
70 // List of buffers to requeue
71 Mutex *lock;
72 Condition *more_buffers;
73 int *putbuffers;
74 int total;
75 int done;
80 class VDeviceV4L2 : public VDeviceBase
82 public:
83 VDeviceV4L2(VideoDevice *device);
84 ~VDeviceV4L2();
86 int close_all();
87 int open_input();
88 int initialize();
89 int get_best_colormodel(Asset *asset);
90 int read_buffer(VFrame *frame);
91 int has_signal();
92 static int cmodel_to_device(int color_model);
93 static int get_sources(VideoDevice *device,
94 char *path);
96 VDeviceV4L2Thread *thread;
99 #endif
100 #endif