confirm prefs update, fix bg_pixmap sz, plugin layout tweaks
[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, int asset_scale);
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         int asset_scale;
92 };
93
94 class ProxyDialog : public BC_DialogThread
95 {
96 public:
97         ProxyDialog(MWindow *mwindow);
98         ~ProxyDialog();
99         BC_Window* new_gui();
100         void handle_close_event(int result);
101
102         void from_proxy();
103 // calculate possible sizes based on the original size
104         void calculate_sizes();
105         void scale_to_text(char *string, int scale);
106
107         MWindow *mwindow;
108         ProxyWindow *gui;
109         Asset *asset;
110         ProxyRender *proxy_render;
111
112         int orig_scale, new_scale;
113         int use_scaler, auto_scale;
114         int orig_w, orig_h;
115         int beep;
116         char *size_text[MAX_SIZES];
117         int size_factors[MAX_SIZES];
118         int total_sizes;
119 };
120
121 class ProxyUseScaler : public BC_CheckBox
122 {
123 public:
124         ProxyUseScaler(ProxyWindow *pwindow, int x, int y);
125         void update();
126         int handle_event();
127
128         ProxyWindow *pwindow;
129 };
130
131 class ProxyAutoScale : public BC_CheckBox
132 {
133 public:
134         ProxyAutoScale(ProxyWindow *pwindow, int x, int y);
135         void update();
136         int handle_event();
137
138         ProxyWindow *pwindow;
139 };
140
141 class ProxyBeepOnDone : public BC_CheckBox
142 {
143 public:
144         ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y);
145         void update();
146         int handle_event();
147
148         ProxyWindow *pwindow;
149 };
150
151 class ProxyFormatTools : public FormatTools
152 {
153 public:
154         ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
155
156         void update_format();
157         ProxyWindow *pwindow;
158 };
159
160 class ProxyMenu : public BC_PopupMenu
161 {
162 public:
163         ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
164                 int x, int y, int w, const char *text);
165         void update_sizes();
166         int handle_event();
167         MWindow *mwindow;
168         ProxyWindow *pwindow;
169 };
170
171
172 class ProxyTumbler : public BC_Tumbler
173 {
174 public:
175         ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
176
177         int handle_up_event();
178         int handle_down_event();
179         
180         ProxyWindow *pwindow;
181         MWindow *mwindow;
182 };
183
184
185 class ProxyWindow : public BC_Window
186 {
187 public:
188         ProxyWindow(MWindow *mwindow, ProxyDialog *dialog,
189                 int x, int y);
190         ~ProxyWindow();
191
192         void create_objects();
193         void update();
194
195         MWindow *mwindow;
196         ProxyDialog *dialog;
197         FormatTools *format_tools;
198         BC_Title *new_dimensions;
199         BC_Title *active_scale;
200         ProxyMenu *scale_factor;
201         ProxyUseScaler *use_scaler;
202         ProxyAutoScale *auto_scale;
203         ProxyBeepOnDone *beep_on_done;
204 };
205
206 class ProxyFarm;
207
208 class ProxyPackage : public LoadPackage
209 {
210 public:
211         ProxyPackage();
212         Indexable *orig_idxbl;
213         Asset *proxy_asset;
214 };
215
216 class ProxyClient : public LoadClient
217 {
218 public:
219         ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server);
220         ~ProxyClient();
221         void process_package(LoadPackage *package);
222
223         MWindow *mwindow;
224         ProxyRender *proxy_render;
225         RenderEngine *render_engine;
226         CICache *video_cache;
227         File *src_file;
228 };
229
230
231 class ProxyFarm : public LoadServer
232 {
233 public:
234         ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render, 
235                 ArrayList<Indexable*> *orig_idxbls, ArrayList<Asset*> *proxy_assets);
236         
237         void init_packages();
238         LoadClient* new_client();
239         LoadPackage* new_package();
240         
241         MWindow *mwindow;
242         ProxyRender *proxy_render;
243         ArrayList<Indexable*> *orig_idxbls;
244         ArrayList<Asset*> *proxy_assets;
245 };
246
247 class ProxyBeep : public Thread
248 {
249 public:
250         enum { BEEP_SAMPLE_RATE=48000 };
251         typedef int16_t audio_data_t;
252         ProxyBeep(MWindow *mwindow);
253         ~ProxyBeep();
254
255         void run();
256         void start();
257         void stop(int wait);
258         void tone(double freq, double secs, double gain);
259
260         MWindow *mwindow;
261         double freq, secs, gain;
262         AudioDevice *audio;
263         int playing_audio, interrupted;
264         int audio_pos;
265 };
266
267 #endif