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