initial commit
[goodguy/history.git] / cinelerra-5.0 / 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 "timeentry.h"
37
38 #define BATCHRENDER_COLUMNS 4
39
40
41
42
43 class BatchRenderMenuItem : public BC_MenuItem
44 {
45 public:
46         BatchRenderMenuItem(MWindow *mwindow);
47         int handle_event();
48         MWindow *mwindow;
49 };
50
51
52
53 class BatchRenderJob
54 {
55 public:
56         BatchRenderJob(Preferences *preferences);
57         ~BatchRenderJob();
58
59         void copy_from(BatchRenderJob *src);
60         void load(FileXML *file);
61         void save(FileXML *file);
62         void fix_strategy();
63
64 // Source EDL to render
65         char edl_path[BCTEXTLEN];
66 // Destination file for output
67         Asset *asset;
68         int strategy;
69         int enabled;
70 // Amount of time elapsed in last render operation
71         double elapsed;
72         Preferences *preferences;
73 };
74
75
76
77
78
79
80
81
82 class BatchRenderThread : public BC_DialogThread
83 {
84 public:
85         BatchRenderThread(MWindow *mwindow);
86         BatchRenderThread();
87
88         void handle_close_event(int result);
89         BC_Window* new_gui();
90
91         int test_edl_files();
92         void calculate_dest_paths(ArrayList<char*> *paths,
93                 Preferences *preferences);
94
95 // Load batch rendering jobs
96         void load_jobs(char *path, Preferences *preferences);
97 // Not applicable to western civilizations
98         void save_jobs(char *path);
99         void load_defaults(BC_Hash *defaults);
100         void save_defaults(BC_Hash *defaults);
101 // Create path for persistent storage functions
102         char* create_path(char *string);
103         void new_job();
104         void delete_job();
105         void update_selected_edl();
106         void use_current_edl();
107 // Conditionally returns the job or the default job based on current_job
108         BatchRenderJob* get_current_job();
109         Asset* get_current_asset();
110         char* get_current_edl();
111 // For command line usage
112         void start_rendering(char *config_path, char *batch_path);
113 // For GUI usage
114         void start_rendering();
115         void stop_rendering();
116 // Highlight the currently rendering job.
117         void update_active(int number);
118         void update_done(int number, int create_list, double elapsed_time);
119         void move_batch(int src, int dst);
120
121         MWindow *mwindow;
122         double current_start;
123         double current_end;
124         BatchRenderJob *default_job;
125         ArrayList<BatchRenderJob*> jobs;
126         BatchRenderGUI *gui;
127         int column_width[BATCHRENDER_COLUMNS];
128 // job being edited
129         int current_job;
130 // job being rendered
131         int rendering_job;
132         int is_rendering;
133         ArrayList<BC_ListBoxItem*> *file_entries;
134 };
135
136
137
138
139
140
141
142
143
144
145 class BatchRenderEDLPath : public BC_TextBox
146 {
147 public:
148         BatchRenderEDLPath(BatchRenderThread *thread, 
149                 int x, 
150                 int y, 
151                 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, 
162                 int x, 
163                 int y);
164         int handle_event();
165         BatchRenderThread *thread;
166 };
167
168
169 class BatchRenderUpdateEDL : public BC_GenericButton
170 {
171 public:
172         BatchRenderUpdateEDL(BatchRenderThread *thread, 
173                 int x, 
174                 int y);
175         int handle_event();
176         BatchRenderThread *thread;
177 };
178
179
180 class BatchRenderNew : public BC_GenericButton
181 {
182 public:
183         BatchRenderNew(BatchRenderThread *thread, 
184                 int x, 
185                 int y);
186         int handle_event();
187         BatchRenderThread *thread;
188 };
189
190 class BatchRenderDelete : public BC_GenericButton
191 {
192 public:
193         BatchRenderDelete(BatchRenderThread *thread, 
194                 int x, 
195                 int y);
196         int handle_event();
197         BatchRenderThread *thread;
198 };
199
200 class BatchRenderList : public BC_ListBox
201 {
202 public:
203         BatchRenderList(BatchRenderThread *thread, 
204                 int x, 
205                 int y,
206                 int w,
207                 int h);
208         int handle_event();
209         int selection_changed();
210         int column_resize_event();
211         int drag_start_event();
212         int drag_motion_event();
213         int drag_stop_event();
214         int dragging_item;
215         BatchRenderThread *thread;
216 };
217 class BatchRenderStart : public BC_GenericButton
218 {
219 public:
220         BatchRenderStart(BatchRenderThread *thread, 
221                 int x, 
222                 int y);
223         int handle_event();
224         BatchRenderThread *thread;
225 };
226
227 class BatchRenderStop : public BC_GenericButton
228 {
229 public:
230         BatchRenderStop(BatchRenderThread *thread, 
231                 int x, 
232                 int y);
233         int handle_event();
234         BatchRenderThread *thread;
235 };
236
237 class BatchRenderCancel : public BC_GenericButton
238 {
239 public:
240         BatchRenderCancel(BatchRenderThread *thread, 
241                 int x, 
242                 int y);
243         int handle_event();
244         int keypress_event();
245         BatchRenderThread *thread;
246 };
247
248
249 class BatchFormat : public FormatTools
250 {
251 public:
252         BatchFormat(MWindow *mwindow,
253                                 BatchRenderGUI *gui,
254                                 Asset *asset);
255         ~BatchFormat();
256
257         int handle_event();
258
259         BatchRenderGUI *gui;
260         MWindow *mwindow;
261 };
262
263
264 class BatchRenderGUI : public BC_Window
265 {
266 public:
267         BatchRenderGUI(MWindow *mwindow, 
268                 BatchRenderThread *thread,
269                 int x,
270                 int y,
271                 int w,
272                 int h);
273         ~BatchRenderGUI();
274
275         void create_objects();
276         int resize_event(int w, int h);
277         int translation_event();
278         int close_event();
279         void create_list(int update_widget);
280         void change_job();
281         void button_enable();
282         void button_disable();
283
284         ArrayList<BC_ListBoxItem*> list_columns[BATCHRENDER_COLUMNS];
285
286         MWindow *mwindow;
287         BatchRenderThread *thread;
288         BC_Title *output_path_title;
289         BatchFormat *format_tools;
290         BrowseButton *edl_path_browse;
291         BatchRenderEDLPath *edl_path_text;
292         BC_Title *edl_path_title;
293 //      BC_Title *status_title;
294 //      BC_Title *status_text;
295 //      BC_ProgressBar *progress_bar;
296         BC_Title *list_title;
297         BatchRenderNew *new_batch;
298         BatchRenderDelete *delete_batch;
299         BatchRenderList *batch_list;
300         BatchRenderStart *start_button;
301         BatchRenderStop *stop_button;
302         BatchRenderCancel *cancel_button;
303         BatchRenderCurrentEDL *use_current_edl;
304         BatchRenderUpdateEDL *update_selected_edl;
305 };
306
307
308
309
310 class CreateDVD_MenuItem : public BC_MenuItem
311 {
312 public:
313         CreateDVD_MenuItem(MWindow *mwindow);
314         int handle_event();
315         MWindow *mwindow;
316 };
317
318
319 class CreateDVD_Thread : public BC_DialogThread
320 {
321         static const int64_t DVD_SIZE;
322         static const int DVD_STREAMS, DVD_WIDTH, DVD_HEIGHT;
323         static const double DVD_ASPECT_WIDTH, DVD_ASPECT_HEIGHT;
324         static const double DVD_WIDE_ASPECT_WIDTH, DVD_WIDE_ASPECT_HEIGHT;
325         static const int DVD_MAX_BITRATE, DVD_CHANNELS, DVD_WIDE_CHANNELS;
326         static const double DVD_FRAMERATE, DVD_SAMPLERATE, DVD_KAUDIO_RATE;
327 public:
328         CreateDVD_Thread(MWindow *mwindow);
329         ~CreateDVD_Thread();
330         void handle_close_event(int result);
331         BC_Window* new_gui();
332         int option_presets();
333         int create_dvd_jobs(ArrayList<BatchRenderJob*> *jobs,
334                 const char *tmp_path, const char *asset_title);
335         int insert_video_plugin(const char *title, KeyFrame *default_keyframe);
336         int resize_tracks();
337
338         MWindow *mwindow;
339         CreateDVD_GUI *gui;
340         char asset_title[BCTEXTLEN];
341         char tmp_path[BCTEXTLEN];
342         int use_deinterlace, use_inverse_telecine;
343         int use_scale, use_resize_tracks;
344         int use_wide_audio, use_wide_aspect;
345         int use_histogram, use_label_chapters;
346 };
347
348 class CreateDVD_OK : public BC_OKButton
349 {
350 public:
351         CreateDVD_OK(CreateDVD_GUI *gui, int x, int y);
352         ~CreateDVD_OK();
353         int button_press_event();
354         int keypress_event();
355
356         CreateDVD_GUI *gui;
357 };
358
359 class CreateDVD_Cancel : public BC_CancelButton
360 {
361 public:
362         CreateDVD_Cancel(CreateDVD_GUI *gui, int x, int y);
363         ~CreateDVD_Cancel();
364         int button_press_event();
365
366         CreateDVD_GUI *gui;
367 };
368
369
370 class CreateDVD_DiskSpace : public BC_Title
371 {
372 public:
373         CreateDVD_DiskSpace(CreateDVD_GUI *gui, int x, int y);
374         ~CreateDVD_DiskSpace();
375         int64_t tmp_path_space();
376         void update();
377
378         CreateDVD_GUI *gui;
379 };
380
381 class CreateDVD_TmpPath : public BC_TextBox
382 {
383 public:
384         CreateDVD_TmpPath(CreateDVD_GUI *gui, int x, int y, int w);
385         ~CreateDVD_TmpPath();
386         int handle_event();
387
388         CreateDVD_GUI *gui;
389 };
390
391
392 class CreateDVD_AssetTitle : public BC_TextBox
393 {
394 public:
395         CreateDVD_AssetTitle(CreateDVD_GUI *gui, int x, int y, int w);
396         ~CreateDVD_AssetTitle();
397
398         CreateDVD_GUI *gui;
399 };
400
401 class CreateDVD_Deinterlace : public BC_CheckBox
402 {
403 public:
404         CreateDVD_Deinterlace(CreateDVD_GUI *gui, int x, int y);
405         ~CreateDVD_Deinterlace();
406         int handle_event();
407
408         CreateDVD_GUI *gui;
409 };
410
411 class CreateDVD_InverseTelecine : public BC_CheckBox
412 {
413 public:
414         CreateDVD_InverseTelecine(CreateDVD_GUI *gui, int x, int y);
415         ~CreateDVD_InverseTelecine();
416         int handle_event();
417
418         CreateDVD_GUI *gui;
419 };
420
421 class CreateDVD_Scale : public BC_CheckBox
422 {
423 public:
424         CreateDVD_Scale(CreateDVD_GUI *gui, int x, int y);
425         ~CreateDVD_Scale();
426
427         CreateDVD_GUI *gui;
428 };
429
430 class CreateDVD_ResizeTracks : public BC_CheckBox
431 {
432 public:
433         CreateDVD_ResizeTracks(CreateDVD_GUI *gui, int x, int y);
434         ~CreateDVD_ResizeTracks();
435
436         CreateDVD_GUI *gui;
437 };
438
439 class CreateDVD_Histogram : public BC_CheckBox
440 {
441 public:
442         CreateDVD_Histogram(CreateDVD_GUI *gui, int x, int y);
443         ~CreateDVD_Histogram();
444
445         CreateDVD_GUI *gui;
446 };
447
448 class CreateDVD_LabelChapters : public BC_CheckBox
449 {
450 public:
451         CreateDVD_LabelChapters(CreateDVD_GUI *gui, int x, int y);
452         ~CreateDVD_LabelChapters();
453
454         CreateDVD_GUI *gui;
455 };
456
457 class CreateDVD_WideAudio : public BC_CheckBox
458 {
459 public:
460         CreateDVD_WideAudio(CreateDVD_GUI *gui, int x, int y);
461         ~CreateDVD_WideAudio();
462
463         CreateDVD_GUI *gui;
464 };
465
466 class CreateDVD_WideAspect : public BC_CheckBox
467 {
468 public:
469         CreateDVD_WideAspect(CreateDVD_GUI *gui, int x, int y);
470         ~CreateDVD_WideAspect();
471
472         CreateDVD_GUI *gui;
473 };
474
475 class CreateDVD_GUI : public BC_Window
476 {
477 public:
478         CreateDVD_GUI(CreateDVD_Thread *thread,
479                 int x, int y, int w, int h);
480         ~CreateDVD_GUI();
481
482         void create_objects();
483         int resize_event(int w, int h);
484         int translation_event();
485         int close_event();
486
487         int64_t needed_disk_space;
488         CreateDVD_Thread *thread;
489         int at_x, at_y;
490         CreateDVD_AssetTitle *asset_title;
491         int tmp_x, tmp_y;
492         CreateDVD_TmpPath *tmp_path;
493         CreateDVD_DiskSpace *disk_space;
494         CreateDVD_Deinterlace *need_deinterlace;
495         CreateDVD_InverseTelecine *need_inverse_telecine;
496         CreateDVD_Scale *need_scale;
497         CreateDVD_ResizeTracks *need_resize_tracks;
498         CreateDVD_Histogram *need_histogram;
499         CreateDVD_WideAudio *need_wide_audio;
500         CreateDVD_WideAspect *need_wide_aspect;
501         CreateDVD_LabelChapters *need_label_chapters;
502         int ok_x, ok_y, ok_w, ok_h;
503         CreateDVD_OK *ok;
504         int cancel_x, cancel_y, cancel_w, cancel_h;
505         CreateDVD_Cancel *cancel;
506 };
507
508
509
510
511 #endif