sams latest icons, rework proxy settings
[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 "asset.h"
28 #include "bcdialog.h"
29 #include "cache.inc"
30 #include "file.inc"
31 #include "formattools.inc"
32 #include "loadbalance.h"
33 #include "mutex.inc"
34 #include "mwindow.inc"
35 #include "renderengine.inc"
36
37 class ProxyDialog;
38 class ProxyWindow;
39
40 #define MAX_SIZES 16
41
42 class ProxyMenuItem : public BC_MenuItem
43 {
44 public:
45         ProxyMenuItem(MWindow *mwindow);
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         void 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 };
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         void 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
112         int new_scale;
113         int orig_scale;
114         int use_scaler;
115         int auto_scale;
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 ProxyFormatTools : public FormatTools
142 {
143 public:
144         ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
145
146         void update_format();
147         ProxyWindow *pwindow;
148 };
149
150 class ProxyMenu : public BC_PopupMenu
151 {
152 public:
153         ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
154                 int x, int y, int w, const char *text);
155         void update_sizes();
156         int handle_event();
157         MWindow *mwindow;
158         ProxyWindow *pwindow;
159 };
160
161
162 class ProxyTumbler : public BC_Tumbler
163 {
164 public:
165         ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
166
167         int handle_up_event();
168         int handle_down_event();
169         
170         ProxyWindow *pwindow;
171         MWindow *mwindow;
172 };
173
174
175 class ProxyWindow : public BC_Window
176 {
177 public:
178         ProxyWindow(MWindow *mwindow, ProxyDialog *dialog,
179                 int x, int y);
180         ~ProxyWindow();
181
182         void create_objects();
183         void update();
184
185         MWindow *mwindow;
186         ProxyDialog *dialog;
187         FormatTools *format_tools;
188         BC_Title *new_dimensions;
189         ProxyMenu *scale_factor;
190         ProxyUseScaler *use_scaler;
191         ProxyAutoScale *auto_scale;
192 };
193
194 class ProxyFarm;
195
196 class ProxyPackage : public LoadPackage
197 {
198 public:
199         ProxyPackage();
200         Indexable *orig_idxbl;
201         Asset *proxy_asset;
202 };
203
204 class ProxyClient : public LoadClient
205 {
206 public:
207         ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server);
208         ~ProxyClient();
209         void process_package(LoadPackage *package);
210
211         MWindow *mwindow;
212         ProxyRender *proxy_render;
213         RenderEngine *render_engine;
214         CICache *video_cache;
215         File *src_file;
216 };
217
218
219 class ProxyFarm : public LoadServer
220 {
221 public:
222         ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render, 
223                 ArrayList<Indexable*> *orig_idxbls, ArrayList<Asset*> *proxy_assets);
224         
225         void init_packages();
226         LoadClient* new_client();
227         LoadPackage* new_package();
228         
229         MWindow *mwindow;
230         ProxyRender *proxy_render;
231         ArrayList<Indexable*> *orig_idxbls;
232         ArrayList<Asset*> *proxy_assets;
233 };
234
235 #endif