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