Add back 2 patches for histogram and overlayframe that are working correctly and...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / batchrender.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 BATCHRENDER_H
23 #define BATCHRENDER_H
24
25 #include "arraylist.h"
26 #include "asset.inc"
27 #include "batchrender.inc"
28 #include "bcbutton.h"
29 #include "bcdialog.h"
30 #include "browsebutton.inc"
31 #include "filexml.inc"
32 #include "formattools.h"
33 #include "indexable.inc"
34 #include "keyframe.inc"
35 #include "mwindow.inc"
36 #include "preferences.inc"
37 #include "render.inc"
38 #include "timeentry.h"
39
40 enum {
41         ENABLED_COL, LABELED_COL, FARMED_COL,
42         OUTPUT_COL, EDL_COL, ELAPSED_COL,
43         BATCHRENDER_COLUMNS
44 };
45
46 class BatchRenderMenuItem : public BC_MenuItem
47 {
48 public:
49         BatchRenderMenuItem(MWindow *mwindow);
50         int handle_event();
51         MWindow *mwindow;
52 };
53
54
55
56 class BatchRenderJob
57 {
58 public:
59         BatchRenderJob(const char *tag,
60                 Preferences *preferences, int labeled, int farmed);
61         BatchRenderJob(Preferences *preferences, int labeled, int farmed);
62         BatchRenderJob(const char *tag);
63         virtual ~BatchRenderJob();
64         virtual BatchRenderJob *copy();
65         virtual void load(FileXML *file);
66         virtual void save(FileXML *file);
67         virtual int get_strategy();
68         virtual char *create_script(EDL *edl, ArrayList<Indexable *> *idxbls);
69         void copy_from(BatchRenderJob *src);
70
71         const char *tag;
72 // Source EDL to render
73         char edl_path[BCTEXTLEN];
74 // Destination file for output
75         Asset *asset;
76         int labeled, farmed;
77         int enabled;
78 // Amount of time elapsed in last render operation
79         double elapsed;
80         Preferences *preferences;
81 };
82
83
84 class BatchRenderWarnJob
85 {
86 public:
87         BatchRenderWarnJob() { no = 0; path = 0; }
88         ~BatchRenderWarnJob() { delete [] path; }
89         int no;
90         const char *path;
91 };
92
93 class BatchRenderWarnJobs : public ArrayList<BatchRenderWarnJob>
94 {
95 public:
96         BatchRenderWarnJobs() {}
97         ~BatchRenderWarnJobs() {}
98         void add(int no, const char *path) {
99                 BatchRenderWarnJob &job = append();
100                 job.no = no;  job.path = cstrdup(path);
101         }
102 };
103
104 class BatchRenderThread : public BC_DialogThread
105 {
106 public:
107         BatchRenderThread(MWindow *mwindow=0);
108         ~BatchRenderThread();
109         void handle_close_event(int result);
110         BC_Window* new_gui();
111
112         int test_edl_files();
113         int test_errmsg(BatchRenderWarnJobs &err_jobs, const char *msg, int *warn);
114         void calculate_dest_paths(ArrayList<char*> *paths,
115                 Preferences *preferences);
116         void reset(const char *path=0);
117 // Load batch rendering jobs
118         void load_jobs(char *path, Preferences *preferences);
119 // Not applicable to western civilizations
120         void save_jobs(char *path=0);
121         void load_defaults(BC_Hash *defaults);
122         void save_defaults(BC_Hash *defaults);
123 // Create path for persistent storage functions
124         char* create_path(char *string);
125         void new_job();
126         void delete_job();
127         void update_selected_edl();
128         void use_current_edl();
129 // Conditionally returns the job or the default job based on current_job
130         BatchRenderJob* get_current_job();
131         Asset* get_current_asset();
132         char* get_current_edl();
133 // For command line usage
134         void start_rendering(char *config_path, char *batch_path);
135 // For GUI usage
136         void start_rendering();
137         void stop_rendering();
138 // Highlight the currently rendering job.
139         void update_active(int number);
140         void update_done(int number, int create_list, double elapsed_time);
141         void move_batch(int src, int dst);
142         void start(int do_farmed, int do_labeled);
143         static void trap_hook(FILE *fp, void *vp);
144
145         MWindow *mwindow;
146         char batch_path[BCTEXTLEN];
147         double current_start;
148         double current_end;
149         BatchRenderJob *default_job;
150         ArrayList<BatchRenderJob*> jobs;
151         BC_Hash *boot_defaults;
152         Preferences *preferences;
153         Render *render;
154         BatchRenderGUI *gui;
155
156         static const char *column_titles[BATCHRENDER_COLUMNS];
157         static int column_widths[BATCHRENDER_COLUMNS];
158         int list_width[BATCHRENDER_COLUMNS];
159         int do_farmed;
160         int do_labeled;
161 // job being edited
162         int current_job;
163 // job being rendered
164         int rendering_job;
165         int is_rendering;
166         int warn;
167 };
168
169
170
171 class BatchRenderEDLPath : public BC_TextBox
172 {
173 public:
174         BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
175                 char *text);
176         int handle_event();
177         BatchRenderThread *thread;
178 };
179
180
181 class BatchRenderCurrentEDL : public BC_GenericButton
182 {
183 public:
184         BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
185         int handle_event();
186         BatchRenderThread *thread;
187 };
188
189
190 class BatchRenderUpdateEDL : public BC_GenericButton
191 {
192 public:
193         BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
194         int handle_event();
195         BatchRenderThread *thread;
196 };
197
198
199 class BatchRenderNew : public BC_GenericButton
200 {
201 public:
202         BatchRenderNew(BatchRenderThread *thread, int x, int y);
203         int handle_event();
204         BatchRenderThread *thread;
205 };
206
207 class BatchRenderDelete : public BC_GenericButton
208 {
209 public:
210         BatchRenderDelete(BatchRenderThread *thread, int x, int y);
211         int handle_event();
212         BatchRenderThread *thread;
213 };
214
215
216
217 class BatchRenderSaveList : public BC_GenericButton, public Thread
218 {
219 public:
220         BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
221         ~BatchRenderSaveList();
222         int handle_event();
223         BatchRenderThread *thread;
224         BC_FileBox *gui;
225         void run();
226         void stop();
227         virtual int keypress_event();
228         Mutex *startup_lock;
229 };
230
231 class BatchRenderLoadList : public BC_GenericButton, public Thread
232 {
233 public:
234         BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
235         ~BatchRenderLoadList();
236         int handle_event();
237         BatchRenderThread *thread;
238         BC_FileBox *gui;
239         void run();
240         void stop();
241         virtual int keypress_event();
242         Mutex *startup_lock;
243 };
244
245
246
247 class BatchRenderList : public BC_ListBox
248 {
249 public:
250         BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
251         int handle_event();
252         int selection_changed();
253         int column_resize_event();
254         int drag_start_event();
255         int drag_motion_event();
256         int drag_stop_event();
257         int dragging_item;
258         BatchRenderThread *thread;
259 };
260 class BatchRenderStart : public BC_GenericButton
261 {
262 public:
263         BatchRenderStart(BatchRenderThread *thread, int x, int y);
264         int handle_event();
265         BatchRenderThread *thread;
266 };
267
268 class BatchRenderStop : public BC_GenericButton
269 {
270 public:
271         BatchRenderStop(BatchRenderThread *thread, int x, int y);
272         int handle_event();
273         BatchRenderThread *thread;
274 };
275
276 class BatchRenderWarning : public BC_CheckBox
277 {
278 public:
279         BatchRenderWarning(BatchRenderThread *thread, int x, int y);
280         int handle_event();
281         BatchRenderThread *thread;
282 };
283
284 class BatchRenderCancel : public BC_GenericButton
285 {
286 public:
287         BatchRenderCancel(BatchRenderThread *thread, int x, int y);
288         int handle_event();
289         int keypress_event();
290         BatchRenderThread *thread;
291 };
292
293
294 class BatchFormat : public FormatTools
295 {
296 public:
297         BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
298         ~BatchFormat();
299
300         int handle_event();
301
302         BatchRenderGUI *gui;
303         MWindow *mwindow;
304 };
305
306 class BatchRenderUseFarm : public BC_CheckBox
307 {
308 public:
309         BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
310         int handle_event();
311         void update(int *output);
312
313         BatchRenderThread *thread;
314         int *output;
315 };
316
317
318 class BatchRenderGUI : public BC_Window
319 {
320 public:
321         BatchRenderGUI(MWindow *mwindow,
322                 BatchRenderThread *thread,
323                 int x,
324                 int y,
325                 int w,
326                 int h);
327         ~BatchRenderGUI();
328
329         void create_objects();
330         int resize_event(int w, int h);
331         int translation_event();
332         int close_event();
333         void create_list(int update_widget);
334         void change_job();
335         void button_enable();
336         void button_disable();
337
338         ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
339         const char *list_titles[BATCHRENDER_COLUMNS];
340         int list_width[BATCHRENDER_COLUMNS], list_columns;
341
342         MWindow *mwindow;
343         BatchRenderThread *thread;
344         BC_Title *output_path_title;
345         BatchFormat *format_tools;
346         BrowseButton *edl_path_browse;
347         BatchRenderEDLPath *edl_path_text;
348         BC_Title *edl_path_title;
349 //      BC_Title *status_title;
350 //      BC_Title *status_text;
351 //      BC_ProgressBar *progress_bar;
352         BC_Title *list_title;
353         BC_Title *batch_path;
354         BatchRenderNew *new_batch;
355         BatchRenderDelete *delete_batch;
356         BatchRenderSaveList *savelist_batch;
357         BatchRenderLoadList *loadlist_batch;
358         BatchRenderWarning *warning;
359         BatchRenderList *batch_list;
360         BatchRenderStart *start_button;
361         BatchRenderStop *stop_button;
362         BatchRenderCancel *cancel_button;
363         BatchRenderCurrentEDL *use_current_edl;
364         BatchRenderUpdateEDL *update_selected_edl;
365         BatchRenderUseFarm *use_renderfarm;
366 };
367
368
369 #endif