4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
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.
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.
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
26 #include "arraylist.h"
28 #include "batchrender.inc"
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"
39 #include "timeentry.h"
42 ENABLED_COL, LABELED_COL, FARMED_COL,
43 OUTPUT_COL, EDL_COL, ELAPSED_COL,
47 class BatchRenderMenuItem : public BC_MenuItem
50 BatchRenderMenuItem(MWindow *mwindow);
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);
73 // Source EDL to render
74 char edl_path[BCTEXTLEN];
75 // Destination file for output
79 // Amount of time elapsed in last render operation
81 Preferences *preferences;
85 class BatchRenderWarnJob
88 BatchRenderWarnJob() { no = 0; path = 0; }
89 ~BatchRenderWarnJob() { delete [] path; }
94 class BatchRenderWarnJobs : public ArrayList<BatchRenderWarnJob>
97 BatchRenderWarnJobs() {}
98 ~BatchRenderWarnJobs() {}
99 void add(int no, const char *path) {
100 BatchRenderWarnJob &job = append();
101 job.no = no; job.path = cstrdup(path);
105 class BatchRenderThread : public BC_DialogThread
108 BatchRenderThread(MWindow *mwindow=0);
109 ~BatchRenderThread();
110 void handle_close_event(int result);
111 BC_Window* new_gui();
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);
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);
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);
147 char batch_path[BCTEXTLEN];
148 double current_start;
150 BatchRenderJob *default_job;
151 ArrayList<BatchRenderJob*> jobs;
152 BC_Hash *boot_defaults;
153 Preferences *preferences;
157 static const char *column_titles[BATCHRENDER_COLUMNS];
158 static int column_widths[BATCHRENDER_COLUMNS];
159 int list_width[BATCHRENDER_COLUMNS];
164 // job being rendered
172 class BatchRenderEDLPath : public BC_TextBox
175 BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
178 BatchRenderThread *thread;
182 class BatchRenderCurrentEDL : public BC_GenericButton
185 BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
187 BatchRenderThread *thread;
191 class BatchRenderUpdateEDL : public BC_GenericButton
194 BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
196 BatchRenderThread *thread;
200 class BatchRenderNew : public BC_GenericButton
203 BatchRenderNew(BatchRenderThread *thread, int x, int y);
205 BatchRenderThread *thread;
208 class BatchRenderDelete : public BC_GenericButton
211 BatchRenderDelete(BatchRenderThread *thread, int x, int y);
213 BatchRenderThread *thread;
218 class BatchRenderSaveList : public BC_GenericButton, public Thread
221 BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
222 ~BatchRenderSaveList();
224 BatchRenderThread *thread;
228 virtual int keypress_event();
232 class BatchRenderLoadList : public BC_GenericButton, public Thread
235 BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
236 ~BatchRenderLoadList();
238 BatchRenderThread *thread;
242 virtual int keypress_event();
248 class BatchRenderList : public BC_ListBox
251 BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
253 int selection_changed();
254 int column_resize_event();
255 int drag_start_event();
256 int drag_motion_event();
257 int drag_stop_event();
259 BatchRenderThread *thread;
261 class BatchRenderStart : public BC_GenericButton
264 BatchRenderStart(BatchRenderThread *thread, int x, int y);
266 BatchRenderThread *thread;
269 class BatchRenderStop : public BC_GenericButton
272 BatchRenderStop(BatchRenderThread *thread, int x, int y);
274 BatchRenderThread *thread;
277 class BatchRenderWarning : public BC_CheckBox
280 BatchRenderWarning(BatchRenderThread *thread, int x, int y);
282 BatchRenderThread *thread;
285 class BatchRenderCancel : public BC_GenericButton
288 BatchRenderCancel(BatchRenderThread *thread, int x, int y);
290 int keypress_event();
291 BatchRenderThread *thread;
295 class BatchFormat : public FormatTools
298 BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
307 class BatchRenderUseFarm : public BC_CheckBox
310 BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
312 void update(int *output);
314 BatchRenderThread *thread;
319 class BatchRenderHelp : public BC_GenericButton
322 BatchRenderHelp(BatchRenderThread *thread, int x, int y);
324 BatchRenderThread *thread;
327 class BatchRenderGUI : public BC_Window
330 BatchRenderGUI(MWindow *mwindow,
331 BatchRenderThread *thread,
338 void create_objects();
339 int resize_event(int w, int h);
340 int translation_event();
342 void create_list(int update_widget);
344 void button_enable();
345 void button_disable();
347 ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
348 const char *list_titles[BATCHRENDER_COLUMNS];
349 int list_width[BATCHRENDER_COLUMNS], list_columns;
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;