tweak zoom/fullscr to remember cwdw scale after fullscr
[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         RecordMonitorCanvas *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 keypress_event(RecordMonitorGUI *window);
232         int get_output_w();
233         int get_output_h();
234
235         RecordMonitorGUI *window;
236         MWindow *mwindow;
237         Record *record;
238 };
239
240 class DoCursor : public BC_CheckBox
241 {
242 public:
243         DoCursor(Record *record, int x, int y);
244         ~DoCursor();
245         int handle_event();
246         Record *record;
247 };
248
249 class DoBigCursor : public BC_CheckBox
250 {
251 public:
252         DoBigCursor(Record *record, int x, int y);
253         ~DoBigCursor();
254         int handle_event();
255         Record *record;
256 };
257
258 class ReverseInterlace : public BC_CheckBox
259 {
260 public:
261         ReverseInterlace(Record *record, int x, int y);
262         ~ReverseInterlace();
263         int handle_event();
264         Record *record;
265 };
266
267 class RecVideoMJPGThread
268 {
269 public:
270         RecVideoMJPGThread(Record *record,
271                 RecordMonitorThread *thread,
272                 int fields);
273         ~RecVideoMJPGThread();
274
275         int render_frame(VFrame *frame, long size);
276         int start_rendering();
277         int stop_rendering();
278
279         RecordMonitorThread *thread;
280         Record *record;
281
282 private:
283         mjpeg_t *mjpeg;
284         int fields;
285 };
286
287 class RecVideoDVThread
288 {
289 public:
290         RecVideoDVThread(Record *record, RecordMonitorThread *thread);
291         ~RecVideoDVThread();
292
293         int start_rendering();
294         int stop_rendering();
295         int render_frame(VFrame *frame, long size);
296
297         RecordMonitorThread *thread;
298         Record *record;
299
300 private:
301 // Don't want theme to need libdv to compile
302         void *dv;
303 };
304
305 class RecVideoOverlay
306 {
307         int x, y, ticks;
308         float scale, alpha;
309         VFrame *vframe;
310 public:
311         RecVideoOverlay(VFrame *vframe, int x, int y, int ticks, float scale, float alpha);
312         ~RecVideoOverlay();
313
314         int overlay(VFrame *out);
315 };
316
317
318 #endif