version update
[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         void calculate_dest_paths(ArrayList<char*> *paths,
114                 Preferences *preferences);
115         void reset(const char *path=0);
116 // Load batch rendering jobs
117         void load_jobs(char *path, Preferences *preferences);
118 // Not applicable to western civilizations
119         void save_jobs(char *path=0);
120         void load_defaults(BC_Hash *defaults);
121         void save_defaults(BC_Hash *defaults);
122 // Create path for persistent storage functions
123         char* create_path(char *string);
124         void new_job();
125         void delete_job();
126         void update_selected_edl();
127         void use_current_edl();
128 // Conditionally returns the job or the default job based on current_job
129         BatchRenderJob* get_current_job();
130         Asset* get_current_asset();
131         char* get_current_edl();
132 // For command line usage
133         void start_rendering(char *config_path, char *batch_path);
134 // For GUI usage
135         void start_rendering();
136         void stop_rendering();
137 // Highlight the currently rendering job.
138         void update_active(int number);
139         void update_done(int number, int create_list, double elapsed_time);
140         void move_batch(int src, int dst);
141         void start(int do_farmed, int do_labeled);
142         static void trap_hook(FILE *fp, void *vp);
143
144         MWindow *mwindow;
145         char batch_path[BCTEXTLEN];
146         double current_start;
147         double current_end;
148         BatchRenderJob *default_job;
149         ArrayList<BatchRenderJob*> jobs;
150         BC_Hash *boot_defaults;
151         Preferences *preferences;
152         Render *render;
153         BatchRenderGUI *gui;
154
155         static const char *column_titles[BATCHRENDER_COLUMNS];
156         static int column_widths[BATCHRENDER_COLUMNS];
157         int list_width[BATCHRENDER_COLUMNS];
158         int do_farmed;
159         int do_labeled;
160 // job being edited
161         int current_job;
162 // job being rendered
163         int rendering_job;
164         int is_rendering;
165         int warn;
166 };
167
168
169
170 class BatchRenderEDLPath : public BC_TextBox
171 {
172 public:
173         BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
174                 char *text);
175         int handle_event();
176         BatchRenderThread *thread;
177 };
178
179
180 class BatchRenderCurrentEDL : public BC_GenericButton
181 {
182 public:
183         BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
184         int handle_event();
185         BatchRenderThread *thread;
186 };
187
188
189 class BatchRenderUpdateEDL : public BC_GenericButton
190 {
191 public:
192         BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
193         int handle_event();
194         BatchRenderThread *thread;
195 };
196
197
198 class BatchRenderNew : public BC_GenericButton
199 {
200 public:
201         BatchRenderNew(BatchRenderThread *thread, int x, int y);
202         int handle_event();
203         BatchRenderThread *thread;
204 };
205
206 class BatchRenderDelete : public BC_GenericButton
207 {
208 public:
209         BatchRenderDelete(BatchRenderThread *thread, int x, int y);
210         int handle_event();
211         BatchRenderThread *thread;
212 };
213
214
215
216 class BatchRenderSaveList : public BC_GenericButton, public Thread
217 {
218 public:
219         BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
220         ~BatchRenderSaveList();
221         int handle_event();
222         BatchRenderThread *thread;
223         BC_FileBox *gui;
224         void run();
225         void stop();
226         virtual int keypress_event();
227         Mutex *startup_lock;
228 };
229
230 class BatchRenderLoadList : public BC_GenericButton, public Thread
231 {
232 public:
233         BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
234         ~BatchRenderLoadList();
235         int handle_event();
236         BatchRenderThread *thread;
237         BC_FileBox *gui;
238         void run();
239         void stop();
240         virtual int keypress_event();
241         Mutex *startup_lock;
242 };
243
244
245
246 class BatchRenderList : public BC_ListBox
247 {
248 public:
249         BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
250         int handle_event();
251         int selection_changed();
252         int column_resize_event();
253         int drag_start_event();
254         int drag_motion_event();
255         int drag_stop_event();
256         int dragging_item;
257         BatchRenderThread *thread;
258 };
259 class BatchRenderStart : public BC_GenericButton
260 {
261 public:
262         BatchRenderStart(BatchRenderThread *thread, int x, int y);
263         int handle_event();
264         BatchRenderThread *thread;
265 };
266
267 class BatchRenderStop : public BC_GenericButton
268 {
269 public:
270         BatchRenderStop(BatchRenderThread *thread, int x, int y);
271         int handle_event();
272         BatchRenderThread *thread;
273 };
274
275 class BatchRenderWarning : public BC_CheckBox
276 {
277 public:
278         BatchRenderWarning(BatchRenderThread *thread, int x, int y);
279         int handle_event();
280         BatchRenderThread *thread;
281 };
282
283 class BatchRenderCancel : public BC_GenericButton
284 {
285 public:
286         BatchRenderCancel(BatchRenderThread *thread, int x, int y);
287         int handle_event();
288         int keypress_event();
289         BatchRenderThread *thread;
290 };
291
292
293 class BatchFormat : public FormatTools
294 {
295 public:
296         BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
297         ~BatchFormat();
298
299         int handle_event();
300
301         BatchRenderGUI *gui;
302         MWindow *mwindow;
303 };
304
305 class BatchRenderUseFarm : public BC_CheckBox
306 {
307 public:
308         BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
309         int handle_event();
310         void update(int *output);
311
312         BatchRenderThread *thread;
313         int *output;
314 };
315
316
317 class BatchRenderGUI : public BC_Window
318 {
319 public:
320         BatchRenderGUI(MWindow *mwindow,
321                 BatchRenderThread *thread,
322                 int x,
323                 int y,
324                 int w,
325                 int h);
326         ~BatchRenderGUI();
327
328         void create_objects();
329         int resize_event(int w, int h);
330         int translation_event();
331         int close_event();
332         void create_list(int update_widget);
333         void change_job();
334         void button_enable();
335         void button_disable();
336
337         ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
338         const char *list_titles[BATCHRENDER_COLUMNS];
339         int list_width[BATCHRENDER_COLUMNS], list_columns;
340
341         MWindow *mwindow;
342         BatchRenderThread *thread;
343         BC_Title *output_path_title;
344         BatchFormat *format_tools;
345         BrowseButton *edl_path_browse;
346         BatchRenderEDLPath *edl_path_text;
347         BC_Title *edl_path_title;
348 //      BC_Title *status_title;
349 //      BC_Title *status_text;
350 //      BC_ProgressBar *progress_bar;
351         BC_Title *list_title;
352         BC_Title *batch_path;
353         BatchRenderNew *new_batch;
354         BatchRenderDelete *delete_batch;
355         BatchRenderSaveList *savelist_batch;
356         BatchRenderLoadList *loadlist_batch;
357         BatchRenderWarning *warning;
358         BatchRenderList *batch_list;
359         BatchRenderStart *start_button;
360         BatchRenderStop *stop_button;
361         BatchRenderCancel *cancel_button;
362         BatchRenderCurrentEDL *use_current_edl;
363         BatchRenderUpdateEDL *update_selected_edl;
364         BatchRenderUseFarm *use_renderfarm;
365 };
366
367
368 #endif