add proxy quick switch, folder lock, shortcuts update, bsd GL tweak
[goodguy/history.git] / cinelerra-5.1 / cinelerra / proxy.h
index 5436daf982502513ec22efb7125311ea6f12af0b..c98f2e04a5cea9168e947c39a2c4815919c4c3e5 100644 (file)
 // functions for handling proxies
 
 #include "arraylist.h"
+#include "audiodevice.inc"
 #include "asset.h"
 #include "bcdialog.h"
+#include "cache.inc"
+#include "file.inc"
 #include "formattools.inc"
 #include "loadbalance.h"
 #include "mutex.inc"
 #include "mwindow.inc"
-
-class ProxyThread;
-class ProxyWindow;
+#include "proxy.inc"
+#include "renderengine.inc"
 
 #define MAX_SIZES 16
 
@@ -40,12 +42,13 @@ class ProxyMenuItem : public BC_MenuItem
 {
 public:
        ProxyMenuItem(MWindow *mwindow);
+       ~ProxyMenuItem();
 
        int handle_event();
        void create_objects();
 
        MWindow *mwindow;
-       ProxyThread *thread;
+       ProxyDialog *dialog;
 };
 
 class FromProxyMenuItem : public BC_MenuItem
@@ -57,46 +60,100 @@ public:
        MWindow *mwindow;
 };
 
-class ProxyThread : public BC_DialogThread
+
+class ProxyRender
 {
 public:
-       ProxyThread(MWindow *mwindow);
-       ~ProxyThread();
-       BC_Window* new_gui();
-       void handle_close_event(int result);
-       static void to_proxy_path(char *new_path, Asset *asset, int scale);
-       static void from_proxy_path(char *new_path, Asset *asset, int scale);
-       void from_proxy();
-       void to_proxy();
+       ProxyRender(MWindow *mwindow, Asset *format_asset);
+       ~ProxyRender();
+       void to_proxy_path(char *new_path, Indexable *indexable, int scale);
+       static int from_proxy_path(char *new_path, Indexable *indexable, int scale);
+
+       ArrayList<Indexable *> orig_idxbls;   // originals which match the proxy assets
+       ArrayList<Indexable *> orig_proxies;  // proxy assets
+       Asset *add_original(Indexable *idxbl, int new_scale);
+       ArrayList<Indexable *> needed_idxbls; // originals which match the needed_assets
+       ArrayList<Asset *> needed_proxies;    // assets which must be created
+       void add_needed(Indexable *idxbl, Asset *proxy);
+
+       int create_needed_proxies(int new_scale);
 // increment the frame count by 1
        void update_progress();
 // if user canceled progress bar
        int is_canceled();
+
+       MWindow *mwindow;
+       Asset *format_asset;
+       MainProgressBar *progress;
+       Mutex *counter_lock;
+       int total_rendered;
+       int failed, canceled;
+};
+
+class ProxyDialog : public BC_DialogThread
+{
+public:
+       ProxyDialog(MWindow *mwindow);
+       ~ProxyDialog();
+       BC_Window* new_gui();
+       void handle_close_event(int result);
+
+       void from_proxy();
 // calculate possible sizes based on the original size
        void calculate_sizes();
        void scale_to_text(char *string, int scale);
 
        MWindow *mwindow;
        ProxyWindow *gui;
-       MainProgressBar *progress;
-       Mutex *counter_lock;
        Asset *asset;
+       ProxyRender *proxy_render;
+
        int new_scale;
        int orig_scale;
-       int total_rendered;
-       int failed;
+       int use_scaler;
+       int auto_scale;
+       int beep;
        char *size_text[MAX_SIZES];
        int size_factors[MAX_SIZES];
        int total_sizes;
 };
 
