6 * Copyright (C) 2015 Adam Williams <broadcast at earthling dot net>
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.
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.
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
24 // functions for handling proxies
26 #include "arraylist.h"
27 #include "audiodevice.inc"
32 #include "formattools.inc"
33 #include "loadbalance.h"
35 #include "mwindow.inc"
37 #include "renderengine.inc"
41 class ProxyMenuItem : public BC_MenuItem
44 ProxyMenuItem(MWindow *mwindow);
48 void create_objects();
54 class FromProxyMenuItem : public BC_MenuItem
57 FromProxyMenuItem(MWindow *mwindow);
67 ProxyRender(MWindow *mwindow, Asset *format_asset);
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);
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);
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
87 MainProgressBar *progress;
93 class ProxyDialog : public BC_DialogThread
96 ProxyDialog(MWindow *mwindow);
99 void handle_close_event(int result);
102 // calculate possible sizes based on the original size
103 void calculate_sizes();
104 void scale_to_text(char *string, int scale);
109 ProxyRender *proxy_render;
111 int orig_scale, new_scale;
112 int use_scaler, auto_scale;
115 char *size_text[MAX_SIZES];
116 int size_factors[MAX_SIZES];
120 class ProxyUseScaler : public BC_CheckBox
123 ProxyUseScaler(ProxyWindow *pwindow, int x, int y);
127 ProxyWindow *pwindow;
130 class ProxyAutoScale : public BC_CheckBox
133 ProxyAutoScale(ProxyWindow *pwindow, int x, int y);
137 ProxyWindow *pwindow;
140 class ProxyBeepOnDone : public BC_CheckBox
143 ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y);
147 ProxyWindow *pwindow;
150 class ProxyFormatTools : public FormatTools
153 ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
155 void update_format();
156 ProxyWindow *pwindow;
159 class ProxyMenu : public BC_PopupMenu
162 ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
163 int x, int y, int w, const char *text);
167 ProxyWindow *pwindow;
171 class ProxyTumbler : public BC_Tumbler
174 ProxyTumbler(MWindow *mwindow, ProxyWindow *pwindow, int x, int y);
176 int handle_up_event();
177 int handle_down_event();
179 ProxyWindow *pwindow;
184 class ProxyWindow : public BC_Window
187 ProxyWindow(MWindow *mwindow, ProxyDialog *dialog,
191 void create_objects();
196 FormatTools *format_tools;
197 BC_Title *new_dimensions;
198 BC_Title *active_scale;
199 ProxyMenu *scale_factor;
200 ProxyUseScaler *use_scaler;
201 ProxyAutoScale *auto_scale;
202 ProxyBeepOnDone *beep_on_done;
207 class ProxyPackage : public LoadPackage
211 Indexable *orig_idxbl;
215 class ProxyClient : public LoadClient
218 ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server);
220 void process_package(LoadPackage *package);
223 ProxyRender *proxy_render;
224 RenderEngine *render_engine;
225 CICache *video_cache;
230 class ProxyFarm : public LoadServer
233 ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render,
234 ArrayList<Indexable*> *orig_idxbls, ArrayList<Asset*> *proxy_assets);
236 void init_packages();
237 LoadClient* new_client();
238 LoadPackage* new_package();
241 ProxyRender *proxy_render;
242 ArrayList<Indexable*> *orig_idxbls;
243 ArrayList<Asset*> *proxy_assets;
246 class ProxyBeep : public Thread
249 enum { BEEP_SAMPLE_RATE=48000 };
250 typedef int16_t audio_data_t;
251 ProxyBeep(MWindow *mwindow);
257 void tone(double freq, double secs, double gain);
260 double freq, secs, gain;
262 int playing_audio, interrupted;