Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vdevicev4l2.h

Go to the documentation of this file.
00001 #ifndef VDEVICEV4L2_H
00002 #define VDEVICEV4L2_H
00003 
00004 
00005 #ifdef HAVE_CONFIG_H
00006 #include "config.h"
00007 #endif
00008 #ifdef HAVE_VIDEO4LINUX2
00009 
00010 #include "vdevicebase.h"
00011 #include <linux/types.h>
00012 #include <linux/videodev2.h>
00013 #include "videodevice.inc"
00014 #include "vdevicev4l2.inc"
00015 
00016 
00017 
00018 #define BUFFER_TIMEOUT 250000
00019 //#define BUFFER_TIMEOUT 1000000
00020 
00021 
00022 // Isolate the application from the grabbing operation.
00023 // Used by VDeviceV4L2 and VDeviceV4L2JPEG
00024 // Color_model determines whether it uses compressed mode or not.
00025 class VDeviceV4L2Thread : public Thread
00026 {
00027 public:
00028         VDeviceV4L2Thread(VideoDevice *device, int color_model);
00029         ~VDeviceV4L2Thread();
00030 
00031         void start();
00032         void run();
00033         VFrame* get_buffer(int *timed_out);
00034         void put_buffer();
00035         void allocate_buffers(int number);
00036 
00037         Mutex *buffer_lock;
00038 // Some of the drivers in 2.6.7 can't handle simultaneous QBUF and DQBUF calls.
00039         Mutex *ioctl_lock;
00040         Condition *video_lock;
00041         VideoDevice *device;
00042         VFrame **device_buffers;
00043         int *buffer_valid;
00044         int total_valid;
00045         int total_buffers;
00046         int current_inbuffer;
00047         int current_outbuffer;
00048 // Don't block if first frame not recieved yet.
00049 // This frees up the GUI during driver initialization.
00050         int first_frame;
00051         int done;
00052         int input_fd;
00053 // COMPRESSED or another color model the device should use.
00054         int color_model;
00055         VDeviceV4L2Put *put_thread;
00056 };
00057 
00058 
00059 // Another thread which puts back buffers asynchronously of the buffer
00060 // grabber.  Because 2.6.7 drivers block the buffer enqueuer.
00061 class VDeviceV4L2Put : public Thread
00062 {
00063 public:
00064         VDeviceV4L2Put(VDeviceV4L2Thread *thread);
00065         ~VDeviceV4L2Put();
00066         void run();
00067 // Release buffer for capturing.
00068         void put_buffer(int number);
00069         VDeviceV4L2Thread *thread;
00070 // List of buffers to requeue
00071         Mutex *lock;
00072         Condition *more_buffers;
00073         int *putbuffers;
00074         int total;
00075         int done;
00076 };
00077 
00078 
00079 
00080 class VDeviceV4L2 : public VDeviceBase
00081 {
00082 public:
00083         VDeviceV4L2(VideoDevice *device);
00084         ~VDeviceV4L2();
00085 
00086         int close_all();
00087         int open_input();
00088         int initialize();
00089         int get_best_colormodel(Asset *asset);
00090         int read_buffer(VFrame *frame);
00091         int has_signal();
00092         static int cmodel_to_device(int color_model);
00093         static int get_sources(VideoDevice *device,
00094                 char *path);
00095 
00096         VDeviceV4L2Thread *thread;
00097 };
00098 
00099 #endif
00100 #endif

Generated on Sun Jan 8 13:39:01 2006 for Cinelerra-svn by  doxygen 1.4.4