add proxy
[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         char *size_text[MAX_SIZES];
89         int size_factors[MAX_SIZES];
90         int total_sizes;
91 };
92
93 class ProxyReset : public BC_GenericButton
94 {
95 public:
96         ProxyReset(MWindow *mwindow, ProxyWindow *pwindow,
97                 int x, int y);
98         int handle_event();
99         MWindow *mwindow;
100         ProxyWindow *pwindow;
101 };
102
103 class ProxyMenu : public BC_PopupMenu
104 {
105 public:
106         ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
107                 int x, int y, int w, const char *text);
108         int handle_event();
109         MWindow *mwindow;
110         ProxyWindow *pwindow;
111 };
112
113
114 class ProxyTumbler : public BC_Tumbler
115 {
116 public:
117         ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
118
119         int handle_up_event();
120         int handle_down_event();
121         
122         ProxyWindow *pwindow;
123         MWindow *mwindow;
124 };
125
126
127 class ProxyWindow : public BC_Window
128 {
129 public:
130         ProxyWindow(MWindow *mwindow, ProxyThread *thread,
131                 int x, int y);
132         ~ProxyWindow();
133
134         void create_objects();
135         void update();
136
137         MWindow *mwindow;
138         ProxyThread *thread;
139         FormatTools *format_tools;
140         BC_Title *new_dimensions;
141         BC_PopupMenu *scale_factor;
142         ProxyReset *reset;
143 };
144
145 class ProxyFarm;
146
147 class ProxyPackage : public LoadPackage
148 {
149 public:
150         ProxyPackage();
151         Asset *orig_asset;
152         Asset *proxy_asset;
153 };
154
155 class ProxyClient : public LoadClient
156 {
157 public:
158         ProxyClient(MWindow *mwindow, ProxyThread *thread,
159                 ProxyFarm *server);
160         void process_package(LoadPackage *package);
161
162         MWindow *mwindow;
163         ProxyThread *thread;
164 };
165
166
167 class ProxyFarm : public LoadServer
168 {
169 public:
170         ProxyFarm(MWindow *mwindow, ProxyThread *thread, 
171                 ArrayList<Asset*> *proxy_assets, ArrayList<Asset*> *orig_assets);
172         
173         void init_packages();
174         LoadClient* new_client();
175         LoadPackage* new_package();
176         
177         MWindow *mwindow;
178         ProxyThread *thread;
179         ArrayList<Asset*> *proxy_assets;
180         ArrayList<Asset*> *orig_assets;
181 };
182
183 #endif