add toggles for the windows by Andrew
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindow.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef MWINDOW_H
22 #define MWINDOW_H
23
24 #include <stdio.h>
25 #include <stdint.h>
26
27 #include "apatchgui.h"
28 #include "arraylist.h"
29 #include "asset.inc"
30 #include "assets.inc"
31 #include "audiodevice.inc"
32 #include "autos.inc"
33 #include "awindow.inc"
34 #include "batchrender.inc"
35 #include "bcwindowbase.inc"
36 #include "bdcreate.inc"
37 #include "brender.inc"
38 #include "cache.inc"
39 #include "channel.inc"
40 #include "channeldb.inc"
41 #include "commercials.inc"
42 #include "convert.inc"
43 #include "cwindow.inc"
44 #include "bchash.inc"
45 #include "devicedvbinput.inc"
46 #include "devicempeginput.inc"
47 #include "dvdcreate.inc"
48 #include "edit.inc"
49 #include "edl.inc"
50 #include "edlsession.inc"
51 #include "exportedl.inc"
52 #include "filesystem.inc"
53 #include "filexml.inc"
54 #include "framecache.inc"
55 #include "gwindow.inc"
56 #include "indexable.inc"
57 #include "keyframegui.inc"
58 #include "levelwindow.inc"
59 #include "loadmode.inc"
60 #include "mainerror.inc"
61 #include "mainindexes.inc"
62 #include "mainprogress.inc"
63 #include "mainsession.inc"
64 #include "mainundo.inc"
65 #include "maxchannels.h"
66 #include "mixersalign.inc"
67 #include "mutex.inc"
68 #include "mwindow.inc"
69 #include "mwindowgui.inc"
70 #include "new.inc"
71 #include "patchbay.inc"
72 #include "playback3d.inc"
73 #include "playbackengine.inc"
74 #include "plugin.inc"
75 #include "pluginclient.inc"
76 #include "pluginfclient.inc"
77 #include "pluginserver.inc"
78 #include "pluginset.inc"
79 #include "preferences.inc"
80 #include "preferencesthread.inc"
81 #include "proxy.inc"
82 #include "record.inc"
83 #include "recordlabel.inc"
84 #include "render.inc"
85 #include "sharedlocation.inc"
86 #include "sighandler.inc"
87 #include "splashgui.inc"
88 #include "shuttle.inc"
89 #include "theme.inc"
90 #include "thread.h"
91 #include "threadloader.inc"
92 #include "timebar.inc"
93 #include "tipwindow.inc"
94 #include "track.inc"
95 #include "tracking.inc"
96 #include "tracks.inc"
97 #include "transition.inc"
98 #include "transportque.inc"
99 #include "videowindow.inc"
100 #include "vpatchgui.h"
101 #include "vwindow.inc"
102 #include "zwindow.inc"
103 #include "wwindow.inc"
104 #include "wavecache.inc"
105 #include "wintv.inc"
106 #include "x10tv.inc"
107
108 #define FONT_SEARCHPATH "fonts"
109
110 class StackItem
111 {
112 public:
113         EDL *edl, *new_edl;
114         Indexable *idxbl;
115         Edit *edit;
116         MainUndo *undo;
117         int64_t mtime;
118         double duration;
119 };
120
121 class Stack : public ArrayList<StackItem>
122 {
123 public:
124 };
125
126
127 #define BEEP_SAMPLE_RATE 48000
128
129 class Beeper : public Thread
130 {
131 public:
132         typedef int16_t audio_data_t;
133         Beeper(MWindow *mwindow);
134         ~Beeper();
135
136         void run();
137         void start();
138         void stop(int wait);
139         void tone(double freq, double secs, double gain);
140
141         MWindow *mwindow;
142         double freq, secs, gain;
143         AudioDevice *audio;
144         int playing_audio, interrupted;
145         int audio_pos;
146 };
147
148
149 class DrawTrackMovement : public Thread
150 {
151 public:
152         DrawTrackMovement(MWindow *mwindow);
153         ~DrawTrackMovement();
154         void run();
155
156         MWindow *mwindow;
157 };
158
159 class ConfirmRefWindow : public BC_Window
160 {
161 public:
162         ConfirmRefWindow(MWindow *mwindow, char *path,
163                         int px, int py, int cw, int ch);
164         ~ConfirmRefWindow();
165         void create_objects();
166
167         MWindow *mwindow;
168         const char *path;
169 };
170
171
172 class MWindow : public Thread
173 {
174 public:
175         MWindow();
176         ~MWindow();
177
178 // ======================================== initialization commands
179         void create_objects(int want_gui,
180                 int want_new,
181                 char *config_path);
182         int uses_opengl();
183         void show_splash();
184         void hide_splash();
185         void start();
186         void run();
187
188         int run_script(FileXML *script);
189         int new_project();
190         int delete_project(int flash = 1);
191         void quit();
192         int restart() { return restart_status; }
193
194         int load_defaults();
195         int save_defaults();
196         int set_filename(const char *filename);
197         int set_titlebar(const char *filename);
198 // Total vertical pixels in timeline
199         int get_tracks_height();
200 // Total horizontal pixels in timeline
201         int get_tracks_width();
202 // session stack
203         void stack_push(EDL *edl, Indexable *idxbl);
204         void stack_pop();
205         int save(EDL *edl, char *filename, int stat);
206         int save(int save_as);
207         void show_plugins();
208         void clip_to_media();
209         void media_to_clip();
210         int create_ref(Asset *asset, EDL *ref);
211 // Show windows
212         void show_vwindow(int raise);
213         void hide_vwindow();
214         void show_awindow();
215         void hide_awindow();
216         void show_cwindow();
217         void hide_cwindow();
218         void show_lwindow();
219         void hide_lwindow();
220         void show_gwindow();
221         void hide_gwindow();
222         void restore_windows();
223         void load_layout(const char *layout);
224         void save_layout(const char *layout);
225         void delete_layout(const char *layout);
226         int tile_windows(int window_config);
227         char *get_cwindow_display();
228         void set_screens(int value);
229         int asset_to_edl(EDL *new_edl,
230                 Asset *new_asset,
231                 RecordLabels *labels = 0);
232
233 // Entry point to insert assets and insert edls.  Called by TrackCanvas
234 // and AssetPopup when assets are dragged in from AWindow.
235 // Takes the drag vectors from MainSession and
236 // pastes either assets or clips depending on which is full.
237 // Returns 1 if the vectors were full
238         int paste_assets(double position, Track *dest_track, int overwrite);
239
240 // Insert the assets at a point in the EDL.  Called by menueffects,
241 // render, and CWindow drop but recording calls paste_edls directly for
242 // labels.
243         void load_assets(ArrayList<Indexable*> *new_assets,
244                 double position,
245                 int load_mode,
246                 Track *first_track /* = 0 */,
247                 RecordLabels *labels /* = 0 */,
248                 int edit_labels,
249                 int edit_plugins,
250                 int edit_autos,
251                 int overwrite);
252         int paste_edls(ArrayList<EDL*> *new_edls,
253                 int load_mode,
254                 Track *first_track /* = 0 */,
255                 double current_position /* = -1 */,
256                 int edit_labels,
257                 int edit_plugins,
258                 int edit_autos,
259                 int overwrite);
260         void collect_effects();
261         void paste_effects();
262
263 // Reset everything for a load
264         void update_project(int load_mode);
265         void update_preferences(Preferences *prefs);
266         void update_vwindow();
267 // Fit selected time to horizontal display range
268         void fit_selection();
269 // Fit selected autos to the vertical display range
270         void fit_autos(int all);
271         void change_currentautorange(int autogrouptype, int increment, int changemax);
272         void update_autorange(int type, int increment, int use_max);
273         void expand_autos(int changeall, int domin, int domax);
274         void shrink_autos(int changeall, int domin, int domax);
275 // move the window to include the cursor
276         void find_cursor();
277 // Search plugindb and put results in argument
278         static void search_plugindb(int do_audio,
279                 int do_video,
280                 int is_realtime,
281                 int is_transition,
282                 int is_theme,
283                 ArrayList<PluginServer*> &results);
284 // Find the plugin whose title matches title and return it
285         static PluginServer* scan_plugindb(char *title,
286                 int data_type);
287         static void fix_plugin_title(char *title);
288         static int plugin_exists(const char *plugin_path, ArrayList<PluginServer*> &plugins);
289         static int plugin_exists(char *plugin_path);
290         void dump_plugindb(FILE *fp);
291         void stop_playback(int wait);
292         void stop_transport();
293         void undo_before(const char *description = "", void *creator = 0);
294         void undo_after(const char *description, uint32_t load_flags, int changes_made = 1);
295
296         void handle_mixers(EDL *edl, int command, int wait_tracking,
297                 int use_inout, int toggle_audio, int loop_play, float speed);
298         ZWindow *create_mixer(Indexable *indexable, double position);
299         void create_mixers(double position = 0);
300         void refresh_mixers(int dir=1);
301         void stop_mixers();
302         void close_mixers(int result=1);
303         void open_mixers();
304         ZWindow *get_mixer(Mixer *&mixer);
305         ZWindow *get_mixer(int idx);
306         void close_mixer(ZWindow *zwindow);
307         int mixer_track_active(Track *track);
308         void update_mixer_tracks();
309         void start_mixer();
310         int select_zwindow(ZWindow *zwindow);
311         void tile_mixers();
312         void tile_mixers(int x1, int x2, int y1, int y2);
313         int masters_to_mixers();
314         void mix_masters();
315         void set_gang_tracks(int v);
316         int load_filenames(ArrayList<char*> *filenames,
317                 int load_mode = LOADMODE_REPLACE,
318                 int edl_mode = LOADMODE_EDL_CLIP,
319 // Cause the project filename on the top of the window to be updated.
320 // Not wanted for loading backups.
321                 int update_filename = 1);
322
323 // Print out plugins which are referenced in the EDL but not loaded.
324         void test_plugins(EDL *new_edl, const char *path);
325
326         int interrupt_indexes();  // Stop index building
327
328         int redraw_time_dependancies();     // after reconfiguring the time format, sample rate, frame rate
329         void draw_trackmovement();          // after reconfiguring tracks/patchbay guis
330         DrawTrackMovement *redraw_tracks;
331
332 // =========================================== movement
333
334         void next_time_format();
335         void prev_time_format();
336         void time_format_common();
337         int reposition_timebar(int new_pixel, int new_height);
338         int expand_sample();
339         int zoom_in_sample();
340         int zoom_sample(int64_t zoom_sample);
341         void zoom_autos(float min, float max);
342         void zoom_amp(int64_t zoom_amp);
343         void zoom_atrack(int64_t zoom);
344         void zoom_vtrack(int64_t zoom);
345         int fit_sample();
346         int move_left(int64_t distance = 0);
347         int move_right(int64_t distance = 0);
348         void move_up(int64_t distance = 0);
349         void move_down(int64_t distance = 0);
350         int find_selection(double position, int scroll_display = 0);
351         void toggle_camera_xyz();
352         void toggle_projector_xyz();
353         double get_position();
354         void set_position(double position);
355         double get_timecode_offset();
356         void set_timecode_offset(double offset);
357         void align_timecodes();
358
359 // seek to labels
360 // shift_down must be passed by the caller because different windows call
361 // into this
362         int next_label(int shift_down);
363         int prev_label(int shift_down);
364 // seek to edit handles
365         int next_edit_handle(int shift_down);
366         int prev_edit_handle(int shift_down);
367 // seek to keyframes
368         int nearest_plugin_keyframe(int shift_down, int dir);
369         int nearest_auto_keyframe(int shift_down, int dir);
370 // offset is pixels to add to track_start
371         void trackmovement(int offset, int pane_number);
372 // view_start is pixels
373         int samplemovement(int64_t view_start, int pane_number);
374         void select_all();
375         int goto_start();
376         int goto_end();
377         int goto_position(double position);
378         int expand_y();
379         int zoom_in_y();
380         int expand_t();
381         int zoom_in_t();
382         void split_x();
383         void split_y();
384         void crop_video(int mode);
385         void update_plugins();
386         void get_backup_path(char *path, int len);
387 // Call after every edit operation
388         void save_backup();
389         void load_backup();
390         void show_plugin(Plugin *plugin);
391         void hide_plugin(Plugin *plugin, int lock);
392         void hide_plugin(int plugin_id, int lock);
393         void hide_plugins();
394         void delete_plugin(PluginServer *plugin);
395 // Update plugins with configuration changes.
396 // Called by TrackCanvas::cursor_motion_event.
397         void update_plugin_guis(int do_keyframe_guis = 1);
398         void update_plugin_states();
399         void update_plugin_titles();
400 // Called by Attachmentpoint during playback.
401 // Searches for matching plugin and renders data in it.
402         void render_plugin_gui(void *data, Plugin *plugin);
403         void render_plugin_gui(void *data, int size, Plugin *plugin);
404         void reset_plugin_gui_frames(Plugin *plugin);
405         void render_plugin_gui_frames(PluginClientFrames *frames, Plugin *plugin);
406         double get_tracking_position();
407         int get_tracking_direction();
408
409 // Called from PluginVClient::process_buffer
410 // Returns 1 if a GUI for the plugin is open so OpenGL routines can determine if
411 // they can run.
412         int plugin_gui_open(Plugin *plugin);
413         void stop_plugin_guis();
414
415         void show_keyframe_gui(Plugin *plugin);
416         void hide_keyframe_guis();
417         void hide_keyframe_gui(Plugin *plugin);
418         void update_keyframe_guis();
419         int get_hash_color(Edit *edit);
420         int get_hash_color(int v);
421         int get_group_color(int v);
422         int get_title_color(Edit *edit);
423
424 // ============================= editing commands ========================
425
426 // Map each recordable audio track to the desired pattern
427         void map_audio(int pattern);
428         void remap_audio(int pattern);
429         enum
430         {
431                 AUDIO_5_1_TO_2,
432                 AUDIO_1_TO_1
433         };
434         void add_clip_to_edl(EDL *edl);
435         void add_audio_track_entry(int above, Track *dst);
436         Track *add_audio_track(int above, Track *dst);
437         void add_video_track_entry(int above, Track *dst);
438         Track *add_video_track(int above, Track *dst);
439         void add_subttl_track_entry(int above, Track *dst);
440         Track *add_subttl_track(int above, Track *dst);
441
442         void asset_to_all();
443         void asset_to_size();
444         void asset_to_rate();
445 // Entry point for clear operations.
446         void clear_entry();
447 // Clears active region in EDL.
448 // If clear_handle, edit boundaries are cleared if the range is 0.
449 // Called by paste, record, menueffects, render, and CWindow drop.
450         void clear(int clear_handle);
451         void clear_labels();
452         int clear_labels(double start, double end);
453         void clear_hard_edges();
454         int clear_hard_edges(double start, double end);
455         void clear_select();
456         void select_edits(int v);
457         void concatenate_tracks();
458         int copy_flags(int copy_flags=COPY_CLIPBOARD);
459         void copy();
460         int copy(double start, double end);
461         void cut();
462         void blade(double position);
463         void cut(double start, double end, double new_position=-1);
464 // cut edit from current position to handle/label
465         void cut_left_edit();
466         void cut_right_edit();
467         void cut_left_label();
468         void cut_right_label();
469
470 // Calculate aspect ratio from pixel counts
471         static int create_aspect_ratio(float &w, float &h, int width, int height);
472 // Calculate defaults path
473         static void create_defaults_path(char *string, const char *config_file);
474
475         void delete_track(Track *track);
476         void delete_tracks();
477         int feather_edits(int64_t feather_samples, int audio, int video);
478         int64_t get_feather(int audio, int video);
479         float get_aspect_ratio();
480         void insert(double position, FileXML *file,
481                 int edit_labels, int edit_plugins, int edit_autos,
482                 EDL *parent_edl, Track *first_track, int overwrite);
483
484 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
485 // into pluginset_highlighted.
486         void insert_effects_canvas(Track *dest_track, double start, double length);
487
488 // CWindow calls this to insert multiple effects from
489 // the drag_pluginservers array.
490         void insert_effects_cwindow(Track *dest_track);
491
492 // Attach new effect to all recordable tracks
493 // single_standalone - attach 1 standalone on the first track and share it with
494 // other tracks
495         void insert_effect(char *title,
496                 SharedLocation *shared_location,
497                 int data_type, int plugin_type, int single_standalone);
498
499 // This is called multiple times by the above functions.
500 // It can't sync parameters.
501         void insert_effect(char *title,
502                 SharedLocation *shared_location,
503                 Track *track, PluginSet *plugin_set,
504                 double start, double length, int plugin_type);
505
506         void match_output_size(Track *track);
507         void delete_edit(Edit *edit, const char *msg, int collapse=0);
508         void delete_edits(ArrayList<Edit*> *edits, const char *msg, int collapse=0);
509         void delete_edits(int collapse=0);
510         void cut_selected_edits(int collapse, int packed);
511 // Move edit to new position
512         void move_edits(ArrayList<Edit*> *edits, Track *track, double position,
513                 int mode); // mode: 0 - mute and overwrite,  1 - cut and paste
514         void selected_edits_to_clipboard(int packed);
515         void paste_clipboard(Track *first_track, double position, int overwrite,
516                 int edit_edits, int edit_labels, int edit_autos, int edit_plugins);
517         void move_group(EDL *group, Track *first_track, double position, int overwrite);
518 // Move effect to position
519         void move_effect(Plugin *plugin, Track *track, int64_t position);
520         void move_effect(Plugin *plugin, PluginSet *plugin_set, int64_t position);
521         void move_plugins_up(PluginSet *plugin_set);
522         void move_plugins_down(PluginSet *plugin_set);
523         void roll_track_down(Track *track);
524         void roll_tracks_down();
525         void roll_track_up(Track *track);
526         void roll_tracks_up();
527         void move_track_down(Track *track);
528         void move_tracks_down();
529         void move_track_up(Track *track);
530         void move_tracks_up();
531         void mute_selection();
532         void new_folder(const char *new_folder, int is_clips);
533         void delete_folder(char *folder);
534 // For clipboard commands
535         void paste();
536         void paste(double start, Track *first_track, int clear_selection, int overwrite);
537 // For splice and overwrite
538         void overwrite(EDL *source, int all);
539         void splice(EDL *source, int all);
540         int paste(double start, double end, FileXML *file,
541                 int edit_labels, int edit_plugins, int edit_autos,
542                 Track *first_track, int overwrite);
543         int paste_output(int64_t startproject, int64_t endproject,
544                 int64_t startsource_sample, int64_t endsource_sample,
545                 int64_t startsource_frame, int64_t endsource_frame,
546                 Asset *asset, RecordLabels *new_labels);
547         void paste_silence();
548
549 // Detach single transition
550         void detach_transition(Transition *transition);
551 // Detach all transitions in selection
552         void detach_transitions();
553 // Attach dragged transition
554         void paste_transition();
555 // Attach transition to all edits in selection
556         void paste_transitions(int track_type, char *title);
557 // Attach transition dragged onto CWindow
558         void paste_transition_cwindow(Track *dest_track);
559 // Attach default transition to single edit
560         void paste_audio_transition();
561         void paste_video_transition();
562         void shuffle_edits();
563         void reverse_edits();
564         void align_edits();
565         void set_edit_length(double length);
566 // Set length of single transition
567         void set_transition_length(Transition *transition, double length);
568 // Set length in seconds of all transitions in active range
569         void set_transition_length(double length);
570
571         void remove_indexfile(Indexable *indexable);
572         void rebuild_indices();
573 // Asset removal from caches
574         void reset_caches(int locked);
575         void remove_from_caches(Indexable *idxbl);
576         void remove_assets_from_project(int push_undo, int redraw, int delete_indexes,
577                 ArrayList<Indexable*> *drag_assets /* mwindow->session->drag_assets */,
578                 ArrayList<EDL*> *drag_clips /* mwindow->session->drag_clips */);
579         void remove_assets_from_disk();
580         void resize_track(Track *track, int w, int h);
581
582         void set_automation_mode(int mode);
583         void set_keyframe_type(int mode);
584         void set_auto_keyframes(int value);
585         void set_span_keyframes(int value);
586         void set_auto_visibility(Autos *autos, int value);
587         void set_labels_follow_edits(int value);
588
589 // Update the editing mode
590         int set_editing_mode(int new_editing_mode);
591         void toggle_editing_mode();
592         void set_inpoint();
593         void set_outpoint();
594         void unset_inoutpoint();
595         void toggle_loop_playback();
596         void trim_selection();
597 // Synchronize EDL settings with all playback engines depending on current
598 // operation.  Doesn't redraw anything.
599         void sync_parameters(int change_type = CHANGE_PARAMS);
600         void save_clip(EDL *new_edl, const char *txt);
601         void to_clip(EDL *edl, const char *txt, int all);
602         int toggle_label();
603         void undo_entry(BC_WindowBase *calling_window_gui);
604         void redo_entry(BC_WindowBase *calling_window_gui);
605         void save_undo_data();
606         void load_undo_data();
607         void remove_undo_data();
608         int copy_target(const char *path, const char *target);
609         int link_target(const char *real_path, const char *link_path, int relative);
610         void save_project(const char *dir, int save_mode, int overwrite, int reload);
611
612         int cut_automation();
613         int copy_automation();
614         int paste_automation();
615         void clear_automation();
616         int cut_default_keyframe();
617         int copy_default_keyframe();
618 // Use paste_automation to paste the default keyframe in other position.
619 // Use paste_default_keyframe to replace the default keyframe with whatever is
620 // in the clipboard.
621         int paste_default_keyframe();
622         int clear_default_keyframe();
623         void create_keyframes(int mask, int mode);
624
625         FloatAuto* get_float_auto(PatchGUI *patch,int idx);
626         IntAuto* get_int_auto(PatchGUI *patch,int idx);
627         PanAuto* get_pan_auto(PatchGUI *patch);
628         PatchGUI *get_patchgui(Track *track);
629
630         int modify_edithandles();
631         int modify_pluginhandles();
632         int modify_transnhandles();
633         void finish_modify_handles();
634         void rescale_proxy(EDL *clip, int orig_scale, int new_scale);
635         void add_proxy(ArrayList<Indexable*> *orig_assets,
636                         ArrayList<Indexable*> *proxy_assets);
637         int render_proxy(ArrayList<Indexable *> &new_idxbls);
638         void beep(double freq, double secs, double gain);
639         int enable_proxy();
640         int disable_proxy();
641         int to_proxy(Asset *asset, int new_scale, int new_use_scaler);
642         Beeper *beeper;
643
644         void dump_plugins(FILE *fp=stdout);
645         void dump_edl(FILE *fp=stdout);
646         void dump_undo(FILE *fp=stdout);
647         void dump_exe(FILE *fp=stdout);
648         void dump_caches(FILE *fp=stdout);
649         static void trap_hook(FILE *fp, void *vp);
650
651         void reset_android_remote();
652
653 // Send new EDL to caches
654         void age_caches();
655         int optimize_assets();            // delete unused assets from the cache and assets
656 // render edl assets to specified format, then replace in edl
657         void start_convert(Asset *format_asset, const char *suffix,
658                         float beep, int to_proxy, int remove_originals);
659         void finish_convert(int remove_originals);
660         ConvertRender *convert_render;
661
662         void select_point(double position);
663         int set_loop_boundaries();         // toggle loop playback and set boundaries for loop playback
664
665
666         Playback3D *playback_3d;
667         SplashGUI *splash_window;
668
669 // Main undo stack
670         MainUndo *undo;
671         int undo_command;
672 // session stack
673         Stack stack;
674
675         BC_Hash *defaults;
676         Assets *assets;
677 // CICaches for drawing timeline only
678         CICache *audio_cache, *video_cache;
679 // Frame cache for drawing timeline only.
680 // Cache drawing doesn't wait for file decoding.
681         FrameCache *frame_cache;
682         WaveCache *wave_cache;
683         Preferences *preferences;
684         PreferencesThread *preferences_thread;
685         MainSession *session;
686         Theme *theme;
687         MainIndexes *mainindexes;
688         MainProgress *mainprogress;
689         BRender *brender;
690         char cin_lang[4];
691         int brender_active;
692         const char *default_standard;
693         static Commercials *commercials;
694         int commercial_active;
695         int has_commercials();
696 // copy of edl created in speed_before, used in speed_after to normalize_speed
697         EDL *speed_edl;
698
699 // Menu items
700         ArrayList<ColormodelItem*> colormodels;
701         ArrayList<InterlacemodeItem*>          interlace_project_modes;
702         ArrayList<InterlacemodeItem*>          interlace_asset_modes;
703
704         int reset_meters();
705         void resync_guis();
706
707         int select_asset(Asset *asset, int vstream, int astream, int delete_tracks);
708         int select_asset(int vtrack, int delete_tracks);
709
710 // Channel DB for playback only.  Record channel DB's are in record.C
711         ChannelDB *channeldb_buz;
712         ChannelDB *channeldb_v4l2jpeg;
713
714 // ====================================== plugins ==============================
715
716 // Contains file descriptors for all the dlopens
717         static ArrayList<PluginServer*> *plugindb;
718 // Currently visible plugins
719         int64_t plugin_visibility;
720         PluginGUIs *plugin_guis;
721 // GUI Plugins to delete
722         ArrayList<PluginServer*> *dead_plugins;
723 // Keyframe editors
724         ArrayList<KeyFrameThread*> *keyframe_threads;
725
726 // Adjust sample position to line up with frames.
727         int fix_timing(int64_t &samples_out,
728                 int64_t &frames_out,
729                 int64_t samples_in);
730
731
732         CreateBD_Thread *create_bd;
733         CreateDVD_Thread *create_dvd;
734         BatchRenderThread *batch_render;
735         Render *render;
736
737         ExportEDL *exportedl;
738
739
740 // Master edl
741         EDL *edl;
742 // Main Window GUI
743         MWindowGUI *gui;
744 // Compositor
745         CWindow *cwindow;
746 // Viewer
747         Mutex *vwindows_lock;
748         ArrayList<VWindow*> vwindows;
749 // Mixer
750         Mutex *zwindows_lock;
751         ArrayList<ZWindow*> zwindows;
752         MixersAlign *mixers_align;
753
754 // Asset manager
755         AWindow *awindow;
756 // Automation window
757         GWindow *gwindow;
758 // Tip of the day
759         TipWindow *twindow;
760 // Warning window
761         WWindow *wwindow;
762         void show_warning(int *do_warning, const char *text);
763         int wait_warning();
764 // Levels
765         LevelWindow *lwindow;
766         Mutex *run_lock;
767 // Lock during creation and destruction of GUI
768         Mutex *plugin_gui_lock;
769         Mutex *dead_plugin_lock;
770         Mutex *keyframe_gui_lock;
771 // Lock during creation and destruction of brender so playback doesn't use it.
772         Mutex *brender_lock;
773 // Initialize shared memory
774         void init_shm(const char *pfn, int64_t min);
775 // Initialize channel DB's for playback
776         void init_channeldb();
777         void init_render();
778         void init_exportedl();
779 // These three happen synchronously with each other
780 // Make sure this is called after synchronizing EDL's.
781         void init_brender();
782 // Restart brender after testing its existence
783         void restart_brender();
784 // Stops brender after testing its existence
785         void stop_brender();
786 // This one happens asynchronously of the others.  Used by playback to
787 // see what frame is background rendered.
788         int brender_available(int position);
789         void set_brender_active(int v, int update=1);
790         int put_commercial();
791         void activate_commercial() { commercial_active = 1; }
792         void commit_commercial();
793         void undo_commercial();
794         void cut_commercials();
795         void update_gui(int changed_edl);
796         int paste_subtitle_text(char *text, double start, double end);
797
798         void init_error();
799         void finit_error();
800         static void init_defaults(BC_Hash* &defaults, char *config_path);
801         void check_language();
802         const char *default_std();
803         void fill_preset_defaults(const char *preset, EDLSession *session);
804         const char *get_preset_name(int index);
805         void init_edl();
806         void init_awindow();
807         void init_gwindow();
808         void init_tipwindow();
809 // Used by MWindow and RenderFarmClient
810         static void get_plugin_path(char *path, const char *plug_dir, const char *fs_path);
811         static int init_plugins(MWindow *mwindow, Preferences *preferences);
812         static int init_ladspa_plugins(MWindow *mwindow, Preferences *preferences);
813         static void init_plugin_tips(ArrayList<PluginServer*> &plugins, const char *lang);
814         static int check_plugin_index(ArrayList<PluginServer*> &plugins,
815                 const char *plug_dir, const char *plug_path);
816         static void init_plugin_index(MWindow *mwindow, Preferences *preferences,
817                 FILE *fp, const char *plugin_dir);
818         static int init_ladspa_index(MWindow *mwindow, Preferences *preferences,
819                 FILE *fp, const char *plugin_dir);
820         static void scan_plugin_index(MWindow *mwindow, Preferences *preferences,
821                 FILE *fp, const char *plug_dir, const char *plug_path, int &idx);
822         static void init_ffmpeg();
823         static void init_ffmpeg_index(MWindow *mwindow, Preferences *preferences, FILE *fp);
824         static int load_plugin_index(MWindow *mwindow, FILE *fp, const char *plugin_dir);
825         static PluginServer *new_ffmpeg_server(MWindow *mwindow, const char *name);
826         static int init_lv2_index(MWindow *mwindow, Preferences *preferences, FILE *fp);
827         static PluginServer *new_lv2_server(MWindow *mwindow, const char *name);
828         static void remove_plugin_index();
829
830         void init_preferences();
831         void init_signals();
832         void init_shuttle();
833         void init_wintv();
834         void init_x10tv();
835         void init_theme();
836         void init_compositor();
837         void init_levelwindow();
838 // Called when creating a new viewer to view footage
839         VWindow* get_viewer(int start_it, int idx=-1);
840         void init_cache();
841         void init_menus();
842         void init_indexes();
843         void init_gui();
844         void init_3d();
845         void init_playbackcursor();
846         void init_commercials();
847         static void add_plugins(ArrayList<PluginServer*> &plugins);
848         static void delete_plugins();
849         void speed_before();
850         int speed_after(int done, int edit_speed);
851         int normalize_speed(EDL *old_edl, EDL *new_edl, int edit_speed);
852         int get_cpus(int out_w, int out_h);
853         int get_cpus();
854 //
855         void clean_indexes();
856 //      TimeBomb timebomb;
857         SigHandler *sighandler;
858         int restart_status;
859         int screens;
860         int in_destructor;
861         Shuttle *shuttle;
862         WinTV *wintv;
863         X10TV *x10tv;
864 };
865
866 #endif