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