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