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