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