add mask color radio btn sel, fix del all mask btn, fix mask dflt kfrm draw name...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / proxy.h
1 #ifndef __PROXY_H__
2 #define __PROXY_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 // functions for handling proxies
25
26 #include "arraylist.h"
27 #include "audiodevice.inc"
28 #include "asset.h"
29 #include "bcdialog.h"
30 #include "cache.inc"
31 #include "file.inc"
32 #include "formattools.inc"
33 #include "loadbalance.h"
34 #include "mutex.inc"
35 #include "mwindow.inc"
36 #include "proxy.inc"
37 #include "renderengine.inc"
38
39 #define MAX_SIZES 16
40
41 class ProxyMenuItem : public BC_MenuItem
42 {
43 public:
44         ProxyMenuItem(MWindow *mwindow);
45         ~ProxyMenuItem();
46
47         int handle_event();
48         void create_objects();
49
50         MWindow *mwindow;
51         ProxyDialog *dialog;
52 };
53
54 class FromProxyMenuItem : public BC_MenuItem
55 {
56 public:
57         FromProxyMenuItem(MWindow *mwindow);
58
59         int handle_event();
60         MWindow *mwindow;
61 };
62
63
64 class ProxyRender
65 {
66 public:
67         ProxyRender(MWindow *mwindow, Asset *format_asset);
68         ~ProxyRender();
69         void to_proxy_path(char *new_path, Indexable *indexable, int scale);
70         static int from_proxy_path(char *new_path, Indexable *indexable, int scale);
71
72         ArrayList<Indexable *> orig_idxbls;   // originals which match the proxy assets
73         ArrayList<Indexable *> orig_proxies;  // proxy assets
74         Asset *add_original(Indexable *idxbl, int new_scale);
75         ArrayList<Indexable *> needed_idxbls; // originals which match the needed_assets
76         ArrayList<Asset *> needed_proxies;    // assets which must be created
77         void add_needed(Indexable *idxbl, Asset *proxy);
78
79         int create_needed_proxies(int new_scale);
80 // increment the frame count by 1
81         void update_progress();
82 // if user canceled progress bar
83         int is_canceled();
84
85         MWindow *mwindow;
86         Asset *format_asset;
87         MainProgressBar *progress;
88         Mutex *counter_lock;
89         int total_rendered;
90         int failed, canceled;
91 };
92
93 class ProxyDialog : public BC_DialogThread
94 {
95 public:
96         ProxyDialog(MWindow *mwindow);
97         ~ProxyDialog();
98         BC_Window* new_gui();
99         void handle_close_event(int result);
100
101         void from_proxy();
102 // calculate possible sizes based on the original size
103         void calculate_sizes();
104         void scale_to_text(char *string, int scale);
105
106         MWindow *mwindow;
107         ProxyWindow *gui;
108         Asset *asset;
109         ProxyRender *proxy_render;
110
111         int orig_scale, new_scale;
112         int use_scaler, auto_scale;
113         int orig_w, orig_h;
114         int beep;
115         char *size_text[MAX_SIZES];
116         int size_factors[MAX_SIZES];
117         int total_sizes;
118 };
119
120 class ProxyUseScaler : public BC_CheckBox
121 {
122 public:
123         ProxyUseScaler(ProxyWindow *pwindow, int x, int y);
124         void update();
125         int handle_event();
126
127         ProxyWindow *pwindow;
128 };
129
130 class ProxyAutoScale : public BC_CheckBox
131 {
132 public:
133         ProxyAutoScale(ProxyWindow *pwindow, int x, int y);
134         void update();
135         int handle_event();
136
137         ProxyWindow *pwindow;
138 };
139
140 class ProxyBeepOnDone : public BC_CheckBox
141 {
142 public:
143         ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y);
144         void update();
145         int handle_event();
146
147         ProxyWindow *pwindow;
148 };
149
150 class ProxyFormatTools : public FormatTools
151 {
152 public:
153         ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
154
155         void update_format();
156         ProxyWindow *pwindow;
157 };
158
159 class ProxyMenu : public BC_PopupMenu
160 {
161 public:
162         ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
163                 int x, int y, int w, const char *text);
164         void update_sizes();
165         int handle_event();
166         MWindow *mwindow;
167         ProxyWindow *pwindow;
168 };
169
170
171 class ProxyTumbler : public BC_Tumbler
172 {
173 public:
174         ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
175
176         int handle_up_event();
177         int handle_down_event();
178         
179         ProxyWindow *pwindow;
180         MWindow *mwindow;
181 };
182
183
184 class ProxyWindow : public BC_Window
185 {
186 public:
187         ProxyWindow(MWindow *mwindow, ProxyDialog *dialog,
188                 int x, int y);
189         ~ProxyWindow();
190
191         void create_objects();
192         void update();
193
194         MWindow *mwindow;
195         ProxyDialog *dialog;
196         FormatTools *format_tools;
197         BC_Title *new_dimensions;
198         BC_Title *active_scale;
199         ProxyMenu *scale_factor;
200         ProxyUseScaler *use_scaler;
201         ProxyAutoScale *auto_scale;
202         ProxyBeepOnDone *beep_on_done;
203 };
204
205 class ProxyFarm;
206
207 class ProxyPackage : public LoadPackage
208 {
209 public:
210         ProxyPackage();
211         Indexable *orig_idxbl;
212         Asset *proxy_asset;
213 };
214
215 class ProxyClient : public LoadClient
216 {
217 public:
218         ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server);
219         ~ProxyClient();
220         void process_package(LoadPackage *package);
221
222         MWindow *mwindow;
223         ProxyRender *proxy_render;
224         RenderEngine *render_engine;
225         CICache *video_cache;
226         File *src_file;
227 };
228
229
230 class ProxyFarm : public LoadServer
231 {
232 public:
233         ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render, 
234                 ArrayList<Indexable*> *orig_idxbls, ArrayList<Asset*> *proxy_assets);
235         
236         void init_packages();
237         LoadClient* new_client();
238         LoadPackage* new_package();
239         
240         MWindow *mwindow;
241         ProxyRender *proxy_render;
242         ArrayList<Indexable*> *orig_idxbls;
243         ArrayList<Asset*> *proxy_assets;
244 };
245
246 class ProxyBeep : public Thread
247 {
248 public:
249         enum { BEEP_SAMPLE_RATE=48000 };
250         typedef int16_t audio_data_t;
251         ProxyBeep(MWindow *mwindow);
252         ~ProxyBeep();
253
254         void run();
255         void start();
256         void stop(int wait);
257         void tone(double freq, double secs, double gain);
258
259         MWindow *mwindow;
260         double freq, secs, gain;
261         AudioDevice *audio;
262         int playing_audio, interrupted;
263         int audio_pos;
264 };
265
266 #endif