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