dde071d4c1e137f64b733295361487d163e4feaa
[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
78         Mutex *counter_lock;
79         int total_rendered, remove_originals;
80         int failed, canceled, result;
81         float beep;
82         int to_proxy;
83 };
84
85 class ConvertMenuItem : public BC_MenuItem
86 {
87 public:
88         ConvertMenuItem(MWindow *mwindow);
89         ~ConvertMenuItem();
90
91         int handle_event();
92         void create_objects();
93
94         MWindow *mwindow;
95         ConvertDialog *dialog;
96 };
97
98 class ConvertFormatTools : public FormatTools
99 {
100 public:
101         ConvertFormatTools(MWindow *mwindow, ConvertWindow *gui, Asset *asset);
102
103         void update_format();
104         ConvertWindow *gui;
105 };
106
107 class ConvertSuffixText : public BC_TextBox
108 {
109 public:
110         ConvertSuffixText(ConvertWindow *gui, ConvertDialog *dialog, int x, int y);
111         ~ConvertSuffixText();
112         int handle_event();
113
114         ConvertWindow *gui;
115         ConvertDialog *dialog;
116 };
117
118 class ConvertRemoveOriginals : public BC_CheckBox
119 {
120 public:
121         ConvertRemoveOriginals(ConvertWindow *gui, int x, int y);
122         ~ConvertRemoveOriginals();
123
124         int handle_event();
125
126         ConvertWindow *gui;
127 };
128
129 class ConvertToProxyPath : public BC_CheckBox
130 {
131 public:
132         ConvertToProxyPath(ConvertWindow *gui, int x, int y);
133         ~ConvertToProxyPath();
134
135         int handle_event();
136
137         ConvertWindow *gui;
138 };
139
140 class ConvertBeepOnDone : public BC_FPot
141 {
142 public:
143         ConvertBeepOnDone(ConvertWindow *gui, int x, int y);
144         void update();
145         int handle_event();
146
147         ConvertWindow *gui;
148 };
149
150 class ConvertPackageRenderer : public PackageRenderer
151 {
152 public:
153         ConvertPackageRenderer(ConvertRender *render);
154         ~ConvertPackageRenderer();
155
156         int get_master();
157         int get_result();
158         void set_result(int value);
159         void set_progress(int64_t value);
160         int progress_cancelled();
161
162         ConvertRender *render;
163 };
164
165 class ConvertProgress : public Thread
166 {
167 public:
168         ConvertProgress(MWindow *mwindow, ConvertRender *render);
169         ~ConvertProgress();
170
171         void run();
172
173         MWindow *mwindow;
174         ConvertRender *render;
175         int64_t last_value;
176 };
177
178 class ConvertWindow : public BC_Window
179 {
180 public:
181         ConvertWindow(MWindow *mwindow, ConvertDialog *dialog,
182                 int x, int y);
183         ~ConvertWindow();
184
185         void create_objects();
186
187         MWindow *mwindow;
188         ConvertDialog *dialog;
189
190         ConvertSuffixText *suffix_text;
191         ConvertFormatTools *format_tools;
192         ConvertRemoveOriginals *remove_originals;
193         ConvertToProxyPath *to_proxy_path;
194         ConvertBeepOnDone *beep_on_done;
195 };
196
197 class ConvertDialog : public BC_DialogThread
198 {
199 public:
200         ConvertDialog(MWindow *mwindow);
201         ~ConvertDialog();
202         BC_Window* new_gui();
203
204         void handle_close_event(int result);
205         void convert();
206
207         MWindow *mwindow;
208         ConvertWindow *gui;
209         Asset *asset;
210         char suffix[BCTEXTLEN];
211         ConvertRender *convert_render;
212
213         int orig_scale, new_scale;
214         int use_scaler, auto_scale;
215         int orig_w, orig_h;
216         int remove_originals;
217         float beep;
218         int to_proxy;
219 };
220
221 #endif