00001 #ifndef VDEVICEBUZ_H 00002 #define VDEVICEBUZ_H 00003 00004 #include "buz.h" 00005 #include "channel.inc" 00006 #include "condition.inc" 00007 #include "guicast.h" 00008 #include "libmjpeg.h" 00009 #include "mutex.inc" 00010 #include "thread.h" 00011 #include "vdevicebase.h" 00012 #include "vdevicebuz.inc" 00013 #include "vframe.inc" 00014 00015 00016 #define INPUT_BUFFER_SIZE 0x40000 00017 00018 // Let's get real. The Buz driver doesn't work. If the buffers overflow 00019 // for enough time it locks up and can't be recovered except by a 00020 // SIGINT and restart. We need to cascade the buffer reading in another 00021 // ring buffer thread, have it read continuously, and cancel it if it 00022 // dies. How about if we do this in SCHED_RR and wait for it to die before 00023 // implementing cancellation? 00024 00025 00026 class VDeviceBUZInput : public Thread 00027 { 00028 public: 00029 VDeviceBUZInput(VDeviceBUZ *device); 00030 ~VDeviceBUZInput(); 00031 void start(); 00032 void run(); 00033 void get_buffer(char **ptr, int *size); 00034 void put_buffer(); 00035 void increment_counter(int *counter); 00036 void decrement_counter(int *counter); 00037 VDeviceBUZ *device; 00038 00039 char **buffer; 00040 int *buffer_size; 00041 int total_buffers; 00042 int current_inbuffer; 00043 int current_outbuffer; 00044 Condition *output_lock; 00045 Mutex *buffer_lock; 00046 int done; 00047 }; 00048 00049 00050 class VDeviceBUZ : public VDeviceBase 00051 { 00052 public: 00053 VDeviceBUZ(VideoDevice *device); 00054 ~VDeviceBUZ(); 00055 00056 friend class VDeviceBUZInput; 00057 00058 int open_input(); 00059 int open_output(); 00060 int close_all(); 00061 int read_buffer(VFrame *frame); 00062 int write_buffer(VFrame **frames, EDL *edl); 00063 int reset_parameters(); 00064 ArrayList<int>* get_render_strategies(); 00065 int set_channel(Channel *channel); 00066 int get_norm(int norm); 00067 static void get_inputs(ArrayList<Channel*> *input_sources); 00068 int set_picture(PictureConfig *picture); 00069 int get_best_colormodel(int colormodel); 00070 void create_channeldb(ArrayList<Channel*> *channeldb); 00071 void new_output_buffer(VFrame **outputs, int colormodel); 00072 00073 00074 private: 00075 int open_input_core(Channel *channel); 00076 int close_input_core(); 00077 int open_output_core(Channel *channel); 00078 int close_output_core(); 00079 00080 int jvideo_fd; 00081 char *input_buffer, *frame_buffer, *output_buffer; 00082 long frame_size, frame_allocated; 00083 int input_error; 00084 // quicktime_mjpeg_hdr jpeg_header; 00085 long last_frame_no; 00086 ArrayList<int> render_strategies; 00087 // Temporary frame for compressing output data 00088 VFrame *temp_frame; 00089 // Frame given to user to acquire data 00090 VFrame *user_frame; 00091 mjpeg_t *mjpeg; 00092 Mutex *tuner_lock; 00093 VDeviceBUZInput *input_thread; 00094 00095 struct buz_params bparm; 00096 struct buz_requestbuffers breq; 00097 // Can't CSYNC the first loop 00098 int total_loops; 00099 // Number of output frame to load 00100 int output_number; 00101 00102 int brightness; 00103 int hue; 00104 int color; 00105 int contrast; 00106 int whiteness; 00107 }; 00108 00109 #endif
1.4.4