no longer need ffmpeg patch0 which was for Termux
[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.h"
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, Asset *asset, 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 beeper_on;
116         float beeper_volume;
117         char *size_text[MAX_SIZES];
118         int size_factors[MAX_SIZES];
119         int total_sizes;
120 };
121
122 class ProxyUseScaler : public BC_CheckBox
123 {
124 public:
125         ProxyUseScaler(ProxyWindow *pwindow, int x, int y);
126         void update();
127         int handle_event();
128
129         ProxyWindow *pwindow;
130 };
131
132 class ProxyAutoScale : public BC_CheckBox
133 {
134 public:
135         ProxyAutoScale(ProxyWindow *pwindow, int x, int y);
136         void update();
137         int handle_event();
138
139         ProxyWindow *pwindow;
140 };
141
142 class ProxyBeepOnDone : public BC_CheckBox
143 {
144 public:
145         ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y);
146         int handle_event();
147
148         ProxyWindow *pwindow;
149 };
150
151 class ProxyBeepVolume : public BC_FSlider
152 {
153 public:
154         ProxyBeepVolume(ProxyWindow *pwindow, int x, int y);
155         int handle_event();
156
157         ProxyWindow *pwindow;
158 };
159
160 class ProxyFormatTools : public FormatTools
161 {
162 public:
163         ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
164
165         void update_format();
166         ProxyWindow *pwindow;
167 };
168
169 class ProxyMenu : public BC_PopupMenu
170 {
171 public:
172         ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
173                 int x, int y, int w, const char *text);
174         void update_sizes();
175         int handle_event();
176         MWindow *mwindow;
177         ProxyWindow *pwindow;
178 };
179
180
181 class ProxyTumbler : public BC_Tumbler
182 {
183 public:
184         ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
185
186         int handle_up_event();
187         int handle_down_event();
188         
189         ProxyWindow *pwindow;
190         MWindow *mwindow;
191 };
192
193
194 class ProxyWindow : public BC_Window
195 {
196 public:
197         ProxyWindow(MWindow *mwindow, ProxyDialog *dialog,
198                 int x, int y);
199         ~ProxyWindow();
200
201         void create_objects();
202         void update();
203
204         MWindow *mwindow;
205         ProxyDialog *dialog;
206         BC_TitleBar *title_bar1, *title_bar2;
207         FormatTools *format_tools;
208         BC_Title *new_dimensions;
209         BC_Title *active_scale;
210         BC_Title *active_state;
211         ProxyMenu *scale_factor;
212         ProxyUseScaler *use_scaler;
213         ProxyAutoScale *auto_scale;
214         ProxyBeepOnDone *beep_on_done;
215         ProxyBeepVolume *beep_volume;
216 };
217
218 class ProxyFarm;
219
220 class ProxyPackage : public LoadPackage
221 {
222 public:
223         ProxyPackage();
224         Indexable *orig_idxbl;
225         Asset *proxy_asset;
226 };
227
228 class ProxyClient : public LoadClient
229 {
230 public:
231         ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server);
232         ~ProxyClient();
233         void process_package(LoadPackage *package);
234
235         MWindow *mwindow;
236         ProxyRender *proxy_render;
237         RenderEngine *render_engine;
238         CICache *video_cache;
239         File *src_file;
240 };
241
242
243 class ProxyFarm : public LoadServer
244 {
245 public:
246         ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render, 
247                 ArrayList<Indexable*> *orig_idxbls, ArrayList<Asset*> *proxy_assets);
248         
249         void init_packages();
250         LoadClient* new_client();
251         LoadPackage* new_package();
252         
253         MWindow *mwindow;
254         ProxyRender *proxy_render;
255         ArrayList<Indexable*> *orig_idxbls;
256         ArrayList<Asset*> *proxy_assets;
257 };
258
259 #endif