add Autosave continuous backups by Andras Reuss and Andrew-R
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / convert.h
1 #ifndef __CONVERT_H__
2 #define __CONVERT_H__
3
4 /*
5  * CINELERRA
6  * Copyright (C) 2015 Adam Williams <broadcast at earthling dot net>
7  * 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  * 
22  */
23
24 #include "arraylist.h"
25 #include "audiodevice.inc"
26 #include "asset.h"
27 #include "bcdialog.h"
28 #include "bctimer.inc"
29 #include "convert.inc"
30 #include "file.inc"
31 #include "formattools.h"
32 #include "guicast.h"
33 #include "mainprogress.inc"
34 #include "mutex.inc"
35 #include "mwindow.inc"
36 #include "packagerenderer.h"
37 #include "render.inc"
38
39 class ConvertRender : public Thread
40 {
41 public:
42         ConvertRender(MWindow *mwindow);
43         ~ConvertRender();
44         void reset();
45         void to_convert_path(char *new_path, Indexable *idxbl);
46         int from_convert_path(char *new_path, Indexable *idxbl);
47
48         ArrayList<Indexable *> orig_idxbls;     // originals which match the convert assets
49         ArrayList<Asset *> orig_copies;         // convert assets
50         ArrayList<Indexable *> needed_idxbls;   // originals which match the needed_assets
51         ArrayList<Asset *> needed_copies;       // assets which must be created
52
53         double get_video_length(Indexable *idxbl);
54         double get_audio_length(Indexable *idxbl);
55         double get_length(Indexable *idxbl);
56         int match_format(Asset *asset);
57         EDL *convert_edl(EDL *edl, Indexable *idxbl);  // create render edl for this indexable
58         int add_original(EDL *edl, Indexable *idxbl);
59         void add_needed(Indexable *idxbl, Asset *convert);
60         int find_convertable_assets(EDL *edl);
61
62 // if user canceled progress bar
63         int is_canceled();
64         void set_format(Asset *asset, const char *suffix, int to_proxy);
65         void start_convert(float beep, int remove_originals);
66         void run();
67         void create_copy(int i);
68         void start_progress();
69         void stop_progress(const char *msg);
70
71         MWindow *mwindow;
72         const char *suffix;
73         Asset *format_asset;
74         MainProgressBar *progress;
75         ConvertProgress *convert_progress;
76         Timer *progress_timer;
77         ConvertPackageRenderer *renderer;
78
79         Mutex *counter_lock;
80         int total_rendered, remove_originals;
81         int failed, canceled, result;
82         float beep;
83         int to_proxy;
84 };
85
86 class ConvertMenuItem : public BC_MenuItem
87 {
88 public:
89         ConvertMenuItem(MWindow *mwindow);
90         ~ConvertMenuItem();
91
92         int handle_event();
93         void create_objects();
94
95         MWindow *mwindow;
96         ConvertDialog *dialog;
97 };
98
99 class ConvertFormatTools : public FormatTools
100 {
101 public:
102         ConvertFormatTools(MWindow *mwindow, ConvertWindow *gui, Asset *asset);
103
104         void update_format();
105         ConvertWindow *gui;
106 };
107
108 class ConvertSuffixText : public BC_TextBox
109 {
110 public:
111         ConvertSuffixText(ConvertWindow *gui, ConvertDialog *dialog, int x, int y);
112         ~ConvertSuffixText();
113         int handle_event();
114
115         ConvertWindow *gui;
116         ConvertDialog *dialog;
117 };
118
119 class ConvertRemoveOriginals : public BC_CheckBox
120 {
121 public:
122         ConvertRemoveOriginals(ConvertWindow *gui, int x, int y);
123         ~ConvertRemoveOriginals();
124
125         int handle_event();
126
127         ConvertWindow *gui;
128 };
129
130 class ConvertToProxyPath : public BC_CheckBox
131 {
132 public:
133         ConvertToProxyPath(ConvertWindow *gui, int x, int y);
134         ~ConvertToProxyPath();
135
136         int handle_event();
137
138         ConvertWindow *gui;
139 };
140
141 class ConvertBeepOnDone : public BC_FPot
142 {
143 public:
144         ConvertBeepOnDone(ConvertWindow *gui, int x, int y);
145         void update();
146         int handle_event();
147
148         ConvertWindow *gui;
149 };
150
151 class ConvertPackageRenderer : public PackageRenderer
152 {
153 public:
154         ConvertPackageRenderer(ConvertRender *render);
155         virtual ~ConvertPackageRenderer();
156
157         int get_master();
158         int get_result();
159         void set_result(int value);
160         void set_progress(int64_t value);
161         int progress_cancelled();
162
163         ConvertRender *render;
164 };
165
166 class ConvertProgress : public Thread
167 {
168 public:
169         ConvertProgress(MWindow *mwindow, ConvertRender *render);
170         ~ConvertProgress();
171
172         void run();
173
174         MWindow *mwindow;
175         ConvertRender *render;
176         int64_t last_value;
177 };
178
179 class ConvertWindow : public BC_Window
180 {
181 public:
182         ConvertWindow(MWindow *mwindow, ConvertDialog *dialog,
183                 int x, int y);
184         ~ConvertWindow();
185
186         void create_objects();
187
188         MWindow *mwindow;
189         ConvertDialog *dialog;
190
191         ConvertSuffixText *suffix_text;
192         ConvertFormatTools *format_tools;
193         ConvertRemoveOriginals *remove_originals;
194         ConvertToProxyPath *to_proxy_path;
195         ConvertBeepOnDone *beep_on_done;
196 };
197
198 class ConvertDialog : public BC_DialogThread
199 {
200 public:
201         ConvertDialog(MWindow *mwindow);
202         ~ConvertDialog();
203         BC_Window* new_gui();
204
205         void handle_close_event(int result);
206         void convert();
207
208         MWindow *mwindow;
209         ConvertWindow *gui;
210         Asset *asset;
211         char suffix[BCTEXTLEN];
212         ConvertRender *convert_render;
213
214         int orig_scale, new_scale;
215         int use_scaler, auto_scale;
216         int orig_w, orig_h;
217         int remove_originals;
218         float beep;
219         int to_proxy;
220 };
221
222 #endif