allow ffmpeg video to resample curr_pos, add bluray format
[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         int use_ffmpeg;
347 };
348
349 class CreateDVD_OK : public BC_OKButton
350 {
351 public:
352         CreateDVD_OK(CreateDVD_GUI *gui, int x, int y);
353         ~CreateDVD_OK();
354         int button_press_event();
355         int keypress_event();
356
357         CreateDVD_GUI *gui;
358 };
359
360 class CreateDVD_Cancel : public BC_CancelButton
361 {
362 public:
363         CreateDVD_Cancel(CreateDVD_GUI *gui, int x, int y);
364         ~CreateDVD_Cancel();
365         int button_press_event();
366
367         CreateDVD_GUI *gui;
368 };
369
370
371 class CreateDVD_DiskSpace : public BC_Title
372 {
373 public:
374         CreateDVD_DiskSpace(CreateDVD_GUI *gui, int x, int y);
375         ~CreateDVD_DiskSpace();
376         int64_t tmp_path_space();
377         void update();
378
379         CreateDVD_GUI *gui;
380 };
381
382 class CreateDVD_TmpPath : public BC_TextBox
383 {
384 public:
385         CreateDVD_TmpPath(CreateDVD_GUI *gui, int x, int y, int w);
386         ~CreateDVD_TmpPath();
387         int handle_event();
388
389         CreateDVD_GUI *gui;
390 };
391
392
393 class CreateDVD_AssetTitle : public BC_TextBox
394 {
395 public:
396         CreateDVD_AssetTitle(CreateDVD_GUI *gui, int x, int y, int w);
397         ~CreateDVD_AssetTitle();
398
399         CreateDVD_GUI *gui;
400 };
401
402 class CreateDVD_Deinterlace : public BC_CheckBox
403 {
404 public:
405         CreateDVD_Deinterlace(CreateDVD_GUI *gui, int x, int y);
406         ~CreateDVD_Deinterlace();
407         int handle_event();
408
409         CreateDVD_GUI *gui;
410 };
411
412 class CreateDVD_InverseTelecine : public BC_CheckBox
413 {
414 public:
415         CreateDVD_InverseTelecine(CreateDVD_GUI *gui, int x, int y);
416         ~CreateDVD_InverseTelecine();
417         int handle_event();
418
419         CreateDVD_GUI *gui;
420 };
421
422 class CreateDVD_Scale : public BC_CheckBox
423 {
424 public:
425         CreateDVD_Scale(CreateDVD_GUI *gui, int x, int y);
426         ~CreateDVD_Scale();
427
428         CreateDVD_GUI *gui;
429 };
430
431 class CreateDVD_ResizeTracks : public BC_CheckBox
432 {
433 public:
434         CreateDVD_ResizeTracks(CreateDVD_GUI *gui, int x, int y);
435         ~CreateDVD_ResizeTracks();
436
437         CreateDVD_GUI *gui;
438 };
439
440 class CreateDVD_Histogram : public BC_CheckBox
441 {
442 public:
443         CreateDVD_Histogram(CreateDVD_GUI *gui, int x, int y);
444         ~CreateDVD_Histogram();
445
446         CreateDVD_GUI *gui;
447 };
448
449 class CreateDVD_LabelChapters : public BC_CheckBox
450 {
451 public:
452         CreateDVD_LabelChapters(CreateDVD_GUI *gui, int x, int y);
453         ~CreateDVD_LabelChapters();
454
455         CreateDVD_GUI *gui;
456 };
457
458 class CreateDVD_WideAudio : public BC_CheckBox
459 {
460 public:
461         CreateDVD_WideAudio(CreateDVD_GUI *gui, int x, int y);
462         ~CreateDVD_WideAudio();
463
464         CreateDVD_GUI *gui;
465 };
466
467 class CreateDVD_WideAspect : public BC_CheckBox
468 {
469 public:
470         CreateDVD_WideAspect(CreateDVD_GUI *gui, int x, int y);
471         ~CreateDVD_WideAspect();
472
473         CreateDVD_GUI *gui;
474 };
475
476 class CreateDVD_UseFFMpeg : public BC_CheckBox
477 {
478 public:
479         CreateDVD_UseFFMpeg(CreateDVD_GUI *gui, int x, int y);
480         ~CreateDVD_UseFFMpeg();
481
482         CreateDVD_GUI *gui;
483 };
484
485 class CreateDVD_GUI : public BC_Window
486 {
487 public:
488         CreateDVD_GUI(CreateDVD_Thread *thread,
489                 int x, int y, int w, int h);
490         ~CreateDVD_GUI();
491
492         void create_objects();
493         int resize_event(int w, int h);
494         int translation_event();
495         int close_event();
496
497         int64_t needed_disk_space;
498         CreateDVD_Thread *thread;
499         int at_x, at_y;
500         CreateDVD_AssetTitle *asset_title;
501         int tmp_x, tmp_y;
502         CreateDVD_TmpPath *tmp_path;
503         CreateDVD_DiskSpace *disk_space;
504         CreateDVD_Deinterlace *need_deinterlace;
505         CreateDVD_InverseTelecine *need_inverse_telecine;
506         CreateDVD_Scale *need_scale;
507         CreateDVD_UseFFMpeg *need_use_ffmpeg;
508         CreateDVD_ResizeTracks *need_resize_tracks;
509         CreateDVD_Histogram *need_histogram;
510         CreateDVD_WideAudio *need_wide_audio;
511         CreateDVD_WideAspect *need_wide_aspect;
512         CreateDVD_LabelChapters *need_label_chapters;
513         int ok_x, ok_y, ok_w, ok_h;
514         CreateDVD_OK *ok;
515         int cancel_x, cancel_y, cancel_w, cancel_h;
516         CreateDVD_Cancel *cancel;
517 };
518
519
520
521
522 #endif