r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / vdevicebuz.h
blobe4755ab30bd9711b55591324c6716491e22779a2
1 #ifndef VDEVICEBUZ_H
2 #define VDEVICEBUZ_H
4 #include "buz.h"
5 #include "channel.inc"
6 #include "guicast.h"
7 #include "libmjpeg.h"
8 #include "mutex.h"
9 #include "sema.h"
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 Sema 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<char *> *input_sources);
68 int set_picture(int brightness,
69 int hue,
70 int color,
71 int contrast,
72 int whiteness);
73 int get_best_colormodel(int colormodel);
74 void create_channeldb(ArrayList<Channel*> *channeldb);
75 void new_output_buffer(VFrame **outputs, int colormodel);
78 private:
79 int open_input_core(Channel *channel);
80 int close_input_core();
81 int open_output_core(Channel *channel);
82 int close_output_core();
84 int jvideo_fd;
85 char *input_buffer, *frame_buffer, *output_buffer;
86 long frame_size, frame_allocated;
87 int input_error;
88 // quicktime_mjpeg_hdr jpeg_header;
89 long last_frame_no;
90 ArrayList<int> render_strategies;
91 // Temporary frame for compressing output data
92 VFrame *temp_frame;
93 // Frame given to user to acquire data
94 VFrame *user_frame;
95 mjpeg_t *mjpeg;
96 Mutex tuner_lock;
97 VDeviceBUZInput *input_thread;
99 struct buz_params bparm;
100 struct buz_requestbuffers breq;
101 // Can't CSYNC the first loop
102 int total_loops;
103 // Number of output frame to load
104 int output_number;
107 #endif