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