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