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
00019
00020
00021
00022 #define BUFFER_TIMEOUT 10000000
00023
00024
00025
00026
00027
00028 class VDeviceV4L2Thread : public Thread
00029 {
00030 public:
00031 VDeviceV4L2Thread(VideoDevice *device, int color_model);
00032 ~VDeviceV4L2Thread();
00033
00034 void start();
00035 void run();
00036 VFrame* get_buffer(int *timed_out);
00037 void put_buffer();
00038 void allocate_buffers(int number);
00039
00040 Mutex *buffer_lock;
00041
00042 Mutex *ioctl_lock;
00043 Condition *video_lock;
00044 VideoDevice *device;
00045 VFrame **device_buffers;
00046 int *buffer_valid;
00047 int total_valid;
00048 int total_buffers;
00049 int current_inbuffer;
00050 int current_outbuffer;
00051
00052
00053 int first_frame;
00054 int done;
00055 int input_fd;
00056
00057 int color_model;
00058 VDeviceV4L2Put *put_thread;
00059 };
00060
00061
00062
00063
00064 class VDeviceV4L2Put : public Thread
00065 {
00066 public:
00067 VDeviceV4L2Put(VDeviceV4L2Thread *thread);
00068 ~VDeviceV4L2Put();
00069 void run();
00070
00071 void put_buffer(int number);
00072 VDeviceV4L2Thread *thread;
00073
00074 Mutex *lock;
00075 Condition *more_buffers;
00076 int *putbuffers;
00077 int total;
00078 int done;
00079 };
00080
00081
00082
00083 class VDeviceV4L2 : public VDeviceBase
00084 {
00085 public:
00086 VDeviceV4L2(VideoDevice *device);
00087 ~VDeviceV4L2();
00088
00089 int close_all();
00090 int open_input();
00091 int initialize();
00092 int get_best_colormodel(Asset *asset);
00093 int read_buffer(VFrame *frame);
00094 int has_signal();
00095 static int cmodel_to_device(int color_model);
00096 static int get_sources(VideoDevice *device,
00097 char *path);
00098
00099 VDeviceV4L2Thread *thread;
00100 };
00101
00102 #endif
00103 #endif