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