r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / edlsession.C
blob0af2308aa5fdf94ca28864d2a659609c1ce06c2a
1 #include "assets.h"
2 #include "autoconf.h"
3 #include "colormodels.h"
4 #include "defaults.h"
5 #include "edl.h"
6 #include "edlsession.h"
7 #include "filexml.h"
8 #include "overlayframe.inc"
9 #include "playbackconfig.h"
10 #include "recordconfig.h"
11 #include "tracks.h"
12 #include "workarounds.h"
14 int EDLSession::current_id = 0;
16 EDLSession::EDLSession(EDL *edl)
18         highlighted_track = 0;
19         playback_cursor_visible = 0;
20         aconfig_in = new AudioInConfig;
21         aconfig_duplex = new AudioOutConfig(PLAYBACK_LOCALHOST, 0, 1);
22         vconfig_in = new VideoInConfig;
23         playback_strategy = PLAYBACK_LOCALHOST;
24         interpolation_type = CUBIC_LINEAR;
25         force_uniprocessor = 0;
26         test_playback_edits = 1;
27         smp = calculate_smp();
28         brender_start = 0.0;
29         mpeg4_deblock = 1;
31         for(int i = 0; i < PLAYBACK_STRATEGIES; i++)
32         {
33                 PlaybackConfig *config = new PlaybackConfig(i, 0);
34                 playback_config[i].append(config);
35         }
36         auto_conf = new AutoConf;
37         vwindow_folder[0]=0;
40 EDLSession::~EDLSession()
42         delete aconfig_in;
43         delete aconfig_duplex;
44         delete auto_conf;
45         delete vconfig_in;
46         for(int i = 0; i < PLAYBACK_STRATEGIES; i++)
47         {
48                 for(int j = 0; j < playback_config[i].total; j++)
49                         delete playback_config[i].values[j];
50                 playback_config[i].remove_all();
51         }
55 int EDLSession::calculate_smp()
57 /* Get processor count */
58         int result = 1;
59         FILE *proc;
61         if(force_uniprocessor) return 0;
63         if(proc = fopen("/proc/cpuinfo", "r"))
64         {
65                 char string[1024];
66                 while(!feof(proc))
67                 {
68                         fgets(string, 1024, proc);
69                         if(!strncasecmp(string, "processor", 9))
70                         {
71                                 char *ptr = strchr(string, ':');
72                                 if(ptr)
73                                 {
74                                         ptr++;
75                                         result = atol(ptr) + 1;
76                                 }
77                         }
78                         else
79                         if(!strncasecmp(string, "cpus detected", 13))
80                         {
81                                 char *ptr = strchr(string, ':');
82                                 if(ptr)
83                                 {
84                                         ptr++;
85                                         result = atol(ptr);
86                                 }
87                         }
88                 }
89                 fclose(proc);
90         }
92         return result - 1;
95 char* EDLSession::get_cwindow_display()
97         if(playback_config[PLAYBACK_LOCALHOST].values[0]->vconfig->x11_host[0])
98                 return playback_config[PLAYBACK_LOCALHOST].values[0]->vconfig->x11_host;
99         else
100                 return 0;
107 void EDLSession::equivalent_output(EDLSession *session, double *result)
109         if(session->output_w != output_w ||
110                 session->output_h != output_h ||
111                 session->frame_rate != frame_rate ||
112                 session->color_model != color_model ||
113                 session->interpolation_type != interpolation_type ||
114                 session->mpeg4_deblock != mpeg4_deblock)
115                 *result = 0;
117 // If it's before the current brender_start, render extra data.
118 // If it's after brender_start, check brender map.
119         if(brender_start != session->brender_start &&
120                 (*result < 0 || *result > brender_start))
121                 *result = brender_start;
125 int EDLSession::load_defaults(Defaults *defaults)
127         char string[BCTEXTLEN];
129 // Default channel positions
130         for(int i = 0; i < MAXCHANNELS; i++)
131         {
132                 sprintf(string, "ACHANNEL_ANGLE_%d", i);
133                 int default_position = i * 30;
135                 if(i == 0) default_position = 180;
136                 else
137                 if(i == 1) default_position = 0;
138                 else
139                 if(default_position == 90) default_position = 300;
140                 else
141                 if(default_position == 0) default_position = 330;
143                 achannel_positions[i] = defaults->get(string, default_position);
144         }
145         aconfig_duplex->load_defaults(defaults);
146         aconfig_in->load_defaults(defaults);
147         actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1);
148         assetlist_format = defaults->get("ASSETLIST_FORMAT", ASSETS_ICONS);
149         aspect_w = defaults->get("ASPECTW", (float)4);
150         aspect_h = defaults->get("ASPECTH", (float)3);
151         for(int i = 0; i < ASSET_COLUMNS; i++)
152         {
153                 sprintf(string, "ASSET_COLUMN%d", i);
154                 asset_columns[i] = defaults->get(string, 100);
155         }
156         audio_channels = defaults->get("ACHANNELS", 2);
157         audio_module_fragment = defaults->get("AUDIO_MODULE_FRAGMENT", 2048);
158         audio_read_length = defaults->get("PLAYBACK_READ_LENGTH", 131072);
159         audio_tracks = defaults->get("ATRACKS", 2);
160         auto_conf->load_defaults(defaults);
161         autos_follow_edits = defaults->get("AUTOS_FOLLOW_EDITS", 1);
162         brender_start = defaults->get("BRENDER_START", brender_start);
163         cmodel_to_text(string, BC_RGBA8888);
164         color_model = cmodel_from_text(defaults->get("COLOR_MODEL", string));
165         crop_x1 = defaults->get("CROP_X1", 0);
166         crop_x2 = defaults->get("CROP_X2", 320);
167         crop_y1 = defaults->get("CROP_Y1", 0);
168         crop_y2 = defaults->get("CROP_Y2", 240);
169         sprintf(current_folder, MEDIA_FOLDER);
170         defaults->get("CURRENT_FOLDER", current_folder);
171         cursor_on_frames = defaults->get("CURSOR_ON_FRAMES", 0);
172         cwindow_dest = defaults->get("CWINDOW_DEST", 0);
173         cwindow_mask = defaults->get("CWINDOW_MASK", 0);
174         cwindow_meter = defaults->get("CWINDOW_METER", 1);
175         cwindow_operation = defaults->get("CWINDOW_OPERATION", 0);
176         cwindow_scrollbars = defaults->get("CWINDOW_SCROLLBARS", 1);
177         cwindow_xscroll = defaults->get("CWINDOW_XSCROLL", 0);
178         cwindow_yscroll = defaults->get("CWINDOW_YSCROLL", 0);
179         cwindow_zoom = defaults->get("CWINDOW_ZOOM", (float)1);
180         sprintf(default_atransition, "Crossfade");
181         defaults->get("DEFAULT_ATRANSITION", default_atransition);
182         sprintf(default_vtransition, "Dissolve");
183         defaults->get("DEFAULT_VTRANSITION", default_vtransition);
184         default_transition_length = defaults->get("DEFAULT_TRANSITION_LENGTH", (double)1);
185         edit_handle_mode[0] = defaults->get("EDIT_HANDLE_MODE0", MOVE_ALL_EDITS);
186         edit_handle_mode[1] = defaults->get("EDIT_HANDLE_MODE1", MOVE_ONE_EDIT);
187         edit_handle_mode[2] = defaults->get("EDIT_HANDLE_MODE2", MOVE_NO_EDITS);
188         editing_mode = defaults->get("EDITING_MODE", EDITING_IBEAM);
189         enable_duplex = defaults->get("ENABLE_DUPLEX", 1);
190         folderlist_format = defaults->get("FOLDERLIST_FORMAT", FOLDERS_ICONS);
191         force_uniprocessor = defaults->get("FORCE_UNIPROCESSOR", 0);
192         frame_rate = defaults->get("FRAMERATE", (double)30000.0/1001);
193         frames_per_foot = defaults->get("FRAMES_PER_FOOT", (float)16);
194         interpolation_type = defaults->get("INTERPOLATION_TYPE", interpolation_type);
195         labels_follow_edits = defaults->get("LABELS_FOLLOW_EDITS", 1);
196         plugins_follow_edits = defaults->get("PLUGINS_FOLLOW_EDITS", 1);
197         auto_keyframes = defaults->get("AUTO_KEYFRAMES", 0);
198         meter_format = defaults->get("METER_FORMAT", METER_DB);
199         min_meter_db = defaults->get("MIN_METER_DB", (float)-85);
200         mpeg4_deblock = defaults->get("MPEG4_DEBLOCK", mpeg4_deblock);
201         output_w = defaults->get("OUTPUTW", 720);
202         output_h = defaults->get("OUTPUTH", 480);
203         playback_buffer = defaults->get("PLAYBACK_BUFFER", 4096);
204         playback_preload = defaults->get("PLAYBACK_PRELOAD", 0);
205         playback_software_position = defaults->get("PLAYBACK_SOFTWARE_POSITION", 0);
206         playback_strategy = defaults->get("PLAYBACK_STRATEGY", playback_strategy);
207         for(int i = 0; i < 1 /* PLAYBACK_STRATEGIES */; i++)
208         {
209                 playback_config[i].remove_all_objects();
211                 sprintf(string, "PLAYBACK_CONFIGS_%d", i);
212                 int playback_configs = defaults->get(string, 1);
213                 for(int j = 0; j < playback_configs; j++)
214                 {
215                         PlaybackConfig *config = new PlaybackConfig(i, j);
216                         playback_config[i].append(config);
217                         config->load_defaults(defaults);
218                 }
219         }
220         real_time_playback = defaults->get("PLAYBACK_REALTIME", 0);
221         real_time_record = defaults->get("REALTIME_RECORD", 0);
222         record_software_position = defaults->get("RECORD_SOFTWARE_POSITION", 1);
223         record_sync_drives = defaults->get("RECORD_SYNC_DRIVES", 0);
224         record_speed = defaults->get("RECORD_SPEED", 8);
225         record_write_length = defaults->get("RECORD_WRITE_LENGTH", 131072);
226         safe_regions = defaults->get("SAFE_REGIONS", 1);
227         sample_rate = defaults->get("SAMPLERATE", 48000);
228         scrub_speed = defaults->get("SCRUB_SPEED", (float)2);
229         show_titles = defaults->get("SHOW_TITLES", 1);
230         smp = calculate_smp();
231 //      test_playback_edits = defaults->get("TEST_PLAYBACK_EDITS", 1);
232         time_format = defaults->get("TIME_FORMAT", TIME_HMS);
233         tool_window = defaults->get("TOOL_WINDOW", 0);
234         vconfig_in->load_defaults(defaults);
235         for(int i = 0; i < MAXCHANNELS; i++)
236         {
237                 int default_position = i * output_w;
238                 sprintf(string, "VCHANNEL_X_%d", i);
239                 vchannel_x[i] = defaults->get(string, default_position);
240                 sprintf(string, "VCHANNEL_Y_%d", i);
241                 vchannel_y[i] = defaults->get(string, 0);
242         }
243         video_channels = defaults->get("VCHANNELS", 1);
244         video_every_frame = defaults->get("VIDEO_EVERY_FRAME", 0);
245         video_tracks = defaults->get("VTRACKS", 1);
246         video_write_length = defaults->get("VIDEO_WRITE_LENGTH", 30);
247         view_follows_playback = defaults->get("VIEW_FOLLOWS_PLAYBACK", 1);
248         vwindow_meter = defaults->get("VWINDOW_METER", 1);
249         
250         vwindow_folder[0] = 0;
251         vwindow_source = -1;
252         vwindow_zoom = defaults->get("VWINDOW_ZOOM", (float)1);
254         return 0;
257 int EDLSession::save_defaults(Defaults *defaults)
259         char string[BCTEXTLEN];
261 // Session
262         for(int i = 0; i < MAXCHANNELS; i++)
263         {
264                 sprintf(string, "ACHANNEL_ANGLE_%d", i);
265                 defaults->update(string, achannel_positions[i]);
266         }
267         defaults->update("ACHANNELS", audio_channels);
268         aconfig_duplex->save_defaults(defaults);
269         aconfig_in->save_defaults(defaults);
270         for(int i = 0; i < ASSET_COLUMNS; i++)
271         {
272                 sprintf(string, "ASSET_COLUMN%d", i);
273                 defaults->update(string, asset_columns[i]);
274         }
275         auto_conf->save_defaults(defaults);
276     defaults->update("ACTUAL_FRAME_RATE", actual_frame_rate);
277     defaults->update("ASSETLIST_FORMAT", assetlist_format);
278     defaults->update("ASPECTW", aspect_w);
279     defaults->update("ASPECTH", aspect_h);
280     defaults->update("AUDIO_MODULE_FRAGMENT", audio_module_fragment);
281     defaults->update("PLAYBACK_READ_LENGTH", audio_read_length);
282         defaults->update("ATRACKS", audio_tracks);
283         defaults->update("AUTOS_FOLLOW_EDITS", autos_follow_edits);
284         defaults->update("BRENDER_START", brender_start);
285         cmodel_to_text(string, color_model);
286         defaults->update("COLOR_MODEL", string);
287         defaults->update("CROP_X1", crop_x1);
288         defaults->update("CROP_X2", crop_x2);
289         defaults->update("CROP_Y1", crop_y1);
290         defaults->update("CROP_Y2", crop_y2);
291         defaults->update("CURRENT_FOLDER", current_folder);
292         defaults->update("CURSOR_ON_FRAMES", cursor_on_frames);
293         defaults->update("CWINDOW_DEST", cwindow_dest);
294         defaults->update("CWINDOW_MASK", cwindow_mask);
295         defaults->update("CWINDOW_METER", cwindow_meter);
296         defaults->update("CWINDOW_OPERATION", cwindow_operation);
297         defaults->update("CWINDOW_SCROLLBARS", cwindow_scrollbars);
298         defaults->update("CWINDOW_XSCROLL", cwindow_xscroll);
299         defaults->update("CWINDOW_YSCROLL", cwindow_yscroll);
300         defaults->update("CWINDOW_ZOOM", cwindow_zoom);
301         defaults->update("DEFAULT_ATRANSITION", default_atransition);
302         defaults->update("DEFAULT_VTRANSITION", default_vtransition);
303         defaults->update("DEFAULT_TRANSITION_LENGTH", default_transition_length);
304     defaults->update("EDIT_HANDLE_MODE0", edit_handle_mode[0]);
305     defaults->update("EDIT_HANDLE_MODE1", edit_handle_mode[1]);
306     defaults->update("EDIT_HANDLE_MODE2", edit_handle_mode[2]);
307         defaults->update("EDITING_MODE", editing_mode);
308         defaults->update("ENABLE_DUPLEX", enable_duplex);
309     defaults->update("FOLDERLIST_FORMAT", folderlist_format);
310         defaults->update("FORCE_UNIPROCESSOR", force_uniprocessor);
311         defaults->update("FRAMERATE", frame_rate);
312         defaults->update("FRAMES_PER_FOOT", frames_per_foot);
313         defaults->update("HIGHLIGHTED_TRACK", highlighted_track);
314     defaults->update("INTERPOLATION_TYPE", interpolation_type);
315         defaults->update("LABELS_FOLLOW_EDITS", labels_follow_edits);
316         defaults->update("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
317         defaults->update("AUTO_KEYFRAMES", auto_keyframes);
318     defaults->update("METER_FORMAT", meter_format);
319     defaults->update("MIN_METER_DB", min_meter_db);
320         defaults->update("MPEG4_DEBLOCK", mpeg4_deblock);
321         defaults->update("OUTPUTW", output_w);
322         defaults->update("OUTPUTH", output_h);
323     defaults->update("PLAYBACK_BUFFER", playback_buffer);
324         defaults->update("PLAYBACK_PRELOAD", playback_preload);
325     defaults->update("PLAYBACK_SOFTWARE_POSITION", playback_software_position);
326     defaults->update("PLAYBACK_STRATEGY", playback_strategy);
327     for(int i = 0; i < 1 /* PLAYBACK_STRATEGIES */; i++)
328     {
329         sprintf(string, "PLAYBACK_CONFIGS_%d", i);
330         defaults->update(string, (int32_t)playback_config[i].total);
331         for(int j = 0; j < playback_config[i].total; j++)
332         {
333             playback_config[i].values[j]->save_defaults(defaults);
334         }
335     }
336     defaults->update("PLAYBACK_REALTIME", real_time_playback);
337         defaults->update("REALTIME_RECORD", real_time_record);
338     defaults->update("RECORD_SOFTWARE_POSITION", record_software_position);
339         defaults->update("RECORD_SYNC_DRIVES", record_sync_drives);
340         defaults->update("RECORD_SPEED", record_speed);  // Full lockup on anything higher
341         defaults->update("RECORD_WRITE_LENGTH", record_write_length); // Heroine kernel 2.2 scheduling sucks.
342         defaults->update("SAFE_REGIONS", safe_regions);
343         defaults->update("SAMPLERATE", sample_rate);
344     defaults->update("SCRUB_SPEED", scrub_speed);
345         defaults->update("SHOW_TITLES", show_titles);
346 //      defaults->update("TEST_PLAYBACK_EDITS", test_playback_edits);
347         defaults->update("TIME_FORMAT", time_format);
348         defaults->update("TOOL_WINDOW", tool_window);
349     vconfig_in->save_defaults(defaults);
350         for(int i = 0; i < MAXCHANNELS; i++)
351         {
352                 sprintf(string, "VCHANNEL_X_%d", i);
353                 defaults->update(string, vchannel_x[i]);
354                 sprintf(string, "VCHANNEL_Y_%d", i);
355                 defaults->update(string, vchannel_y[i]);
356         }
357         defaults->update("VCHANNELS", video_channels);
358     defaults->update("VIDEO_EVERY_FRAME", video_every_frame);
359         defaults->update("VTRACKS", video_tracks);
360         defaults->update("VIDEO_WRITE_LENGTH", video_write_length);
361     defaults->update("VIEW_FOLLOWS_PLAYBACK", view_follows_playback);
362         defaults->update("VWINDOW_METER", vwindow_meter);
363         defaults->update("VWINDOW_ZOOM", vwindow_zoom);
365         return 0;
370 // GCC 3.0 fails to compile
371 #define BC_INFINITY 65536
374 void EDLSession::boundaries()
376         Workarounds::clamp(audio_tracks, 0, (int)BC_INFINITY);
377         Workarounds::clamp(audio_channels, 1, MAXCHANNELS - 1);
378         Workarounds::clamp(sample_rate, 1, 1000000);
379         Workarounds::clamp(video_tracks, 0, (int)BC_INFINITY);
380         Workarounds::clamp(video_channels, 1, MAXCHANNELS - 1);
381         Workarounds::clamp(frame_rate, 1.0, (double)BC_INFINITY);
382         Workarounds::clamp(min_meter_db, -100, -1);
383         Workarounds::clamp(frames_per_foot, 1, 32);
384         Workarounds::clamp(output_w, 16, (int)BC_INFINITY);
385         Workarounds::clamp(output_h, 16, (int)BC_INFINITY);
386         Workarounds::clamp(video_write_length, 1, 1000);
387 //printf("EDLSession::boundaries 1\n");
388         output_w /= 2;
389         output_w *= 2;
390         output_h /= 2;
391         output_h *= 2;
393         Workarounds::clamp(crop_x1, 0, output_w);
394         Workarounds::clamp(crop_x2, 0, output_w);
395         Workarounds::clamp(crop_y1, 0, output_h);
396         Workarounds::clamp(crop_y2, 0, output_h);
397         if(brender_start < 0) brender_start = 0.0;
398 // Correct framerates
399         frame_rate = Units::fix_framerate(frame_rate);
400 //printf("EDLSession::boundaries 1 %p %p\n", edl->assets, edl->tracks);
401 //      if(vwindow_source < 0 || vwindow_source >= edl->assets->total() + 1) vwindow_source = 0;
402 //      if(cwindow_dest < 0 || cwindow_dest > edl->tracks->total()) cwindow_dest = 0;
403 //printf("EDLSession::boundaries 2\n");
408 int EDLSession::load_video_config(FileXML *file, int append_mode, uint32_t load_flags)
410         char string[1024];
411         if(append_mode) return 0;
412         interpolation_type = file->tag.get_property("INTERPOLATION_TYPE", interpolation_type);
413         cmodel_to_text(string, color_model);
414         color_model = cmodel_from_text(file->tag.get_property("COLORMODEL", string));
415         video_channels = file->tag.get_property("CHANNELS", video_channels);
416         for(int i = 0; i < video_channels; i++)
417         {
418                 int default_position = i * output_w;
419                 sprintf(string, "VCHANNEL_X_%d", i);
420                 vchannel_x[i] = file->tag.get_property(string, default_position);
421                 sprintf(string, "VCHANNEL_Y_%d", i);
422                 vchannel_y[i] = file->tag.get_property(string, 0);
423         }
425         frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
426         frames_per_foot = file->tag.get_property("FRAMES_PER_FOOT", frames_per_foot);
427         output_w = file->tag.get_property("OUTPUTW", output_w);
428         output_h = file->tag.get_property("OUTPUTH", output_h);
429         aspect_w = file->tag.get_property("ASPECTW", aspect_w);
430         aspect_h = file->tag.get_property("ASPECTH", aspect_h);
431         return 0;
434 int EDLSession::load_audio_config(FileXML *file, int append_mode, uint32_t load_flags)
436         char string[32];
437 // load channels setting
438         if(append_mode) return 0;
439         audio_channels = file->tag.get_property("CHANNELS", (int64_t)audio_channels);
442         for(int i = 0; i < audio_channels; i++)
443         {
444                 sprintf(string, "CHPOSITION%d", i);
445                 achannel_positions[i] = file->tag.get_property(string, achannel_positions[i]);
446         }
448         sample_rate = file->tag.get_property("SAMPLERATE", (int64_t)sample_rate);
449         return 0;
452 int EDLSession::load_xml(FileXML *file, 
453         int append_mode, 
454         uint32_t load_flags)
456         char string[BCTEXTLEN];
458         if(append_mode)
459         {
460         }
461         else
462         {
463                 assetlist_format = file->tag.get_property("ASSETLIST_FORMAT", assetlist_format);
464                 for(int i = 0; i < ASSET_COLUMNS; i++)
465                 {
466                         sprintf(string, "ASSET_COLUMN%d", i);
467                         asset_columns[i] = file->tag.get_property(string, asset_columns[i]);
468                 }
469                 audio_module_fragment = file->tag.get_property("AUDIO_MODULE_FRAGMENT", audio_module_fragment);
470                 audio_read_length = file->tag.get_property("PLAYBACK_READ_LENGTH", audio_read_length);
471                 auto_conf->load_xml(file);
472                 auto_keyframes = file->tag.get_property("AUTO_KEYFRAMES", auto_keyframes);
473                 autos_follow_edits = file->tag.get_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
474                 brender_start = file->tag.get_property("BRENDER_START", brender_start);
475                 crop_x1 = file->tag.get_property("CROP_X1", crop_x1);
476                 crop_y1 = file->tag.get_property("CROP_Y1", crop_y1);
477                 crop_x2 = file->tag.get_property("CROP_X2", crop_x2);
478                 crop_y2 = file->tag.get_property("CROP_Y2", crop_y2);
479                 file->tag.get_property("CURRENT_FOLDER", current_folder);
480                 cursor_on_frames = file->tag.get_property("CURSOR_ON_FRAMES", cursor_on_frames);
481                 cwindow_dest = file->tag.get_property("CWINDOW_DEST", cwindow_dest);
482                 cwindow_mask = file->tag.get_property("CWINDOW_MASK", cwindow_mask);
483                 cwindow_meter = file->tag.get_property("CWINDOW_METER", cwindow_meter);
484                 cwindow_operation = file->tag.get_property("CWINDOW_OPERATION", cwindow_operation);
485                 cwindow_scrollbars = file->tag.get_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
486                 cwindow_xscroll = file->tag.get_property("CWINDOW_XSCROLL", cwindow_xscroll);
487                 cwindow_yscroll = file->tag.get_property("CWINDOW_YSCROLL", cwindow_yscroll);
488                 cwindow_zoom = file->tag.get_property("CWINDOW_ZOOM", cwindow_zoom);
489                 file->tag.get_property("DEFAULT_ATRANSITION", default_atransition);
490                 file->tag.get_property("DEFAULT_VTRANSITION", default_vtransition);
491                 default_transition_length = file->tag.get_property("DEFAULT_TRANSITION_LENGTH", default_transition_length);
492                 editing_mode = file->tag.get_property("EDITING_MODE", editing_mode);
493                 folderlist_format = file->tag.get_property("FOLDERLIST_FORMAT", folderlist_format);
494                 force_uniprocessor = file->tag.get_property("FORCE_UNIPROCESSOR", force_uniprocessor);
495                 highlighted_track = file->tag.get_property("HIGHLIGHTED_TRACK", 0);
496                 labels_follow_edits = file->tag.get_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
497                 mpeg4_deblock = file->tag.get_property("MPEG4_DEBLOCK", mpeg4_deblock);
498                 plugins_follow_edits = file->tag.get_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
499                 playback_preload = file->tag.get_property("PLAYBACK_PRELOAD", playback_preload);
500                 safe_regions = file->tag.get_property("SAFE_REGIONS", safe_regions);
501                 show_titles = file->tag.get_property("SHOW_TITLES", 1);
502                 smp = calculate_smp();
503 //              test_playback_edits = file->tag.get_property("TEST_PLAYBACK_EDITS", test_playback_edits);
504                 time_format = file->tag.get_property("TIME_FORMAT", time_format);
505                 tool_window = file->tag.get_property("TOOL_WINDOW", tool_window);
506                 vwindow_meter = file->tag.get_property("VWINDOW_METER", vwindow_meter);
507                 file->tag.get_property("VWINDOW_FOLDER", vwindow_folder);
508                 vwindow_source = file->tag.get_property("VWINDOW_SOURCE", vwindow_source);
509                 vwindow_zoom = file->tag.get_property("VWINDOW_ZOOM", vwindow_zoom);
510         }
511         
512         return 0;
515 int EDLSession::save_xml(FileXML *file)
517 //printf("EDLSession::save_session 1\n");
518         char string[BCTEXTLEN];
519         file->tag.set_title("SESSION");
520         file->tag.set_property("ASSETLIST_FORMAT", assetlist_format);
521         for(int i = 0; i < ASSET_COLUMNS; i++)
522         {
523                 sprintf(string, "ASSET_COLUMN%d", i);
524                 file->tag.set_property(string, asset_columns[i]);
525         }
526         file->tag.set_property("AUDIO_MODULE_FRAGMENT", audio_module_fragment);
527         file->tag.set_property("PLAYBACK_READ_LENGTH", audio_read_length);
528         auto_conf->save_xml(file);
529         file->tag.set_property("AUTO_KEYFRAMES", auto_keyframes);
530         file->tag.set_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
531         file->tag.set_property("BRENDER_START", brender_start);
532         file->tag.set_property("CROP_X1", crop_x1);
533         file->tag.set_property("CROP_Y1", crop_y1);
534         file->tag.set_property("CROP_X2", crop_x2);
535         file->tag.set_property("CROP_Y2", crop_y2);
536         file->tag.set_property("CURRENT_FOLDER", current_folder);
537         file->tag.set_property("CURSOR_ON_FRAMES", cursor_on_frames);
538         file->tag.set_property("CWINDOW_DEST", cwindow_dest);
539         file->tag.set_property("CWINDOW_MASK", cwindow_mask);
540         file->tag.set_property("CWINDOW_METER", cwindow_meter);
541         file->tag.set_property("CWINDOW_OPERATION", cwindow_operation);
542         file->tag.set_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
543         file->tag.set_property("CWINDOW_XSCROLL", cwindow_xscroll);
544         file->tag.set_property("CWINDOW_YSCROLL", cwindow_yscroll);
545         file->tag.set_property("CWINDOW_ZOOM", cwindow_zoom);
546         file->tag.set_property("DEFAULT_ATRANSITION", default_atransition);
547         file->tag.set_property("DEFAULT_VTRANSITION", default_vtransition);
548         file->tag.set_property("DEFAULT_TRANSITION_LENGTH", default_transition_length);
549         file->tag.set_property("EDITING_MODE", editing_mode);
550         file->tag.set_property("FOLDERLIST_FORMAT", folderlist_format);
551         file->tag.set_property("FORCE_UNIPROCESSOR", force_uniprocessor);
552         file->tag.set_property("HIGHLIGHTED_TRACK", highlighted_track);
553         file->tag.set_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
554         file->tag.set_property("MPEG4_DEBLOCK", mpeg4_deblock);
555         file->tag.set_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
556         file->tag.set_property("PLAYBACK_PRELOAD", playback_preload);
557         file->tag.set_property("SAFE_REGIONS", safe_regions);
558         file->tag.set_property("SHOW_TITLES", show_titles);
559         file->tag.set_property("TEST_PLAYBACK_EDITS", test_playback_edits);
560         file->tag.set_property("TIME_FORMAT", time_format);
561         file->tag.set_property("TOOL_WINDOW", tool_window);
562         file->tag.set_property("VWINDOW_METER", vwindow_meter);
563         file->tag.set_property("VWINDOW_FOLDER", vwindow_folder);
564         file->tag.set_property("VWINDOW_SOURCE", vwindow_source);
565         file->tag.set_property("VWINDOW_ZOOM", vwindow_zoom);
566         file->append_tag();
567         file->append_newline();
568         file->append_newline();
569 //printf("EDLSession::save_session 3\n");
570         return 0;
573 int EDLSession::save_video_config(FileXML *file)
575         char string[1024];
576         file->tag.set_title("VIDEO");
577         file->tag.set_property("INTERPOLATION_TYPE", interpolation_type);
578         cmodel_to_text(string, color_model);
579         file->tag.set_property("COLORMODEL", string);
580     file->tag.set_property("CHANNELS", video_channels);
581         for(int i = 0; i < video_channels; i++)
582         {
583                 sprintf(string, "VCHANNEL_X_%d", i);
584                 file->tag.set_property(string, vchannel_x[i]);
585                 sprintf(string, "VCHANNEL_Y_%d", i);
586                 file->tag.set_property(string, vchannel_y[i]);
587         }
589         file->tag.set_property("FRAMERATE", frame_rate);
590         file->tag.set_property("FRAMES_PER_FOOT", frames_per_foot);
591         file->tag.set_property("OUTPUTW", output_w);
592         file->tag.set_property("OUTPUTH", output_h);
593         file->tag.set_property("ASPECTW", aspect_w);
594         file->tag.set_property("ASPECTH", aspect_h);
595         file->append_tag();
596         file->append_newline();
597         file->append_newline();
598         return 0;
601 int EDLSession::save_audio_config(FileXML *file)
603         char string[1024];
604         file->tag.set_title("AUDIO");
605         file->tag.set_property("SAMPLERATE", (int64_t)sample_rate);
606         file->tag.set_property("CHANNELS", (int64_t)audio_channels);
607         
608         for(int i = 0; i < audio_channels; i++)
609         {
610                 sprintf(string, "ACHANNEL_ANGLE_%d", i);
611                 file->tag.set_property(string, achannel_positions[i]);
612         }
613         
614         file->append_tag();
615         file->append_newline();
616         file->append_newline();
617         return 0;
620 int EDLSession::copy(EDLSession *session)
622 // Audio channel positions
623         for(int i = 0; i < MAXCHANNELS; i++)
624         {
625                 achannel_positions[i] = session->achannel_positions[i];
626         }
627         *aconfig_duplex = *session->aconfig_duplex;
628         *aconfig_in = *session->aconfig_in;
629         actual_frame_rate = session->actual_frame_rate;
630         for(int i = 0; i < ASSET_COLUMNS; i++)
631         {
632                 asset_columns[i] = session->asset_columns[i];
633         }
634         assetlist_format = session->assetlist_format;
635         *auto_conf = *session->auto_conf;
636         aspect_w = session->aspect_w;
637         aspect_h = session->aspect_h;
638         audio_channels = session->audio_channels;
639         audio_module_fragment = session->audio_module_fragment;
640         audio_read_length = session->audio_read_length;
641         audio_tracks = session->audio_tracks;
642         autos_follow_edits = session->autos_follow_edits;
643         brender_start = session->brender_start;
644         color_model = session->color_model;
645         crop_x1 = session->crop_x1;
646         crop_y1 = session->crop_y1;
647         crop_x2 = session->crop_x2;
648         crop_y2 = session->crop_y2;
649         strcpy(current_folder, session->current_folder);
650         cursor_on_frames = session->cursor_on_frames;
651         cwindow_dest = session->cwindow_dest;
652         cwindow_mask = session->cwindow_mask;
653         cwindow_meter = session->cwindow_meter;
654         cwindow_operation = session->cwindow_operation;
655         cwindow_scrollbars = session->cwindow_scrollbars;
656         cwindow_xscroll = session->cwindow_xscroll;
657         cwindow_yscroll = session->cwindow_yscroll;
658         cwindow_zoom = session->cwindow_zoom;
659         strcpy(default_atransition, session->default_atransition);
660         strcpy(default_vtransition, session->default_vtransition);
661         default_transition_length = session->default_transition_length;
662         edit_handle_mode[0] = session->edit_handle_mode[0];
663         edit_handle_mode[1] = session->edit_handle_mode[1];
664         edit_handle_mode[2] = session->edit_handle_mode[2];
665         editing_mode = session->editing_mode;
666         enable_duplex = session->enable_duplex;
667         folderlist_format = session->folderlist_format;
668         force_uniprocessor = session->force_uniprocessor;
669         smp = calculate_smp();
670         frame_rate = session->frame_rate;
671         frames_per_foot = session->frames_per_foot;
672         highlighted_track = session->highlighted_track;
673         interpolation_type = session->interpolation_type;
674         labels_follow_edits = session->labels_follow_edits;
675         plugins_follow_edits = session->plugins_follow_edits;
676         auto_keyframes = session->auto_keyframes;
677 //      last_playback_position = session->last_playback_position;
678         meter_format = session->meter_format;
679         min_meter_db = session->min_meter_db;
680         mpeg4_deblock = session->mpeg4_deblock;
681         output_w = session->output_w;
682         output_h = session->output_h;
683         playback_buffer = session->playback_buffer;
684         for(int i = 0; i < PLAYBACK_STRATEGIES; i++)
685         {
686                 playback_config[i].remove_all_objects();
687                 for(int j = 0; j < session->playback_config[i].total; j++)
688                 {
689                         PlaybackConfig *config;
690                         playback_config[i].append(config = new PlaybackConfig(i, j));
691                         *config = *session->playback_config[i].values[j];
692                 }
693         }
694         playback_cursor_visible = session->playback_cursor_visible;
695         playback_preload = session->playback_preload;
696         playback_software_position = session->playback_software_position;
697         playback_strategy = session->playback_strategy;
698         real_time_playback = session->real_time_playback;
699         real_time_record = session->real_time_record;
700         record_software_position = session->record_software_position;
701         record_speed = session->record_speed;
702         record_sync_drives = session->record_sync_drives;
703         record_write_length = session->record_write_length;
704         safe_regions = session->safe_regions;
705         sample_rate = session->sample_rate;
706         scrub_speed = session->scrub_speed;
707         show_titles = session->show_titles;
708         smp = force_uniprocessor ? 0 : session->smp;
709         test_playback_edits = session->test_playback_edits;
710         time_format = session->time_format;
711         tool_window = session->tool_window;
712         for(int i = 0; i < MAXCHANNELS; i++)
713         {
714                 vchannel_x[i] = session->vchannel_x[i];
715                 vchannel_y[i] = session->vchannel_y[i];
716         }
717         video_channels = session->video_channels;
718         *vconfig_in = *session->vconfig_in;
719         video_every_frame = session->video_every_frame;
720         video_tracks = session->video_tracks;
721         video_write_length = session->video_write_length;       
722         view_follows_playback = session->view_follows_playback;
723         vwindow_meter = session->vwindow_meter;
724         strcpy(vwindow_folder, session->vwindow_folder);
725         vwindow_source = session->vwindow_source;
726         vwindow_zoom = session->vwindow_zoom;
727         return 0;