r870: Merge 2.1:
[cinelerra_cv.git] / cinelerra / vdevicebuz.h
blobecf47fb60cac0d85aa0a3d218aafb4d07c8bfb33
1 #ifndef VDEVICEBUZ_H
2 #define VDEVICEBUZ_H
4 #include "buz.h"
5 #include "channel.inc"
6 #include "condition.inc"
7 #include "guicast.h"
8 #include "libmjpeg.h"
9 #include "mutex.inc"
10 #include "thread.h"
11 #include "vdevicebase.h"
12 #include "vdevicebuz.inc"
13 #include "vframe.inc"
16 #define INPUT_BUFFER_SIZE 0x40000
18 // Let's get real. The Buz driver doesn't work. If the buffers overflow
19 // for enough time it locks up and can't be recovered except by a
20 // SIGINT and restart. We need to cascade the buffer reading in another
21 // ring buffer thread, have it read continuously, and cancel it if it
22 // dies. How about if we do this in SCHED_RR and wait for it to die before
23 // implementing cancellation?
26 class VDeviceBUZInput : public Thread
28 public:
29 VDeviceBUZInput(VDeviceBUZ *device);
30 ~VDeviceBUZInput();
31 void start();
32 void run();
33 void get_buffer(char **ptr, int *size);
34 void put_buffer();
35 void increment_counter(int *counter);
36 void decrement_counter(int *counter);
37 VDeviceBUZ *device;
39 char **buffer;
40 int *buffer_size;
41 int total_buffers;
42 int current_inbuffer;
43 int current_outbuffer;
44 Condition *output_lock;
45 Mutex *buffer_lock;
46 int done;
50 class VDeviceBUZ : public VDeviceBase
52 public:
53 VDeviceBUZ(VideoDevice *device);
54 ~VDeviceBUZ();
56 friend class VDeviceBUZInput;
58 int open_input();
59 int open_output();
60 int close_all();
61 int read_buffer(VFrame *frame);
62 int write_buffer(VFrame *frames, EDL *edl);
63 int reset_parameters();
64 ArrayList<int>* get_render_strategies();
65 int set_channel(Channel *channel);
66 int get_norm(int norm);
67 static void get_inputs(ArrayList<Channel*> *input_sources);
68 int set_picture(PictureConfig *picture);
69 int get_best_colormodel(int colormodel);
70 void create_channeldb(ArrayList<Channel*> *channeldb);
71 void new_output_buffer(VFrame *output, int colormodel);
74 private:
75 int open_input_core(Channel *channel);
76 int close_input_core();
77 int open_output_core(Channel *channel);
78 int close_output_core();
80 int jvideo_fd;
81 char *input_buffer, *frame_buffer, *output_buffer;
82 long frame_size, frame_allocated;
83 int input_error;
84 // quicktime_mjpeg_hdr jpeg_header;
85 long last_frame_no;
86 ArrayList<int> render_strategies;
87 // Temporary frame for compressing output data
88 VFrame *temp_frame;
89 // Frame given to user to acquire data
90 VFrame *user_frame;
91 mjpeg_t *mjpeg;
92 Mutex *tuner_lock;
93 VDeviceBUZInput *input_thread;
95 struct buz_params bparm;
96 struct buz_requestbuffers breq;
97 // Can't CSYNC the first loop
98 int total_loops;
99 // Number of output frame to load
100 int output_number;
102 int brightness;
103 int hue;
104 int color;
105 int contrast;
106 int whiteness;
109 #endif