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