add edit clear submenu/clear hard_edges, fix tessy gl segv, mask toolgui layout,...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edl.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef EDL_H
23 #define EDL_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "asset.inc"
29 #include "assets.inc"
30 #include "autoconf.inc"
31 #include "bchash.inc"
32 #include "binfolder.h"
33 #include "edit.inc"
34 #include "edits.inc"
35 #include "edl.inc"
36 #include "edlsession.inc"
37 #include "filexml.inc"
38 #include "indexable.h"
39 #include "indexstate.inc"
40 #include "labels.inc"
41 #include "localsession.inc"
42 #include "maxchannels.h"
43 #include "mutex.inc"
44 #include "clipedls.h"
45 #include "playabletracks.inc"
46 #include "playbackconfig.h"
47 #include "pluginserver.h"
48 #include "preferences.inc"
49 #include "recordlabel.inc"
50 #include "sharedlocation.inc"
51 #include "theme.inc"
52 #include "tracks.inc"
53 #include "vedit.inc"
54 #include "zwindow.h"
55
56 // Loading and saving are built on load and copy except for automation:
57
58 // Storage:
59 // Load: load new -> paste into master
60 // Save: copy all of master
61 // Undo: selective load into master
62 // Copy: copy from master
63 // Paste: load new -> paste into master
64 // Copy automation: copy just automation from master
65 // Paste automation: paste functions in automation
66
67
68 class EDL : public Indexable
69 {
70 public:
71         EDL(EDL *parent_edl = 0);
72         ~EDL();
73
74         void create_objects();
75         EDL& operator=(EDL &edl);
76
77 // Load configuration and track counts
78         int load_defaults(BC_Hash *defaults);
79         int save_defaults(BC_Hash *defaults);
80 // Clip default settings to boundaries.
81         void boundaries();
82 // Create tracks using existing configuration
83         int create_default_tracks();
84         int load_xml(FileXML *file, uint32_t load_flags);
85         int read_xml(FileXML *file, uint32_t load_flags);
86         int save_xml(FileXML *xml, const char *output_path);
87         int load_audio_config(FileXML *file, int append_mode, uint32_t load_flags);
88         int load_video_config(FileXML *file, int append_mode, uint32_t load_flags);
89
90 // Return 1 if rendering requires a virtual console.
91         int get_use_vconsole(VEdit* *playable_edit,
92                 int64_t position,
93                 int direction,
94                 PlayableTracks *playable_tracks);
95
96 // Convert position to frame boundary times
97         double frame_align(double position, int round);
98 // frame align if cursor alignment is enabled
99         double align_to_frame(double position, int round);
100 // get position under cursor in pane, and inverse
101         double get_cursor_position(int cursor_x, int pane_no);
102         int64_t get_position_cursorx(double position, int pane_no);
103
104 // increase track w/h to at least session w/h
105         void retrack();
106 // Scale all sample values since everything is locked to audio
107         void rechannel();
108         void resample(double old_rate, double new_rate, int data_type);
109
110         int copy(int copy_flags, double start, double end,
111                 FileXML *file, const char *output_path, int rewind_it);
112         int copy(int copy_flags, FileXML *file, const char *output_path,
113                 int rewind_it);
114
115         int copy_clip(int copy_flags, double start, double end,
116                 FileXML *file, const char *output_path, int rewind_it);
117         int copy_clip(int copy_flags, FileXML *file, const char *output_path,
118                 int rewind_it);
119
120         int copy_nested(int copy_flags, double start, double end,
121                 FileXML *file, const char *output_path, int rewind_it);
122         int copy_nested(int copy_flags, FileXML *file, const char *output_path,
123                 int rewind_it);
124
125         int copy_vwindow(int copy_flags, double start, double end,
126                 FileXML *file, const char *output_path, int rewind_it);
127         int copy_vwindow(int copy_flags, FileXML *file, const char *output_path,
128                 int rewind_it);
129
130         int copy_xml(int copy_flags, double start, double end,
131                 FileXML *file, const char *closer, const char *output_path,
132                 int rewind_it);
133
134         void copy_tracks(EDL *edl);
135 // Copies project path, folders, EDLSession, and LocalSession from edl argument.
136 // session_only - used by preferences and format specify
137 // whether to only copy EDLSession
138         void copy_session(EDL *edl, int session_only = 0);
139         int copy_all(EDL *edl);
140         void copy_assets(EDL *edl);
141         void copy_clips(EDL *edl);
142         void copy_nested(EDL *edl);
143         void copy_mixers(EDL *edl);
144 // Copy pan and fade settings from edl
145         void synchronize_params(EDL *edl);
146 // Determine if the positions are equivalent if they're within half a frame
147 // of each other.
148         int equivalent(double position1, double position2);
149 // Determine if the EDL's produce equivalent video output to the old EDL.
150 // The new EDL is this and the old EDL is the argument.
151 // Return the number of seconds from the beginning of this which are
152 // equivalent to the argument.
153 // If they're completely equivalent, -1 is returned;
154 // This is used by BRender + BatchRender.
155         double equivalent_output(EDL *edl);
156 // Set project path for filename prefixes in the assets
157         void set_path(const char *path);
158 // Set points and labels
159         void set_inpoint(double position);
160         void set_outpoint(double position);
161         void unset_inoutpoint();
162 // Redraw resources during index builds
163         void set_index_file(Indexable *indexable);
164 // Add assets from the src to the destination
165         void update_assets(EDL *src);
166         void optimize();
167 // return next/prev edit starting from position
168         double next_edit(double position);
169         double prev_edit(double position);
170         double skip_silence(double position);
171 // Debug
172         int dump(FILE *fp=stdout);
173         static int next_id();
174 // folders
175         BinFolder *get_folder(int no);
176         int get_folder_number(const char *title);
177         const char *get_folder_name(int no);
178         int new_folder(const char *title, int is_clips);
179         int delete_folder(const char *title);
180         void delete_edits(ArrayList<Edit*>*, int);
181         void delete_edit_labels(ArrayList<Edit*> *edits, int collapse);
182         void move_edit_labels(ArrayList<Edit*> *edits, double dist);
183
184         void modify_edithandles(double oldposition, double newposition,
185                 int currentend, int handle_mode, int edit_labels,
186                 int edit_plugins, int edit_autos, int group_id);
187
188         void modify_pluginhandles(double oldposition, double newposition,
189                 int currentend, int handle_mode, int edit_labels,
190                 int edit_autos, Edits *trim_edits);
191
192         int trim_selection(double start, double end,
193                 int edit_labels, int edit_plugins, int edit_autos);
194
195 // Editing functions
196         int copy_assets(int copy_flags, double start, double end,
197                 FileXML *file, const char *output_path);
198         void copy_indexables(EDL *edl);
199         EDL *new_nested(EDL *edl, const char *path);
200         EDL *create_nested_clip(EDL *nested);
201         void create_nested(EDL *nested);
202         void paste_silence(double start, double end,
203                 int edit_labels /* = 1 */,
204                 int edit_plugins,
205                 int edit_autos);
206         int in_use(Indexable *indexable);
207         void remove_from_project(ArrayList<Indexable*> *assets);
208         void remove_from_project(ArrayList<EDL*> *clips);
209         int blade(double position);
210         int clear(double start, double end,
211                 int clear_labels,
212                 int clear_plugins,
213                 int edit_autos);
214         int clear_hard_edges(double start, double end);
215 // Insert the asset at a point in the EDL
216         void insert_asset(Asset *asset,
217                 EDL *nested_edl,
218                 double position,
219                 Track *first_track = 0,
220                 RecordLabels *labels = 0);
221 // Insert the clip at a point in the EDL
222         int insert_clips(ArrayList<EDL*> *new_edls, int load_mode, Track *first_track = 0);
223 // Add a copy of EDL* to the clip array.  Returns the copy.
224         EDL* add_clip(EDL *edl);
225         EDL *selected_edits_to_clip(int packed,
226                 double *start_position, Track **start_track,
227                 int edit_labels, int edit_autos, int edit_plugins);
228         EDL *selected_edits_to_clip(int packed, double *start_position, Track **start_track);
229         void selected_edits_to_clipboard(int packed);
230         void paste_edits(EDL *clip, Track *first_track, double position, int overwrite,
231                 int edit_edits, int edit_labels, int edit_autos, int edit_plugins);
232         void paste_edits(EDL *clip, Track *first_track, double position, int overwrite);
233 // resequence group ids starting at next_id
234         int regroup(int next_id);
235
236         void get_shared_plugins(Track *source, ArrayList<SharedLocation*> *plugin_locations,
237                 int omit_recordable, int data_type);
238         void get_shared_tracks(Track *track, ArrayList<SharedLocation*> *module_locations,
239                 int omit_recordable, int data_type);
240
241     int get_tracks_height(Theme *theme);
242     int64_t get_tracks_width();
243 // Return dimensions for canvas if smaller dimensions has zoom of 1
244         void calculate_conformed_dimensions(int single_channel, float &w, float &h);
245 // Get the total output size scaled to aspect ratio
246         void output_dimensions_scaled(int &w, int &h);
247         float get_aspect_ratio();
248
249
250 // For Indexable
251         int get_audio_channels();
252         int get_sample_rate();
253         int64_t get_audio_samples();
254         int have_audio();
255         int have_video();
256         int get_w();
257         int get_h();
258         double get_frame_rate();
259         int get_video_layers();
260         int64_t get_video_frames();
261
262         EDL* get_vwindow_edl(int number);
263         int total_vwindow_edls();
264         void remove_vwindow_edls();
265         void remove_vwindow_edl(EDL *edl);
266 // Adds to list of EDLs & increase garbage collection counter
267 // Does nothing if EDL already exists
268         void append_vwindow_edl(EDL *edl, int increase_counter);
269         void rescale_proxy(int orig_scale, int new_scale);
270         void set_proxy(int new_scale, int use_scaler,
271                 ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
272         void add_proxy(int use_scaler,
273                 ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
274         Asset *get_proxy_asset();
275         Track *add_new_track(int data_type);
276
277 // Titles of all subfolders
278         BinFolders folders;
279 // Clips, Nested EDLs
280         ClipEDLs clips, nested_edls;
281 // EDLs being shown in VWindows
282         ArrayList<EDL*> vwindow_edls;
283 // is the vwindow_edl shared and therefore should not be deleted in destructor
284 //      int vwindow_edl_shared;
285         Mixers mixers;
286
287 // Media files
288 // Shared between all EDLs
289         Assets *assets;
290
291         Tracks *tracks;
292         Labels *labels;
293 // Shared between all EDLs in a tree, for projects.
294         EDLSession *session;
295 // Specific to this EDL, for clips.
296         LocalSession *local_session;
297
298 // Use parent Assets if nonzero
299         EDL *parent_edl;
300 };
301
302 #endif