4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
30 #include "autoconf.inc"
32 #include "binfolder.h"
36 #include "edlsession.inc"
37 #include "filexml.inc"
38 #include "indexable.h"
39 #include "indexstate.inc"
41 #include "localsession.inc"
42 #include "maxchannels.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"
56 // Loading and saving are built on load and copy except for automation:
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
68 class EDL : public Indexable
71 EDL(EDL *parent_edl = 0);
74 void create_objects();
75 EDL& operator=(EDL &edl);
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.
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);
90 // Return 1 if rendering requires a virtual console.
91 int get_use_vconsole(VEdit* *playable_edit,
94 PlayableTracks *playable_tracks);
96 // Convert position to frame boundry 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);
104 // increase track w/h to at least session w/h
106 // Scale all sample values since everything is locked to audio
108 void resample(double old_rate, double new_rate, int data_type);
110 int copy(double start, double end, int all,
111 FileXML *file, const char *output_path, int rewind_it);
112 int copy(int all, FileXML *file, const char *output_path, int rewind_it);
114 int copy_clip(double start, double end, int all,
115 FileXML *file, const char *output_path, int rewind_it);
116 int copy_clip(int all, FileXML *file, const char *output_path, int rewind_it);
118 int copy_nested_edl(double start, double end, int all,
119 FileXML *file, const char *output_path, int rewind_it);
120 int copy_nested_edl(int all, FileXML *file, const char *output_path, int rewind_it);
122 int copy_vwindow_edl(double start, double end, int all,
123 FileXML *file, const char *output_path, int rewind_it);
124 int copy_vwindow_edl(int all, FileXML *file, const char *output_path, int rewind_it);
126 void copy_tracks(EDL *edl);
127 // Copies project path, folders, EDLSession, and LocalSession from edl argument.
128 // session_only - used by preferences and format specify
129 // whether to only copy EDLSession
130 void copy_session(EDL *edl, int session_only = 0);
131 int copy_all(EDL *edl);
132 void copy_assets(EDL *edl);
133 void copy_clips(EDL *edl);
134 void copy_nested(EDL *edl);
135 void copy_mixers(EDL *edl);
136 // Copy pan and fade settings from edl
137 void synchronize_params(EDL *edl);
138 // Determine if the positions are equivalent if they're within half a frame
140 int equivalent(double position1, double position2);
141 // Determine if the EDL's produce equivalent video output to the old EDL.
142 // The new EDL is this and the old EDL is the argument.
143 // Return the number of seconds from the beginning of this which are
144 // equivalent to the argument.
145 // If they're completely equivalent, -1 is returned;
146 // This is used by BRender + BatchRender.
147 double equivalent_output(EDL *edl);
148 // Set project path for filename prefixes in the assets
149 void set_path(const char *path);
150 // Set points and labels
151 void set_inpoint(double position);
152 void set_outpoint(double position);
153 void unset_inoutpoint();
154 // Redraw resources during index builds
155 void set_index_file(Indexable *indexable);
156 // Add assets from the src to the destination
157 void update_assets(EDL *src);
159 // return next/prev edit starting from position
160 double next_edit(double position);
161 double prev_edit(double position);
163 int dump(FILE *fp=stdout);
164 static int next_id();
166 BinFolder *get_folder(int no);
167 int get_folder_number(const char *title);
168 const char *get_folder_name(int no);
169 int new_folder(const char *title, int is_clips);
170 int delete_folder(const char *title);
171 void delete_edits(ArrayList<Edit*>*, int);
172 void delete_edit_labels(ArrayList<Edit*> *edits, int collapse);
173 void move_edit_labels(ArrayList<Edit*> *edits, double dist);
175 void modify_edithandles(double oldposition, double newposition,
176 int currentend, int handle_mode, int edit_labels,
177 int edit_plugins, int edit_autos, int group_id);
179 void modify_pluginhandles(double oldposition, double newposition,
180 int currentend, int handle_mode, int edit_labels,
181 int edit_autos, Edits *trim_edits);
183 int trim_selection(double start, double end,
184 int edit_labels, int edit_plugins, int edit_autos);
187 int copy_assets(double start, double end,
188 FileXML *file, int all, const char *output_path);
189 int copy(double start, double end, int all,
190 const char *closer, FileXML *file,
191 const char *output_path, int rewind_it);
192 void copy_indexables(EDL *edl);
193 EDL *new_nested(EDL *edl, const char *path);
194 EDL *create_nested_clip(EDL *nested);
195 void create_nested(EDL *nested);
196 void paste_silence(double start, double end,
197 int edit_labels /* = 1 */,
200 int in_use(Indexable *indexable);
201 void remove_from_project(ArrayList<Indexable*> *assets);
202 void remove_from_project(ArrayList<EDL*> *clips);
203 int blade(double position);
204 int clear(double start, double end,
208 void deglitch(double position);
209 // Insert the asset at a point in the EDL
210 void insert_asset(Asset *asset,
213 Track *first_track = 0,
214 RecordLabels *labels = 0);
215 // Insert the clip at a point in the EDL
216 int insert_clips(ArrayList<EDL*> *new_edls, int load_mode, Track *first_track = 0);
217 // Add a copy of EDL* to the clip array. Returns the copy.
218 EDL* add_clip(EDL *edl);
219 // resequence group ids starting at next_id
220 int regroup(int next_id);
222 void get_shared_plugins(Track *source, ArrayList<SharedLocation*> *plugin_locations,
223 int omit_recordable, int data_type);
224 void get_shared_tracks(Track *track, ArrayList<SharedLocation*> *module_locations,
225 int omit_recordable, int data_type);
227 int get_tracks_height(Theme *theme);
228 int64_t get_tracks_width();
229 // Return dimensions for canvas if smaller dimensions has zoom of 1
230 void calculate_conformed_dimensions(int single_channel, float &w, float &h);
231 // Get the total output size scaled to aspect ratio
232 void output_dimensions_scaled(int &w, int &h);
233 float get_aspect_ratio();
237 int get_audio_channels();
238 int get_sample_rate();
239 int64_t get_audio_samples();
244 double get_frame_rate();
245 int get_video_layers();
246 int64_t get_video_frames();
248 EDL* get_vwindow_edl(int number);
249 int total_vwindow_edls();
250 void remove_vwindow_edls();
251 void remove_vwindow_edl(EDL *edl);
252 // Adds to list of EDLs & increase garbage collection counter
253 // Does nothing if EDL already exists
254 void append_vwindow_edl(EDL *edl, int increase_counter);
255 void rescale_proxy(int orig_scale, int new_scale);
256 void set_proxy(int new_scale, int use_scaler,
257 ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
258 void add_proxy(int use_scaler,
259 ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
260 Asset *get_proxy_asset();
261 Track *add_new_track(int data_type);
263 // Titles of all subfolders
265 // Clips, Nested EDLs
266 ClipEDLs clips, nested_edls;
267 // EDLs being shown in VWindows
268 ArrayList<EDL*> vwindow_edls;
269 // is the vwindow_edl shared and therefore should not be deleted in destructor
270 // int vwindow_edl_shared;
274 // Shared between all EDLs
279 // Shared between all EDLs in a tree, for projects.
281 // Specific to this EDL, for clips.
282 LocalSession *local_session;
284 // Use parent Assets if nonzero