no longer need ffmpeg patch0 which was for Termux
[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  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #ifndef RECORDMONITOR_H
24 #define RECORDMONITOR_H
25
26 #ifdef HAVE_FIREWIRE
27 #include "avc1394transport.h"
28 #endif
29 #include "bcdialog.h"
30 #include "canvas.h"
31 #include "channelpicker.inc"
32 #include "condition.inc"
33 #include "guicast.h"
34 #include "channelpicker.inc"
35 #include "libmjpeg.h"
36 #include "meterpanel.inc"
37 #include "preferences.inc"
38 #include "record.inc"
39 #include "recordgui.inc"
40 #include "recordscopes.inc"
41 #include "recordtransport.inc"
42 #include "recordmonitor.inc"
43 #include "signalstatus.inc"
44 #include "videodevice.inc"
45
46 class RecordMonitorThread;
47
48 class RecordMonitor : public Thread
49 {
50 public:
51         RecordMonitor(MWindow *mwindow, Record *record);
52         ~RecordMonitor();
53
54 // Show a frame
55         int update(VFrame *vframe);
56 // Update channel textbox
57         void update_channel(char *text);
58
59         MWindow *mwindow;
60         Record *record;
61 // Thread for slippery monitoring
62         RecordMonitorThread *thread;
63         RecordMonitorGUI *window;
64         VideoDevice *device;
65 // Fake config for monitoring
66         VideoOutConfig *config;
67
68         RecordScopeThread *scope_thread;
69
70         void run();
71         void close_threads();   // Stop all the child threads on exit
72         void create_objects();
73         void fix_size(int &w, int &h, int width_given, float aspect_ratio);
74         float get_scale(int w);
75         int get_mbuttons_height();
76         int get_canvas_height();
77         int get_channel_x();
78         int get_channel_y();
79         void reconfig();
80         void redraw();
81         void start_playback();
82         void stop_playback();
83         void display_vframe(VFrame *in, int x, int y,
84                 int alpha, double secs, double scale);
85         void undisplay_vframe();
86 };
87
88 class ReverseInterlace;
89 class RecordMonitorCanvas;
90 class DoCursor;
91 class DoBigCursor;
92
93 class RecordMonitorGUI : public BC_Window
94 {
95 public:
96         RecordMonitorGUI(MWindow *mwindow, Record *record,
97                 RecordMonitor *thread, int min_w);
98         ~RecordMonitorGUI();
99
100         void create_objects();
101         int cursor_leave_event();
102         int cursor_enter_event();
103         int button_release_event();
104         int cursor_motion_event();
105
106         void display_video_text(int x, int y, const char *text, int font,
107                 int bg_color, int color, int alpha, double secs, double scale);
108         void enable_signal_status(int enable);
109
110         MeterPanel *meters;
111         RecordMonitorCanvas *canvas;
112 //      RecordTransport *record_transport;
113 #ifdef HAVE_FIREWIRE
114         AVC1394Transport *avc1394_transport;
115         AVC1394TransportThread *avc1394transport_thread;
116 #endif
117         RecordChannelPicker *channel_picker;
118         ScopeEnable *scope_toggle;
119         DoCursor *cursor_toggle;
120         DoBigCursor *big_cursor_toggle;
121         ReverseInterlace *reverse_interlace;
122         int cursor_x_origin, cursor_y_origin;
123         int translate_x_origin, translate_y_origin;
124         BC_PopupMenu *monitor_menu;
125         int current_operation;
126
127
128         int translation_event();
129         int button_press_event();
130         int resize_event(int w, int h);
131         int redraw();
132         int set_title();
133         int close_event();
134         int create_bitmap();
135         int keypress_event();
136
137         MWindow *mwindow;
138         BC_SubWindow *mbuttons;
139         BC_Bitmap *bitmap;
140         RecordMonitor *thread;
141         Record *record;
142 #ifdef HAVE_FIREWIRE
143         AVC1394Control *avc;
144         BC_Title *avc1394transport_title;
145         BC_Title *avc1394transport_timecode;
146 #endif
147         SignalStatus *signal_status;
148 };
149
150
151 class RecVideoMJPGThread;
152 class RecVideoDVThread;
153 class RecVideoOverlay;
154
155 class RecordMonitorThread : public Thread
156 {
157         void show_output_frame();
158         void render_uncompressed();
159         int render_jpeg();
160         int render_dv();
161         void process_scope();
162         void process_hist();
163
164         int ready;   // Ready to receive the next frame
165         int done;
166         RecVideoMJPGThread *jpeg_engine;
167         RecVideoDVThread *dv_engine;
168 public:
169         RecordMonitorThread(MWindow *mwindow,
170                 Record *record,
171                 RecordMonitor *record_monitor);
172         ~RecordMonitorThread();
173
174         void reset_parameters();
175         void run();
176 // Calculate the best output format based on input drivers
177         void init_output_format();
178         int start_playback();
179         int stop_playback();
180         int write_frame(VFrame *new_frame);
181         int render_frame();
182         void lock_input();
183         void unlock_input();
184         void new_output_frame();
185         void display_vframe(VFrame *in, int x, int y,
186                 int alpha, double secs, double scale);
187         void undisplay_vframe();
188         int finished() { return done; }
189
190 // Input frame being rendered
191         VFrame *input_frame;
192 // Frames for the rendered output
193         VFrame *output_frame;
194 // Best color model given by device
195         int output_colormodel;
196 // Block until new input data
197         Condition *output_lock;
198         Condition *input_lock;
199         Record *record;
200         RecordMonitor *record_monitor;
201         MWindow *mwindow;
202 // If the input frame is the same data that the file handle uses
203         int shared_data;
204 // overlay data
205         RecVideoOverlay *ovly;
206 };
207
208 class RecordMonitorFullsize : public BC_MenuItem
209 {
210 public:
211         RecordMonitorFullsize(MWindow *mwindow, RecordMonitorGUI *window);
212
213         int handle_event();
214         MWindow *mwindow;
215         RecordMonitorGUI *window;
216 };
217
218 class RecordMonitorCanvas : public Canvas
219 {
220 public:
221         RecordMonitorCanvas(MWindow *mwindow, RecordMonitorGUI *window,
222                 Record *record, int x, int y, int w, int h);
223         ~RecordMonitorCanvas();
224
225         void create_objects(EDL *edl);
226         void zoom_resize_window(float percentage);
227         int button_press_event();
228         int button_release_event();
229         int cursor_motion_event();
230         int cursor_enter_event();
231         void reset_translation();
232         int keypress_event();
233         int keypress_event(RecordMonitorGUI *window);
234         int get_output_w();
235         int get_output_h();
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