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