add proxy scaler option, add sams icons
[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 "formattools.inc"
30 #include "loadbalance.h"
31 #include "mutex.inc"
32 #include "mwindow.inc"
33
34 class ProxyThread;
35 class ProxyWindow;
36
37 #define MAX_SIZES 16
38
39 class ProxyMenuItem : public BC_MenuItem
40 {
41 public:
42         ProxyMenuItem(MWindow *mwindow);
43
44         int handle_event();
45         void create_objects();
46
47         MWindow *mwindow;
48         ProxyThread *thread;
49 };
50
51 class FromProxyMenuItem : public BC_MenuItem
52 {
53 public:
54         FromProxyMenuItem(MWindow *mwindow);
55
56         int handle_event();
57         MWindow *mwindow;
58 };
59
60 class ProxyThread : public BC_DialogThread
61 {
62 public:
63         ProxyThread(MWindow *mwindow);
64         ~ProxyThread();
65         BC_Window* new_gui();
66         void handle_close_event(int result);
67         static void to_proxy_path(char *new_path, Asset *asset, int scale);
68         static void from_proxy_path(char *new_path, Asset *asset, int scale);
69         void from_proxy();
70         void to_proxy();
71 // increment the frame count by 1
72         void update_progress();
73 // if user canceled progress bar
74         int is_canceled();
75 // calculate possible sizes based on the original size
76         void calculate_sizes();
77         void scale_to_text(char *string, int scale);
78
79         MWindow *mwindow;
80         ProxyWindow *gui;
81         MainProgressBar *progress;
82         Mutex *counter_lock;
83         Asset *asset;
84         int new_scale;
85         int orig_scale;
86         int total_rendered;
87         int failed;
88         int use_scaler;
89         char *size_text[MAX_SIZES];
90         int size_factors[MAX_SIZES];
91         int total_sizes;
92 };
93
94 class ProxyUseScaler : public BC_CheckBox
95 {
96 public:
97         ProxyUseScaler(MWindow *mwindow, ProxyWindow *pwindow,
98                 int x, int y);
99         void update();
100         int handle_event();
101         MWindow *mwindow;
102         ProxyWindow *pwindow;
103 };
104
105 class ProxyFormatTools : public FormatTools
106 {
107 public:
108         ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
109
110         void update_format();
111         ProxyWindow *pwindow;
112 };
113
114 class ProxyMenu : public BC_PopupMenu
115 {
116 public:
117         ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
118                 int x, int y, int w, const char *text);
119         void update_sizes();
120         int handle_event();
121         MWindow *mwindow;
122         ProxyWindow *pwindow;
123 };
124
125
126 class ProxyTumbler : public BC_Tumbler
127 {
128 public:
129         ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
130
131         int handle_up_event();
132         int handle_down_event();
133         
134         ProxyWindow *pwindow;
135         MWindow *mwindow;
136 };
137
138
139 class ProxyWindow : public BC_Window
140 {
141 public:
142         ProxyWindow(MWindow *mwindow, ProxyThread *thread,
143                 int x, int y);
144         ~ProxyWindow();
145
146         void create_objects();
147         void update();
148
149         MWindow *mwindow;
150         ProxyThread *thread;
151         FormatTools *format_tools;
152         BC_Title *new_dimensions;
153         ProxyMenu *scale_factor;
154         ProxyUseScaler *use_scaler;
155 };
156
157 class ProxyFarm;
158
159 class ProxyPackage : public LoadPackage
160 {
161 public:
162         ProxyPackage();
163         Asset *orig_asset;
164         Asset *proxy_asset;
165 };
166
167 class ProxyClient : public LoadClient
168 {
169 public:
170         ProxyClient(MWindow *mwindow, ProxyThread *thread,
171                 ProxyFarm *server);
172         void process_package(LoadPackage *package);
173
174         MWindow *mwindow;
175         ProxyThread *thread;
176 };
177
178
179 class ProxyFarm : public LoadServer
180 {
181 public:
182         ProxyFarm(MWindow *mwindow, ProxyThread *thread, 
183                 ArrayList<Asset*> *proxy_assets, ArrayList<Asset*> *orig_assets);
184         
185         void init_packages();
186         LoadClient* new_client();
187         LoadPackage* new_package();
188         
189         MWindow *mwindow;
190         ProxyThread *thread;
191         ArrayList<Asset*> *proxy_assets;
192         ArrayList<Asset*> *orig_assets;
193 };
194
195 #endif