repair selected_to_clipboard bug
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / recordmonitor.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef RECORDMONITOR_H
23 #define RECORDMONITOR_H
24
25 #ifdef HAVE_FIREWIRE
26 #include "avc1394transport.h"
27 #endif
28 #include "bcdialog.h"
29 #include "canvas.h"
30 #include "channelpicker.inc"
31 #include "condition.inc"
32 #include "guicast.h"
33 #include "channelpicker.inc"
34 #include "libmjpeg.h"
35 #include "meterpanel.inc"
36 #include "preferences.inc"
37 #include "record.inc"
38 #include "recordgui.inc"
39 #include "recordscopes.inc"
40 #include "recordtransport.inc"
41 #include "recordmonitor.inc"
42 #include "signalstatus.inc"
43 #include "videodevice.inc"
44
45 class RecordMonitorThread;
46
47 class RecordMonitor : public Thread
48 {
49 public:
50         RecordMonitor(MWindow *mwindow, Record *record);
51         ~RecordMonitor();
52
53 // Show a frame
54         int update(VFrame *vframe);
55 // Update channel textbox
56         void update_channel(char *text);
57
58         MWindow *mwindow;
59         Record *record;
60 // Thread for slippery monitoring
61         RecordMonitorThread *thread;
62         RecordMonitorGUI *window;
63         VideoDevice *device;
64 // Fake config for monitoring
65         VideoOutConfig *config;
66
67         RecordScopeThread *scope_thread;
68
69         void run();
70         void close_threads();   // Stop all the child threads on exit
71         void create_objects();
72         void fix_size(int &w, int &h, int width_given, float aspect_ratio);
73         float get_scale(int w);
74         int get_mbuttons_height();
75         int get_canvas_height();
76         int get_channel_x();
77         int get_channel_y();
78         void reconfig();
79         void redraw();
80         void start_playback();
81         void stop_playback();
82         void display_vframe(VFrame *in, int x, int y,
83                 int alpha, double secs, double scale);
84         void undisplay_vframe();
85 };
86
87 class ReverseInterlace;
88 class RecordMonitorCanvas;
89 class DoCursor;
90 class DoBigCursor;
91
92 class RecordMonitorGUI : public BC_Window
93 {
94 public:
95         RecordMonitorGUI(MWindow *mwindow, Record *record,
96                 RecordMonitor *thread, int min_w);
97         ~RecordMonitorGUI();
98
99         void create_objects();
100         int cursor_leave_event();
101         int cursor_enter_event();
102         int button_release_event();
103         int cursor_motion_event();
104
105         void display_video_text(int x, int y, const char *text, int font,
106                 int bg_color, int color, int alpha, double secs, double scale);
107         void enable_signal_status(int enable);
108
109         MeterPanel *meters;
110         Canvas *canvas;
111 //      RecordTransport *record_transport;
112 #ifdef HAVE_FIREWIRE
113         AVC1394Transport *avc1394_transport;
114         AVC1394TransportThread *avc1394transport_thread;
115 #endif
116         RecordChannelPicker *channel_picker;
117         ScopeEnable *scope_toggle;
118         DoCursor *cursor_toggle;
119         DoBigCursor *big_cursor_toggle;
120         ReverseInterlace *reverse_interlace;
121         int cursor_x_origin, cursor_y_origin;
122         int translate_x_origin, translate_y_origin;
123         BC_PopupMenu *monitor_menu;
124         int current_operation;
125
126
127         int translation_event();
128         int button_press_event();
129         int resize_event(int w, int h);
130         int redraw();
131         int set_title();
132         int close_event();
133         int create_bitmap();
134         int keypress_event();
135
136         MWindow *mwindow;
137         BC_SubWindow *mbuttons;
138         BC_Bitmap *bitmap;
139         RecordMonitor *thread;
140         Record *record;
141 #ifdef HAVE_FIREWIRE
142         AVC1394Control *avc;
143         BC_Title *avc1394transport_title;
144         BC_Title *avc1394transport_timecode;
145 #endif
146         SignalStatus *signal_status;
147 };
148
149
150 class RecVideoMJPGThread;
151 class RecVideoDVThread;
152 class RecVideoOverlay;
153
154 class RecordMonitorThread : public Thread
155 {
156         void show_output_frame();
157         void render_uncompressed();
158         int render_jpeg();
159         int render_dv();
160         void process_scope();
161         void process_hist();
162
163         int ready;   // Ready to receive the next frame
164         int done;
165         RecVideoMJPGThread *jpeg_engine;
166         RecVideoDVThread *dv_engine;
167 public:
168         RecordMonitorThread(MWindow *mwindow,
169                 Record *record,
170                 RecordMonitor *record_monitor);
171         ~RecordMonitorThread();
172
173         void reset_parameters();
174         void run();
175 // Calculate the best output format based on input drivers
176         void init_output_format();
177         int start_playback();
178         int stop_playback();
179         int write_frame(VFrame *new_frame);
180         int render_frame();
181         void lock_input();
182         void unlock_input();
183         void new_output_frame();
184         void display_vframe(VFrame *in, int x, int y,
185                 int alpha, double secs, double scale);
186         void undisplay_vframe();
187         int finished() { return done; }
188
189 // Input frame being rendered
190         VFrame *input_frame;
191 // Frames for the rendered output
192         VFrame *output_frame;
193 // Best color model given by device
194         int output_colormodel;
195 // Block until new input data
196         Condition *output_lock;
197         Condition *input_lock;
198         Record *record;
199         RecordMonitor *record_monitor;
200         MWindow *mwindow;
201 // If the input frame is the same data that the file handle uses
202         int shared_data;
203 // overlay data
204         RecVideoOverlay *ovly;
205 };
206
207 class RecordMonitorFullsize : public BC_MenuItem
208 {
209 public:
210         RecordMonitorFullsize(MWindow *mwindow, RecordMonitorGUI *window);
211
212         int handle_event();
213         MWindow *mwindow;
214         RecordMonitorGUI *window;
215 };
216
217 class RecordMonitorCanvas : public Canvas
218 {
219 public:
220         RecordMonitorCanvas(MWindow *mwindow, RecordMonitorGUI *window,
221                 Record *record, int x, int y, int w, int h);
222         ~RecordMonitorCanvas();
223
224         void zoom_resize_window(float percentage);
225         int button_press_event();
226         int button_release_event();
227         int cursor_motion_event();
228         int cursor_enter_event();
229         void reset_translation();
230         int keypress_event();
231         int get_output_w();
232         int get_output_h();
233         int get_fullscreen();
234         void set_fullscreen(int value);
235
236
237         RecordMonitorGUI *window;
238         MWindow *mwindow;
239         Record *record;
240 };
241
242 class DoCursor : public BC_CheckBox
243 {
244 public:
245         DoCursor(Record *record, int x, int y);
246         ~DoCursor();
247         int handle_event();
248         Record *record;
249 };
250
251 class DoBigCursor : public BC_CheckBox
252 {
253 public:
254         DoBigCursor(Record *record, int x, int y);
255         ~DoBigCursor();
256         int handle_event();
257         Record *record;
258 };
259
260 class ReverseInterlace : public BC_CheckBox
261 {
262 public:
263         ReverseInterlace(Record *record, int x, int y);
264         ~ReverseInterlace();
265         int handle_event();
266         Record *record;
267 };
268
269 class RecVideoMJPGThread
270 {
271 public:
272         RecVideoMJPGThread(Record *record,
273                 RecordMonitorThread *thread,
274                 int fields);
275         ~RecVideoMJPGThread();
276
277         int render_frame(VFrame *frame, long size);
278         int start_rendering();
279         int stop_rendering();
280
281         RecordMonitorThread *thread;
282         Record *record;
283
284 private:
285         mjpeg_t *mjpeg;
286         int fields;
287 };
288
289 class RecVideoDVThread
290 {
291 public:
292         RecVideoDVThread(Record *record, RecordMonitorThread *thread);
293         ~RecVideoDVThread();
294
295         int start_rendering();
296         int stop_rendering();
297         int render_frame(VFrame *frame, long size);
298
299         RecordMonitorThread *thread;
300         Record *record;
301
302 private:
303 // Don't want theme to need libdv to compile
304         void *dv;
305 };
306
307 class RecVideoOverlay
308 {
309         int x, y, ticks;
310         float scale, alpha;
311         VFrame *vframe;
312 public:
313         RecVideoOverlay(VFrame *vframe, int x, int y, int ticks, float scale, float alpha);
314         ~RecVideoOverlay();
315
316         int overlay(VFrame *out);
317 };
318
319
320 #endif