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