lv2_blklst additions, ffmpeg est/bad times, proxy preview, cin.svg icon
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / track.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 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 TRACK_H
23 #define TRACK_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "arraylist.h"
29 #include "asset.inc"
30 #include "autoconf.inc"
31 #include "automation.inc"
32 #include "datatype.h"
33 #include "bchash.inc"
34 #include "edit.inc"
35 #include "edits.inc"
36 #include "edl.inc"
37 #include "filexml.inc"
38 #include "floatautos.inc"
39 #include "guicast.h"
40 #include "indexable.inc"
41 #include "keyframe.inc"
42 #include "linklist.h"
43 #include "module.inc"
44 #include "patch.inc"
45 #include "plugin.inc"
46 #include "pluginset.inc"
47 #include "sharedlocation.inc"
48 #include "theme.inc"
49 #include "intautos.inc"
50 #include "trackcanvas.inc"
51 #include "tracks.inc"
52 #include "transition.inc"
53
54 // UNITS ARE SAMPLES FOR ALL
55
56 class Track : public ListItem<Track>
57 {
58 public:
59         Track(EDL *edl, Tracks *tracks);
60         Track();
61         virtual ~Track();
62
63         void create_objects();
64         int get_id();
65         virtual int load_defaults(BC_Hash *defaults);
66         int load(FileXML *file, int track_offset, uint32_t load_flags);
67         virtual int save_header(FileXML *file) { return 0; };
68         virtual int save_derived(FileXML *file) { return 0; };
69         virtual int load_header(FileXML *file, uint32_t load_flags) { return 0; };
70         virtual int load_derived(FileXML *file, uint32_t load_flags) { return 0; };
71         void equivalent_output(Track *track, double *result);
72         int get_mixer_id();
73
74         virtual void copy_from(Track *track);
75         Track& operator=(Track& track);
76         virtual PluginSet* new_plugins() { return 0; };
77 // Synchronize playback numbers
78         virtual void synchronize_params(Track *track);
79
80 // Get number of pixels to display
81         virtual int vertical_span(Theme *theme);
82         int64_t horizontal_span();
83         void resample(double old_rate, double new_rate);
84
85 // Speed curve in use
86         int has_speed();
87 // Get length of track in seconds
88         double get_length();
89 // Get dimensions of source for convenience functions
90         void get_source_dimensions(double position, int &w, int &h);
91
92 // Editing
93         void insert_asset(Asset *asset, EDL *nested_edl,
94                 double length, double position, int track_number);
95         Plugin* insert_effect(const char *title, SharedLocation *shared_location,
96                 KeyFrame *keyframe, PluginSet *plugin_set,
97                 double start, double length, int plugin_type);
98         void insert_plugin_set(Track *track, int64_t position,
99                 int64_t min_length, int edit_autos);
100         void detach_effect(Plugin *plugin);
101 // Insert a track from another EDL
102         void insert_track(Track *track, double position,
103                 int replace_default, int edit_plugins, int edit_autos,
104 // Pad pasted sections to a minimum of this length.
105                 double edl_length);
106         void shuffle_edits(double start, double end, int first_track);
107         void reverse_edits(double start, double end, int first_track);
108         void align_edits(double start, double end, ArrayList<double> *times);
109 // Optimize editing
110         void optimize();
111         int is_muted(int64_t position, int direction);  // Test muting status
112
113         void move_plugins_up(PluginSet *plugin_set);
114         void move_plugins_down(PluginSet *plugin_set);
115         void remove_pluginset(PluginSet *plugin_set);
116         void remove_asset(Indexable *asset);
117
118 // Used for determining a selection for editing so leave as int.
119 // converts the selection to SAMPLES OR FRAMES and stores in value
120         virtual int64_t to_units(double position, int round);
121 // For drawing
122         virtual double to_doubleunits(double position);
123         virtual double from_units(int64_t position);
124
125
126 // Positions are identical for handle modifications
127     virtual int identical(int64_t sample1, int64_t sample2) { return 0; };
128
129 // Get the plugin belonging to the set.
130         Plugin* get_current_plugin(double position,
131                 int plugin_set, int direction, int convert_units, int use_nudge);
132         Plugin* get_current_transition(double position,
133                 int direction, int convert_units, int use_nudge);
134
135 // detach shared effects referencing module
136         void detach_shared_effects(int module);
137
138
139 // Called by playable tracks to test for playable server.
140 // Descends the plugin tree without creating a virtual console.
141 // Used by PlayableTracks::is_playable.
142         int is_synthesis(int64_t position, int direction);
143
144 // Used by PlayableTracks::is_playable
145 // Returns 1 if the track is in the output boundaries.
146         virtual int is_playable(int64_t position, int direction);
147
148 // Test direct copy conditions common to all the rendering routines
149         virtual int direct_copy_possible(int64_t start, int direction, int use_nudge);
150
151 // Used by PlayableTracks::is_playable
152         int plugin_used(int64_t position, int64_t direction);
153 // align to frame boundary
154         int64_t frame_align(int64_t position, int round);
155
156         virtual int copy_settings(Track *track);
157         void shift_keyframes(int64_t position, int64_t length);
158         void shift_effects(int64_t position, int64_t length, int edit_autos);
159         void change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap);
160         void change_modules(int old_location, int new_location, int do_swap);
161         int plugin_exists(Plugin *plugin);
162
163         EDL *edl;
164         Tracks *tracks;
165
166         Edits *edits;
167 // Plugin set uses key frames for automation
168         ArrayList<PluginSet*> plugin_set;
169         Automation *automation;
170
171 // Vertical offset from top of timeline
172         int y_pixel;
173         int expand_view;
174         int draw;
175 // There is some debate on whether to expand gang from faders to
176 // dragging operations.  This would allow every edit in a column to get dragged
177 // simultaneously.
178         int gang;
179         char title[BCTEXTLEN];
180         int play;
181         int record;
182 // Nudge in track units.  Positive shifts track earlier in time.  This way
183 // the position variables only need to add the nudge.
184         int64_t nudge;
185 // TRACK_AUDIO or TRACK_VIDEO
186         int data_type;
187
188
189         int load_automation(FileXML *file);
190         int load_edits(FileXML *file);
191
192         virtual int change_channels(int oldchannels, int newchannels) { return 0; };
193         virtual int dump(FILE *fp);
194
195 // ===================================== editing
196         int copy(double start, double end,
197                 FileXML *file, const char *output_path = "");
198         int copy_assets(double start,
199                 double end,
200                 ArrayList<Asset*> *asset_list);
201         virtual int copy_derived(int64_t start, int64_t end, FileXML *file) { return 0; };
202         virtual int paste_derived(int64_t start, int64_t end,
203                 int64_t total_length, FileXML *file, int &current_channel) { return 0; };
204         int blade(double position);
205         int clear(double start, double end,
206                 int edit_edits, int edit_labels, int clear_plugins,
207                 int edit_autos, int convert_units, Edits *trim_edits);
208 // Returns the point to restart background rendering at.
209 // -1 means nothing changed.
210         void clear_automation(double selectionstart, double selectionend,
211                 int shift_autos   /* = 1 */,
212                 int default_only  /* = 0 */);
213         void set_automation_mode(double selectionstart, double selectionend,
214                 int mode);
215         virtual int clear_automation_derived(AutoConf *auto_conf,
216                 double selectionstart, double selectionend,
217                 int shift_autos = 1) { return 0; };
218         virtual int clear_derived(double start,
219                 double end) { return 0; };
220
221         int copy_automation(double selectionstart, double selectionend,
222                 FileXML *file, int default_only, int active_only);
223         virtual int copy_automation_derived(AutoConf *auto_conf,
224                 double selectionstart, double selectionend,
225                 FileXML *file) { return 0; };
226         int paste_automation(double selectionstart, double total_length,
227                 double frame_rate, int64_t sample_rate, FileXML *file,
228                 int default_only, int active_only);
229         virtual int paste_automation_derived(double selectionstart, double selectionend,
230                 double total_length, FileXML *file, int shift_autos, int &current_pan) { return 0; };
231         int paste_auto_silence(double start, double end);
232         virtual int paste_auto_silence_derived(int64_t start, int64_t end) { return 0; };
233         int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
234         virtual int scale_time_derived(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end) { return 0; };
235         int purge_asset(Asset *asset);
236         int asset_used(Asset *asset);
237         int clear_handle(double start, double end,
238                 int clear_labels, int clear_plugins, int edit_autos,
239                 double &distance);
240         int paste_silence(double start, double end, int edit_plugins, int edit_autos);
241         virtual int select_translation(int cursor_x, int cursor_y) { return 0; };  // select video coordinates for frame
242         virtual int update_translation(int cursor_x, int cursor_y, int shift_down) { return 0; };  // move video coordinates
243         int select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y);
244         virtual int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y) { return 0; };
245         int move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
246         virtual int move_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down) { return 0; };
247         int release_auto();
248         virtual int release_auto_derived() { return 0; };
249 // Return whether automation would prevent direct frame copies.  Not fully implemented.
250         int automation_is_used(int64_t start, int64_t end);
251         virtual int automation_is_used_derived(int64_t start, int64_t end) { return 0; }
252
253         int popup_transition(int cursor_x, int cursor_y);
254
255 // Return 1 if the left handle was selected 2 if the right handle was selected 3 if the track isn't recordable
256         int modify_edithandles(double oldposition,
257                 double newposition,
258                 int currentend,
259                 int handle_mode,
260                 int edit_labels,
261                 int edit_plugins,
262                 int edit_autos);
263         int modify_pluginhandles(double oldposition,
264                 double newposition,
265                 int currentend,
266                 int handle_mode,
267                 int edit_labels,
268                 int edit_autos,
269                 Edits *trim_edits);
270         int select_edit(int cursor_x,
271                 int cursor_y,
272                 double &new_start,
273                 double &new_end);
274         virtual int end_translation() { return 0; };
275         virtual int reset_translation(int64_t start, int64_t end) { return 0; };
276         int feather_edits(int64_t start, int64_t end, int64_t units);
277         int64_t get_feather(int64_t selectionstart, int64_t selectionend);
278
279         int show_assets();
280         int show_titles();
281         int show_transitions();
282
283 // Absolute number of this track
284         int number_of();
285
286 // get_dimensions is used for getting drawing regions so use floats for partial frames
287 // get the display dimensions in SAMPLES OR FRAMES
288 //      virtual int get_dimensions(double &view_start,
289 //              double &view_units,
290 //              double &zoom_units) { return 0; };
291 // Longest time from current_position in which nothing changes
292         int64_t edit_change_duration(int64_t input_position,
293                 int64_t input_length,
294                 int reverse,
295                 int test_transitions,
296                 int use_nudge);
297         int64_t plugin_change_duration(int64_t input_position,
298                 int64_t input_length,
299                 int reverse,
300                 int use_nudge);
301 // Utility for edit_change_duration.
302         int need_edit(Edit *current, int test_transitions);
303 // If the edit under position is playable.
304 // Used by PlayableTracks::is_playable.
305         int playable_edit(int64_t position, int direction);
306
307 // ===================================== for handles, titles, etc
308
309         int64_t old_view_start;
310         int pixel;   // pixel position from top of track view
311 // Dimensions of this track if video
312         int track_w, track_h;
313         int mixer_id;
314
315 private:
316 // Identification of the track
317         int id;
318 };
319
320 #endif