r870: Merge 2.1:
[cinelerra_cv.git] / cinelerra / mwindow.h
blob5553bc8b92fd69262d6e03616c635a5d91e91a8e
1 #ifndef MWINDOW_H
2 #define MWINDOW_H
4 #include "arraylist.h"
5 #include "asset.inc"
6 #include "assets.inc"
7 #include "audiodevice.inc"
8 #include "awindow.inc"
9 #include "batchrender.inc"
10 #include "bcwindowbase.inc"
11 #include "brender.inc"
12 #include "cache.inc"
13 #include "channel.inc"
14 #include "channeldb.inc"
15 #include "cwindow.inc"
16 #include "bchash.inc"
17 #include "devicedvbinput.inc"
18 #include "edit.inc"
19 #include "edl.inc"
20 #include "exportedl.inc"
21 #include "filesystem.inc"
22 #include "filexml.inc"
23 #include "framecache.inc"
24 #include "gwindow.inc"
25 #include "levelwindow.inc"
26 #include "loadmode.inc"
27 #include "mainerror.inc"
28 #include "mainindexes.inc"
29 #include "mainprogress.inc"
30 #include "mainsession.inc"
31 #include "mainundo.inc"
32 #include "maxchannels.h"
33 #include "mutex.inc"
34 #include "mwindow.inc"
35 #include "mwindowgui.inc"
36 #include "new.inc"
37 #include "patchbay.inc"
38 #include "playback3d.inc"
39 #include "playbackengine.inc"
40 #include "plugin.inc"
41 #include "pluginserver.inc"
42 #include "pluginset.inc"
43 #include "preferences.inc"
44 #include "preferencesthread.inc"
45 #include "recordlabel.inc"
46 #include "removethread.inc"
47 #include "render.inc"
48 #include "sharedlocation.inc"
49 #include "sighandler.inc"
50 #include "splashgui.inc"
51 #include "theme.inc"
52 #include "thread.h"
53 #include "threadloader.inc"
54 #include "timebar.inc"
55 #include "timebomb.h"
56 #include "tipwindow.inc"
57 #include "track.inc"
58 #include "tracking.inc"
59 #include "tracks.inc"
60 #include "transition.inc"
61 #include "transportque.inc"
62 #include "videowindow.inc"
63 #include "vwindow.inc"
64 #include "wavecache.inc"
66 #include <stdint.h>
68 // All entry points for commands except for window locking should be here.
69 // This allows scriptability.
71 class MWindow : public Thread
73 public:
74 MWindow();
75 ~MWindow();
77 // ======================================== initialization commands
78 void create_objects(int want_gui,
79 int want_new,
80 char *config_path);
81 void show_splash();
82 void hide_splash();
83 void start();
84 void run();
86 int run_script(FileXML *script);
87 int new_project();
88 int delete_project(int flash = 1);
90 int load_defaults();
91 int save_defaults();
92 int set_filename(char *filename);
93 // Total vertical pixels in timeline
94 int get_tracks_height();
95 // Total horizontal pixels in timeline
96 int get_tracks_width();
97 // Show windows
98 void show_vwindow();
99 void show_awindow();
100 void show_lwindow();
101 void show_cwindow();
102 void show_gwindow();
103 void tile_windows();
104 void set_titles(int value);
105 int asset_to_edl(EDL *new_edl, Asset *new_asset, RecordLabels *labels = 0);
107 // Entry point to insert assets and insert edls. Called by TrackCanvas
108 // and AssetPopup when assets are dragged in from AWindow.
109 // Takes the drag vectors from MainSession and
110 // pastes either assets or clips depending on which is full.
111 // Returns 1 if the vectors were full
112 int paste_assets(double position, Track *dest_track);
114 // Insert the assets at a point in the EDL. Called by menueffects,
115 // render, and CWindow drop but recording calls paste_edls directly for
116 // labels.
117 void load_assets(ArrayList<Asset*> *new_assets,
118 double position,
119 int load_mode,
120 Track *first_track /* = 0 */,
121 RecordLabels *labels /* = 0 */,
122 int edit_labels,
123 int edit_plugins);
124 int paste_edls(ArrayList<EDL*> *new_edls,
125 int load_mode,
126 Track *first_track /* = 0 */,
127 double current_position /* = -1 */,
128 int edit_labels,
129 int edit_plugins);
130 // Reset everything for a load
131 void update_project(int load_mode);
132 // Fit selected time to horizontal display range
133 void fit_selection();
134 // Fit selected autos to the vertical display range
135 void fit_autos();
136 void expand_autos();
137 void shrink_autos();
138 // move the window to include the cursor
139 void find_cursor();
140 // Append a plugindb with pointers to the master plugindb
141 void create_plugindb(int do_audio,
142 int do_video,
143 int is_realtime,
144 int is_transition,
145 int is_theme,
146 ArrayList<PluginServer*> &plugindb);
147 // Find the plugin whose title matches title and return it
148 PluginServer* scan_plugindb(char *title,
149 int data_type);
150 void dump_plugins();
155 int load_filenames(ArrayList<char*> *filenames,
156 int load_mode = LOAD_REPLACE,
157 // Cause the project filename on the top of the window to be updated.
158 // Not wanted for loading backups.
159 int update_filename = 1,
160 char *reel_name = "cin0000",
161 int reel_number = 0,
162 int overwrite_reel = 0);
165 // Print out plugins which are referenced in the EDL but not loaded.
166 void test_plugins(EDL *new_edl, char *path);
168 int interrupt_indexes(); // Stop index building
171 int redraw_time_dependancies(); // after reconfiguring the time format, sample rate, frame rate
173 // =========================================== movement
175 void next_time_format();
176 void prev_time_format();
177 void time_format_common();
178 int reposition_timebar(int new_pixel, int new_height);
179 int expand_sample(double fixed_sample = -1); // fixed_sample is the sample that should hold fixed position on the screen after zooming, -1 = selection
180 int zoom_in_sample(double fixed_sample = -1);
181 int zoom_sample(int64_t zoom_sample, int64_t view_start = -1); // what's the supposed view start
182 void zoom_amp(int64_t zoom_amp);
183 void zoom_track(int64_t zoom_track);
184 int fit_sample();
185 int move_left(int64_t distance = 0);
186 int move_right(int64_t distance = 0);
187 void move_up(int64_t distance = 0);
188 void move_down(int64_t distance = 0);
190 // seek to labels
191 // shift_down must be passed by the caller because different windows call
192 // into this
193 int next_label(int shift_down);
194 int prev_label(int shift_down);
195 // seek to edit handles
196 int next_edit_handle(int shift_down);
197 int prev_edit_handle(int shift_down);
198 void trackmovement(int track_start);
199 int samplemovement(int64_t view_start); // view_start is pixels
200 void select_all();
201 int goto_start();
202 int goto_end();
203 int expand_y();
204 int zoom_in_y();
205 int expand_t();
206 int zoom_in_t();
207 void crop_video();
208 void update_plugins();
209 // Call after every edit operation
210 void save_backup();
211 void show_plugin(Plugin *plugin);
212 void hide_plugin(Plugin *plugin, int lock);
213 void hide_plugins();
214 // Update plugins with configuration changes.
215 // Called by TrackCanvas::cursor_motion_event.
216 void update_plugin_guis();
217 void update_plugin_states();
218 void update_plugin_titles();
219 // Called by Attachmentpoint during playback.
220 // Searches for matching plugin and renders data in it.
221 void render_plugin_gui(void *data, Plugin *plugin);
222 void render_plugin_gui(void *data, int size, Plugin *plugin);
224 // Called from PluginVClient::process_buffer
225 // Returns 1 if a GUI for the plugin is open so OpenGL routines can determine if
226 // they can run.
227 int plugin_gui_open(Plugin *plugin);
230 // ============================= editing commands ========================
232 // Map each recordable audio track to the desired pattern
233 void map_audio(int pattern);
234 enum
236 AUDIO_5_1_TO_2,
237 AUDIO_1_TO_1
239 void add_audio_track_entry(int above, Track *dst);
240 int add_audio_track(int above, Track *dst);
241 void add_clip_to_edl(EDL *edl);
242 void add_video_track_entry(Track *dst = 0);
243 int add_video_track(int above, Track *dst);
245 void asset_to_size();
246 void asset_to_rate();
247 // Entry point for clear operations.
248 void clear_entry();
249 // Clears active region in EDL.
250 // If clear_handle, edit boundaries are cleared if the range is 0.
251 // Called by paste, record, menueffects, render, and CWindow drop.
252 void clear(int clear_handle);
253 void clear_labels();
254 int clear_labels(double start, double end);
255 void concatenate_tracks();
256 void copy();
257 int copy(double start, double end);
258 void cut();
260 // Calculate aspect ratio from pixel counts
261 static int create_aspect_ratio(float &w, float &h, int width, int height);
262 // Calculate defaults path
263 static void create_defaults_path(char *string);
265 void delete_folder(char *folder);
266 void delete_inpoint();
267 void delete_outpoint();
269 void delete_track();
270 void delete_track(Track *track);
271 void delete_tracks();
272 void detach_transition(Transition *transition);
273 int feather_edits(int64_t feather_samples, int audio, int video);
274 int64_t get_feather(int audio, int video);
275 float get_aspect_ratio();
276 void insert(double position,
277 FileXML *file,
278 int edit_labels,
279 int edit_plugins,
280 EDL *parent_edl = 0);
282 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
283 // into pluginset_highlighted.
284 void insert_effects_canvas(double start,
285 double length);
287 // CWindow calls this to insert multiple effects from
288 // the drag_pluginservers array.
289 void insert_effects_cwindow(Track *dest_track);
291 // This is called multiple times by the above functions.
292 // It can't sync parameters.
293 void insert_effect(char *title,
294 SharedLocation *shared_location,
295 Track *track,
296 PluginSet *plugin_set,
297 double start,
298 double length,
299 int plugin_type);
301 void match_output_size(Track *track);
302 // Move edit to new position
303 void move_edits(ArrayList<Edit*> *edits,
304 Track *track,
305 double position,
306 int behaviour); // behaviour: 0 - old style (cut and insert elswhere), 1- new style - (clear and overwrite elsewere)
307 // Move effect to position
308 void move_effect(Plugin *plugin,
309 PluginSet *plugin_set,
310 Track *track,
311 int64_t position);
312 void move_plugins_up(PluginSet *plugin_set);
313 void move_plugins_down(PluginSet *plugin_set);
314 void move_track_down(Track *track);
315 void move_tracks_down();
316 void move_track_up(Track *track);
317 void move_tracks_up();
318 void mute_selection();
319 void new_folder(char *new_folder);
320 void overwrite(EDL *source);
321 // For clipboard commands
322 void paste();
323 // For splice and overwrite
324 int paste(double start,
325 double end,
326 FileXML *file,
327 int edit_labels,
328 int edit_plugins);
329 int paste_output(int64_t startproject,
330 int64_t endproject,
331 int64_t startsource_sample,
332 int64_t endsource_sample,
333 int64_t startsource_frame,
334 int64_t endsource_frame,
335 Asset *asset,
336 RecordLabels *new_labels);
337 void paste_silence();
339 void paste_transition();
340 void paste_transition_cwindow(Track *dest_track);
341 void paste_audio_transition();
342 void paste_video_transition();
343 void rebuild_indices();
344 // Asset removal from caches
345 void reset_caches();
346 void remove_asset_from_caches(Asset *asset);
347 void remove_assets_from_project(int push_undo = 0);
348 void remove_assets_from_disk();
349 void resize_track(Track *track, int w, int h);
350 void set_auto_keyframes(int value);
351 // Update the editing mode
352 int set_editing_mode(int new_editing_mode);
353 void set_inpoint(int is_mwindow);
354 void set_outpoint(int is_mwindow);
355 void splice(EDL *source);
356 void toggle_loop_playback();
357 void trim_selection();
358 // Synchronize EDL settings with all playback engines depending on current
359 // operation. Doesn't redraw anything.
360 void sync_parameters(int change_type = CHANGE_PARAMS);
361 void to_clip();
362 int toggle_label(int is_mwindow);
363 void undo_entry(BC_WindowBase *calling_window_gui);
364 void redo_entry(BC_WindowBase *calling_window_gui);
367 int cut_automation();
368 int copy_automation();
369 int paste_automation();
370 void clear_automation();
371 void straighten_automation();
372 int cut_default_keyframe();
373 int copy_default_keyframe();
374 // Use paste_automation to paste the default keyframe in other position.
375 // Use paste_default_keyframe to replace the default keyframe with whatever is
376 // in the clipboard.
377 int paste_default_keyframe();
378 int clear_default_keyframe();
380 int modify_edithandles();
381 int modify_pluginhandles();
382 void finish_modify_handles();
390 // Send new EDL to caches
391 void age_caches();
392 int optimize_assets(); // delete unused assets from the cache and assets
395 void select_point(double position);
396 int set_loop_boundaries(); // toggle loop playback and set boundaries for loop playback
399 Playback3D *playback_3d;
400 RemoveThread *remove_thread;
402 SplashGUI *splash_window;
403 // Main undo stack
404 MainUndo *undo;
405 BC_Hash *defaults;
406 Assets *assets;
407 // CICaches for drawing timeline only
408 CICache *audio_cache, *video_cache;
409 // Frame cache for drawing timeline only.
410 // Cache drawing doesn't wait for file decoding.
411 FrameCache *frame_cache;
412 WaveCache *wave_cache;
413 Preferences *preferences;
414 PreferencesThread *preferences_thread;
415 MainSession *session;
416 Theme *theme;
417 MainIndexes *mainindexes;
418 MainProgress *mainprogress;
419 BRender *brender;
421 // Menu items
422 ArrayList<ColormodelItem*> colormodels;
423 ArrayList<InterlaceautofixoptionItem*> interlace_asset_autofixoptions;
424 ArrayList<InterlacemodeItem*> interlace_project_modes;
425 ArrayList<InterlacemodeItem*> interlace_asset_modes;
426 ArrayList<InterlacefixmethodItem*> interlace_asset_fixmethods;
428 int reset_meters();
430 // Channel DB for playback only. Record channel DB's are in record.C
431 ChannelDB *channeldb_buz;
432 ChannelDB *channeldb_v4l2jpeg;
434 // ====================================== plugins ==============================
436 // Contain file descriptors for all the dlopens
437 ArrayList<PluginServer*> *plugindb;
438 // Currently visible plugins
439 ArrayList<PluginServer*> *plugin_guis;
442 // Adjust sample position to line up with frames.
443 int fix_timing(int64_t &samples_out,
444 int64_t &frames_out,
445 int64_t samples_in);
448 BatchRenderThread *batch_render;
449 Render *render;
451 ExportEDL *exportedl;
454 // Master edl
455 EDL *edl;
456 // Main Window GUI
457 MWindowGUI *gui;
458 // Compositor
459 CWindow *cwindow;
460 // Viewer
461 VWindow *vwindow;
462 // Asset manager
463 AWindow *awindow;
464 // Automation window
465 GWindow *gwindow;
466 // Tip of the day
467 TipWindow *twindow;
468 // Levels
469 LevelWindow *lwindow;
470 // Lock during creation and destruction of GUI
471 Mutex *plugin_gui_lock;
472 // Lock during creation and destruction of brender so playback doesn't use it.
473 Mutex *brender_lock;
475 // Single device drivers which must be shared between audio and video go here.
476 // They are managed by the garbage collector.
477 DeviceDVBInput *dvb_input;
478 // Must be locked before accessing dvb_input or Garbage functions in it.
479 Mutex *dvb_input_lock;
482 // Initialize shared memory
483 void init_shm();
485 // Initialize channel DB's for playback
486 void init_channeldb();
487 void init_render();
488 void init_exportedl();
489 // These three happen synchronously with each other
490 // Make sure this is called after synchronizing EDL's.
491 void init_brender();
492 // Restart brender after testing its existence
493 void restart_brender();
494 // Stops brender after testing its existence
495 void stop_brender();
496 // This one happens asynchronously of the others. Used by playback to
497 // see what frame is background rendered.
498 int brender_available(int position);
499 void set_brender_start();
501 void init_error();
502 static void init_defaults(BC_Hash* &defaults,
503 char *config_path);
504 void init_edl();
505 void init_awindow();
506 void init_gwindow();
507 void init_tipwindow();
508 // Used by MWindow and RenderFarmClient
509 static void init_plugins(Preferences *preferences,
510 ArrayList<PluginServer*>* &plugindb,
511 SplashGUI *splash_window);
512 static void init_plugin_path(Preferences *preferences,
513 ArrayList<PluginServer*>* &plugindb,
514 FileSystem *fs,
515 SplashGUI *splash_window,
516 int *counter);
517 void init_preferences();
518 void init_signals();
519 void init_theme();
520 void init_compositor();
521 void init_levelwindow();
522 void init_viewer();
523 void init_cache();
524 void init_menus();
525 void init_indexes();
526 void init_gui();
527 void init_3d();
528 void init_playbackcursor();
529 void delete_plugins();
531 void clean_indexes();
532 // TimeBomb timebomb;
533 SigHandler *sighandler;
536 #endif