port 7.2 mods: align_edits foreground plugin refresh_frame tweak, rework soundlevel...
[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, const char *suffix);
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         EDL *convert_edl(EDL *edl, Indexable *idxbl);  // create render edl for this indexable
54         int add_original(EDL *edl, Indexable *idxbl);
55         void add_needed(Indexable *idxbl, Asset *convert);
56         int find_convertable_assets(EDL *edl);
57
58 // if user canceled progress bar
59         int is_canceled();
60         void set_format(Asset *asset);
61         void start_convert(float beep, int remove_originals);
62         void run();
63         void create_copy(int i);
64         void start_progress();
65         void stop_progress(const char *msg);
66
67         MWindow *mwindow;
68         const char *suffix;
69         Asset *format_asset;
70         MainProgressBar *progress;
71         ConvertProgress *convert_progress;
72         Timer *progress_timer;
73
74         Mutex *counter_lock;
75         int total_rendered, remove_originals;
76         int failed, canceled, result;
77         float beep;
78 };
79
80 class ConvertMenuItem : public BC_MenuItem
81 {
82 public:
83         ConvertMenuItem(MWindow *mwindow);
84         ~ConvertMenuItem();
85
86         int handle_event();
87         void create_objects();
88
89         MWindow *mwindow;
90         ConvertDialog *dialog;
91 };
92
93 class ConvertFormatTools : public FormatTools
94 {
95 public:
96         ConvertFormatTools(MWindow *mwindow, ConvertWindow *gui, Asset *asset);
97
98         void update_format();
99         ConvertWindow *gui;
100 };
101
102 class ConvertSuffixText : public BC_TextBox
103 {
104 public:
105         ConvertSuffixText(ConvertWindow *gui, ConvertDialog *dialog, int x, int y);
106         ~ConvertSuffixText();
107         int handle_event();
108
109         ConvertWindow *gui;
110         ConvertDialog *dialog;
111 };
112
113 class ConvertRemoveOriginals : public BC_CheckBox
114 {
115 public:
116         ConvertRemoveOriginals(ConvertWindow *gui, int x, int y);
117         ~ConvertRemoveOriginals();
118
119         int handle_event();
120
121         ConvertWindow *gui;
122 };
123
124 class ConvertBeepOnDone : public BC_FPot
125 {
126 public:
127         ConvertBeepOnDone(ConvertWindow *gui, int x, int y);
128         void update();
129         int handle_event();
130
131         ConvertWindow *gui;
132 };
133
134 class ConvertPackageRenderer : public PackageRenderer
135 {
136 public:
137         ConvertPackageRenderer(ConvertRender *render);
138         ~ConvertPackageRenderer();
139
140         int get_master();
141         int get_result();
142         void set_result(int value);
143         void set_progress(int64_t value);
144         int progress_cancelled();
145
146         ConvertRender *render;
147 };
148
149 class ConvertProgress : public Thread
150 {
151 public:
152         ConvertProgress(MWindow *mwindow, ConvertRender *render);
153         ~ConvertProgress();
154
155         void run();
156
157         MWindow *mwindow;
158         ConvertRender *render;
159         int64_t last_value;
160 };
161
162 class ConvertWindow : public BC_Window
163 {
164 public:
165         ConvertWindow(MWindow *mwindow, ConvertDialog *dialog,
166                 int x, int y);
167         ~ConvertWindow();
168
169         void create_objects();
170
171         MWindow *mwindow;
172         ConvertDialog *dialog;
173
174         ConvertSuffixText *suffix_text;
175         ConvertFormatTools *format_tools;
176         ConvertRemoveOriginals *remove_originals;
177         ConvertBeepOnDone *beep_on_done;
178 };
179
180 class ConvertDialog : public BC_DialogThread
181 {
182 public:
183         ConvertDialog(MWindow *mwindow);
184         ~ConvertDialog();
185         BC_Window* new_gui();
186
187         void handle_close_event(int result);
188         void convert();
189
190         MWindow *mwindow;
191         ConvertWindow *gui;
192         Asset *asset;
193         char suffix[BCTEXTLEN];
194         ConvertRender *convert_render;
195
196         int orig_scale, new_scale;
197         int use_scaler, auto_scale;
198         int orig_w, orig_h;
199         int remove_originals;
200         float beep;
201 };
202
203 class ConvertBeep : public Thread
204 {
205 public:
206         enum { BEEP_SAMPLE_RATE=48000 };
207         typedef int16_t audio_data_t;
208         ConvertBeep(MWindow *mwindow);
209         ~ConvertBeep();
210
211         void run();
212         void start();
213         void stop(int wait);
214         void tone(double freq, double secs, double gain);
215
216         MWindow *mwindow;
217         double freq, secs, gain;
218         AudioDevice *audio;
219         int playing_audio, interrupted;
220         int audio_pos;
221 };
222
223 #endif