-class ProxyReset : public BC_GenericButton
+class ProxyUseScaler : public BC_CheckBox
 {
 public:
-       ProxyReset(MWindow *mwindow, ProxyWindow *pwindow,
-               int x, int y);
+       ProxyUseScaler(ProxyWindow *pwindow, int x, int y);
+       void update();
        int handle_event();
-       MWindow *mwindow;
+
+       ProxyWindow *pwindow;
+};
+
+class ProxyAutoScale : public BC_CheckBox
+{
+public:
+       ProxyAutoScale(ProxyWindow *pwindow, int x, int y);
+       void update();
+       int handle_event();
+
+       ProxyWindow *pwindow;
+};
+
+class ProxyBeepOnDone : public BC_CheckBox
+{
+public:
+       ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y);
+       void update();
+       int handle_event();
+
+       ProxyWindow *pwindow;
+};
+
+class ProxyFormatTools : public FormatTools
+{
+public:
+       ProxyFormatTools(MWindow *mwindow, ProxyWindow *window, Asset *asset);
+
+       void update_format();
        ProxyWindow *pwindow;
 };
 
@@ -105,6 +162,7 @@ class ProxyMenu : public BC_PopupMenu
 public:
        ProxyMenu(MWindow *mwindow, ProxyWindow *pwindow,
                int x, int y, int w, const char *text);
+       void update_sizes();
        int handle_event();
        MWindow *mwindow;
        ProxyWindow *pwindow;
@@ -127,7 +185,7 @@ public:
 class ProxyWindow : public BC_Window
 {
 public:
-       ProxyWindow(MWindow *mwindow, ProxyThread *thread,
+       ProxyWindow(MWindow *mwindow, ProxyDialog *dialog,
                int x, int y);
        ~ProxyWindow();
 
@@ -135,11 +193,14 @@ public:
        void update();
 
        MWindow *mwindow;
-       ProxyThread *thread;
+       ProxyDialog *dialog;
        FormatTools *format_tools;
        BC_Title *new_dimensions;
-       BC_PopupMenu *scale_factor;
-       ProxyReset *reset;
+       BC_Title *active_scale;
+       ProxyMenu *scale_factor;
+       ProxyUseScaler *use_scaler;
+       ProxyAutoScale *auto_scale;
+       ProxyBeepOnDone *beep_on_done;
 };
 
 class ProxyFarm;
@@ -148,36 +209,59 @@ class ProxyPackage : public LoadPackage
 {
 public:
        ProxyPackage();
-       Asset *orig_asset;
+       Indexable *orig_idxbl;
        Asset *proxy_asset;
 };
 
 class ProxyClient : public LoadClient
 {
 public:
-       ProxyClient(MWindow *mwindow, ProxyThread *thread,
-               ProxyFarm *server);
+       ProxyClient(MWindow *mwindow, ProxyRender *proxy_render, ProxyFarm *server);
+       ~ProxyClient();
        void process_package(LoadPackage *package);
 
        MWindow *mwindow;
-       ProxyThread *thread;
+       ProxyRender *proxy_render;
+       RenderEngine *render_engine;
+       CICache *video_cache;
+       File *src_file;
 };
 
 
 class ProxyFarm : public LoadServer
 {
 public:
-       ProxyFarm(MWindow *mwindow, ProxyThread *thread
-               ArrayList<Asset*> *proxy_assets, ArrayList<Asset*> *orig_assets);
+       ProxyFarm(MWindow *mwindow, ProxyRender *proxy_render
+               ArrayList<Indexable*> *orig_idxbls, ArrayList<Asset*> *proxy_assets);
        
        void init_packages();
        LoadClient* new_client();
        LoadPackage* new_package();
        
        MWindow *mwindow;
-       ProxyThread *thread;
+       ProxyRender *proxy_render;
+       ArrayList<Indexable*> *orig_idxbls;
        ArrayList<Asset*> *proxy_assets;
-       ArrayList<Asset*> *orig_assets;
+};
+
+class ProxyBeep : public Thread
+{
+public:
+       enum { BEEP_SAMPLE_RATE=48000 };
+       typedef int16_t audio_data_t;
+       ProxyBeep(MWindow *mwindow);
+       ~ProxyBeep();
+
+       void run();
+       void start();
+       void stop(int wait);
+       void tone(double freq, double secs, double gain);
+
+       MWindow *mwindow;
+       double freq, secs, gain;
+       AudioDevice *audio;
+       int playing_audio, interrupted;
+       int audio_pos;
 };
 
 #endif