7 #include "audiodevice.inc"
9 #include "batchrender.inc"
10 #include "bcwindowbase.inc"
11 #include "brender.inc"
13 #include "channel.inc"
14 #include "channeldb.inc"
15 #include "cwindow.inc"
17 #include "devicedvbinput.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"
34 #include "mwindow.inc"
35 #include "mwindowgui.inc"
37 #include "patchbay.inc"
38 #include "playback3d.inc"
39 #include "playbackengine.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"
48 #include "sharedlocation.inc"
49 #include "sighandler.inc"
50 #include "splashgui.inc"
53 #include "threadloader.inc"
54 #include "timebar.inc"
56 #include "tipwindow.inc"
58 #include "tracking.inc"
60 #include "transition.inc"
61 #include "transportque.inc"
62 #include "videowindow.inc"
63 #include "vwindow.inc"
64 #include "wavecache.inc"
68 // All entry points for commands except for window locking should be here.
69 // This allows scriptability.
71 class MWindow
: public Thread
77 // ======================================== initialization commands
78 void create_objects(int want_gui
,
86 int run_script(FileXML
*script
);
88 int delete_project(int flash
= 1);
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();
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
117 void load_assets(ArrayList
<Asset
*> *new_assets
,
120 Track
*first_track
/* = 0 */,
121 RecordLabels
*labels
/* = 0 */,
124 int paste_edls(ArrayList
<EDL
*> *new_edls
,
126 Track
*first_track
/* = 0 */,
127 double current_position
/* = -1 */,
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(int doall
);
136 void change_currentautorange(int autogrouptype
, int increment
, int changemax
);
137 void expand_autos(int changeall
, int domin
, int domax
);
138 void shrink_autos(int changeall
, int domin
, int domax
);
139 // move the window to include the cursor
141 // Append a plugindb with pointers to the master plugindb
142 void create_plugindb(int do_audio
,
147 ArrayList
<PluginServer
*> &plugindb
);
148 // Find the plugin whose title matches title and return it
149 PluginServer
* scan_plugindb(char *title
,
156 int load_filenames(ArrayList
<char*> *filenames
,
157 int load_mode
= LOAD_REPLACE
,
158 // Cause the project filename on the top of the window to be updated.
159 // Not wanted for loading backups.
160 int update_filename
= 1,
161 char *reel_name
= "cin0000",
163 int overwrite_reel
= 0);
166 // Print out plugins which are referenced in the EDL but not loaded.
167 void test_plugins(EDL
*new_edl
, char *path
);
169 int interrupt_indexes(); // Stop index building
172 int redraw_time_dependancies(); // after reconfiguring the time format, sample rate, frame rate
174 // =========================================== movement
176 void next_time_format();
177 void prev_time_format();
178 void time_format_common();
179 int reposition_timebar(int new_pixel
, int new_height
);
180 int expand_sample(double fixed_sample
= -1); // fixed_sample is the sample that should hold fixed position on the screen after zooming, -1 = selection
181 int zoom_in_sample(double fixed_sample
= -1);
182 int zoom_sample(int64_t zoom_sample
, int64_t view_start
= -1); // what's the supposed view start
183 void zoom_amp(int64_t zoom_amp
);
184 void zoom_track(int64_t zoom_track
);
186 int move_left(int64_t distance
= 0);
187 int move_right(int64_t distance
= 0);
188 void move_up(int64_t distance
= 0);
189 void move_down(int64_t distance
= 0);
192 // shift_down must be passed by the caller because different windows call
194 int next_label(int shift_down
);
195 int prev_label(int shift_down
);
196 // seek to edit handles
197 int next_edit_handle(int shift_down
);
198 int prev_edit_handle(int shift_down
);
199 void trackmovement(int track_start
);
200 int samplemovement(int64_t view_start
); // view_start is pixels
209 void update_plugins();
210 // Call after every edit operation
212 void show_plugin(Plugin
*plugin
);
213 void hide_plugin(Plugin
*plugin
, int lock
);
215 // Update plugins with configuration changes.
216 // Called by TrackCanvas::cursor_motion_event.
217 void update_plugin_guis();
218 void update_plugin_states();
219 void update_plugin_titles();
220 // Called by Attachmentpoint during playback.
221 // Searches for matching plugin and renders data in it.
222 void render_plugin_gui(void *data
, Plugin
*plugin
);
223 void render_plugin_gui(void *data
, int size
, Plugin
*plugin
);
225 // Called from PluginVClient::process_buffer
226 // Returns 1 if a GUI for the plugin is open so OpenGL routines can determine if
228 int plugin_gui_open(Plugin
*plugin
);
231 // ============================= editing commands ========================
233 // Map each recordable audio track to the desired pattern
234 void map_audio(int pattern
);
240 void add_audio_track_entry(int above
, Track
*dst
);
241 int add_audio_track(int above
, Track
*dst
);
242 void add_clip_to_edl(EDL
*edl
);
243 void add_video_track_entry(Track
*dst
= 0);
244 int add_video_track(int above
, Track
*dst
);
246 void asset_to_size();
247 void asset_to_rate();
248 // Entry point for clear operations.
250 // Clears active region in EDL.
251 // If clear_handle, edit boundaries are cleared if the range is 0.
252 // Called by paste, record, menueffects, render, and CWindow drop.
253 void clear(int clear_handle
);
255 int clear_labels(double start
, double end
);
256 void concatenate_tracks();
258 int copy(double start
, double end
);
261 // Calculate aspect ratio from pixel counts
262 static int create_aspect_ratio(float &w
, float &h
, int width
, int height
);
263 // Calculate defaults path
264 static void create_defaults_path(char *string
);
266 void delete_folder(char *folder
);
267 void delete_inpoint();
268 void delete_outpoint();
271 void delete_track(Track
*track
);
272 void delete_tracks();
273 void detach_transition(Transition
*transition
);
274 int feather_edits(int64_t feather_samples
, int audio
, int video
);
275 int64_t get_feather(int audio
, int video
);
276 float get_aspect_ratio();
277 void insert(double position
,
281 EDL
*parent_edl
= 0);
283 // TrackCanvas calls this to insert multiple effects from the drag_pluginservers
284 // into pluginset_highlighted.
285 void insert_effects_canvas(double start
,
288 // CWindow calls this to insert multiple effects from
289 // the drag_pluginservers array.
290 void insert_effects_cwindow(Track
*dest_track
);
292 // This is called multiple times by the above functions.
293 // It can't sync parameters.
294 void insert_effect(char *title
,
295 SharedLocation
*shared_location
,
297 PluginSet
*plugin_set
,
302 void match_output_size(Track
*track
);
303 // Move edit to new position
304 void move_edits(ArrayList
<Edit
*> *edits
,
307 int behaviour
); // behaviour: 0 - old style (cut and insert elswhere), 1- new style - (clear and overwrite elsewere)
308 // Move effect to position
309 void move_effect(Plugin
*plugin
,
310 PluginSet
*plugin_set
,
313 void move_plugins_up(PluginSet
*plugin_set
);
314 void move_plugins_down(PluginSet
*plugin_set
);
315 void move_track_down(Track
*track
);
316 void move_tracks_down();
317 void move_track_up(Track
*track
);
318 void move_tracks_up();
319 void mute_selection();
320 void new_folder(char *new_folder
);
321 void overwrite(EDL
*source
);
322 // For clipboard commands
324 // For splice and overwrite
325 int paste(double start
,
330 int paste_output(int64_t startproject
,
332 int64_t startsource_sample
,
333 int64_t endsource_sample
,
334 int64_t startsource_frame
,
335 int64_t endsource_frame
,
337 RecordLabels
*new_labels
);
338 void paste_silence();
340 void paste_transition();
341 void paste_transition_cwindow(Track
*dest_track
);
342 void paste_audio_transition();
343 void paste_video_transition();
344 void rebuild_indices();
345 // Asset removal from caches
347 void remove_asset_from_caches(Asset
*asset
);
348 void remove_assets_from_project(int push_undo
= 0);
349 void remove_assets_from_disk();
350 void resize_track(Track
*track
, int w
, int h
);
351 void set_auto_keyframes(int value
);
352 // Update the editing mode
353 int set_editing_mode(int new_editing_mode
);
354 void set_inpoint(int is_mwindow
);
355 void set_outpoint(int is_mwindow
);
356 void splice(EDL
*source
);
357 void toggle_loop_playback();
358 void trim_selection();
359 // Synchronize EDL settings with all playback engines depending on current
360 // operation. Doesn't redraw anything.
361 void sync_parameters(int change_type
= CHANGE_PARAMS
);
363 int toggle_label(int is_mwindow
);
364 void undo_entry(BC_WindowBase
*calling_window_gui
);
365 void redo_entry(BC_WindowBase
*calling_window_gui
);
368 int cut_automation();
369 int copy_automation();
370 int paste_automation();
371 void clear_automation();
372 void straighten_automation();
373 int cut_default_keyframe();
374 int copy_default_keyframe();
375 // Use paste_automation to paste the default keyframe in other position.
376 // Use paste_default_keyframe to replace the default keyframe with whatever is
378 int paste_default_keyframe();
379 int clear_default_keyframe();
381 int modify_edithandles();
382 int modify_pluginhandles();
383 void finish_modify_handles();
391 // Send new EDL to caches
393 int optimize_assets(); // delete unused assets from the cache and assets
396 void select_point(double position
);
397 int set_loop_boundaries(); // toggle loop playback and set boundaries for loop playback
400 Playback3D
*playback_3d
;
401 RemoveThread
*remove_thread
;
403 SplashGUI
*splash_window
;
408 // CICaches for drawing timeline only
409 CICache
*audio_cache
, *video_cache
;
410 // Frame cache for drawing timeline only.
411 // Cache drawing doesn't wait for file decoding.
412 FrameCache
*frame_cache
;
413 WaveCache
*wave_cache
;
414 Preferences
*preferences
;
415 PreferencesThread
*preferences_thread
;
416 MainSession
*session
;
418 MainIndexes
*mainindexes
;
419 MainProgress
*mainprogress
;
423 ArrayList
<ColormodelItem
*> colormodels
;
424 ArrayList
<InterlaceautofixoptionItem
*> interlace_asset_autofixoptions
;
425 ArrayList
<InterlacemodeItem
*> interlace_project_modes
;
426 ArrayList
<InterlacemodeItem
*> interlace_asset_modes
;
427 ArrayList
<InterlacefixmethodItem
*> interlace_asset_fixmethods
;
431 // Channel DB for playback only. Record channel DB's are in record.C
432 ChannelDB
*channeldb_buz
;
433 ChannelDB
*channeldb_v4l2jpeg
;
435 // ====================================== plugins ==============================
437 // Contain file descriptors for all the dlopens
438 ArrayList
<PluginServer
*> *plugindb
;
439 // Currently visible plugins
440 ArrayList
<PluginServer
*> *plugin_guis
;
443 // Adjust sample position to line up with frames.
444 int fix_timing(int64_t &samples_out
,
449 BatchRenderThread
*batch_render
;
452 ExportEDL
*exportedl
;
470 LevelWindow
*lwindow
;
471 // Lock during creation and destruction of GUI
472 Mutex
*plugin_gui_lock
;
473 // Lock during creation and destruction of brender so playback doesn't use it.
476 // Single device drivers which must be shared between audio and video go here.
477 // They are managed by the garbage collector.
478 DeviceDVBInput
*dvb_input
;
479 // Must be locked before accessing dvb_input or Garbage functions in it.
480 Mutex
*dvb_input_lock
;
483 // Initialize shared memory
486 // Initialize channel DB's for playback
487 void init_channeldb();
489 void init_exportedl();
490 // These three happen synchronously with each other
491 // Make sure this is called after synchronizing EDL's.
493 // Restart brender after testing its existence
494 void restart_brender();
495 // Stops brender after testing its existence
497 // This one happens asynchronously of the others. Used by playback to
498 // see what frame is background rendered.
499 int brender_available(int position
);
500 void set_brender_start();
503 static void init_defaults(BC_Hash
* &defaults
,
508 void init_tipwindow();
509 // Used by MWindow and RenderFarmClient
510 static void init_plugins(Preferences
*preferences
,
511 ArrayList
<PluginServer
*>* &plugindb
,
512 SplashGUI
*splash_window
);
513 static void init_plugin_path(Preferences
*preferences
,
514 ArrayList
<PluginServer
*>* &plugindb
,
516 SplashGUI
*splash_window
,
518 void init_preferences();
521 void init_compositor();
522 void init_levelwindow();
529 void init_playbackcursor();
530 void delete_plugins();
532 void clean_indexes();
533 // TimeBomb timebomb;
534 SigHandler
*sighandler
;