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
00020
00021
00022
00023
00024
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
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
00049
00050 int first_frame;
00051 int done;
00052 int input_fd;
00053
00054 int color_model;
00055 VDeviceV4L2Put *put_thread;
00056 };
00057
00058
00059
00060
00061 class VDeviceV4L2Put : public Thread
00062 {
00063 public:
00064 VDeviceV4L2Put(VDeviceV4L2Thread *thread);
00065 ~VDeviceV4L2Put();
00066 void run();
00067
00068 void put_buffer(int number);
00069 VDeviceV4L2Thread *thread;
00070
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