00001 #include "assets.h"
00002 #include "autoconf.h"
00003 #include "colormodels.h"
00004 #include "defaults.h"
00005 #include "edl.h"
00006 #include "edlsession.h"
00007 #include "filexml.h"
00008 #include "interlacemodes.h"
00009 #include "overlayframe.inc"
00010 #include "playbackconfig.h"
00011 #include "recordconfig.h"
00012 #include "tracks.h"
00013 #include "workarounds.h"
00014
00015 int EDLSession::current_id = 0;
00016
00017 EDLSession::EDLSession(EDL *edl)
00018 {
00019 highlighted_track = 0;
00020 playback_cursor_visible = 0;
00021 aconfig_in = new AudioInConfig;
00022 aconfig_duplex = new AudioOutConfig(1);
00023 vconfig_in = new VideoInConfig;
00024 interpolation_type = CUBIC_LINEAR;
00025 test_playback_edits = 1;
00026 brender_start = 0.0;
00027 mpeg4_deblock = 1;
00028
00029 playback_config = new PlaybackConfig;
00030 auto_conf = new AutoConf;
00031 strcpy(vwindow_folder, "");
00032 strcpy(current_folder, "");
00033 strcpy(default_atransition, "");
00034 strcpy(default_vtransition, "");
00035 default_transition_length = 1.0;
00036 folderlist_format = ASSETS_ICONS;
00037 frame_rate = 25;
00038 autos_follow_edits = 1;
00039 labels_follow_edits = 1;
00040 plugins_follow_edits = 1;
00041 audio_tracks = -10;
00042 audio_channels = -10;
00043 video_tracks = -10;
00044 video_channels = -10;
00045 sample_rate = -10;
00046 frame_rate = -10;
00047 frames_per_foot = -10;
00048 min_meter_db = -1000;
00049 max_meter_db = -1000;
00050 output_w = -1000;
00051 output_h = -1000;
00052 video_write_length = -1000;
00053 color_model = -100;
00054 interlace_mode = BC_ILACE_MODE_UNDETECTED;
00055 }
00056
00057 EDLSession::~EDLSession()
00058 {
00059 delete aconfig_in;
00060 delete aconfig_duplex;
00061 delete auto_conf;
00062 delete vconfig_in;
00063 delete playback_config;
00064 }
00065
00066
00067 char* EDLSession::get_cwindow_display()
00068 {
00069 if(playback_config->vconfig->x11_host[0])
00070 return playback_config->vconfig->x11_host;
00071 else
00072 return 0;
00073 }
00074
00075
00076
00077 void EDLSession::equivalent_output(EDLSession *session, double *result)
00078 {
00079 if(session->output_w != output_w ||
00080 session->output_h != output_h ||
00081 session->frame_rate != frame_rate ||
00082 session->color_model != color_model ||
00083 session->interpolation_type != interpolation_type ||
00084 session->mpeg4_deblock != mpeg4_deblock)
00085 *result = 0;
00086
00087
00088
00089 if(brender_start != session->brender_start &&
00090 (*result < 0 || *result > brender_start))
00091 *result = brender_start;
00092 }
00093
00094
00095 int EDLSession::load_defaults(Defaults *defaults)
00096 {
00097 char string[BCTEXTLEN];
00098
00099
00100 for(int i = 0; i < MAXCHANNELS; i++)
00101 {
00102 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00103 int default_position = i * 30;
00104
00105 if(i == 0) default_position = 180;
00106 else
00107 if(i == 1) default_position = 0;
00108 else
00109 if(default_position == 90) default_position = 300;
00110 else
00111 if(default_position == 0) default_position = 330;
00112
00113 achannel_positions[i] = defaults->get(string, default_position);
00114 }
00115 aconfig_duplex->load_defaults(defaults);
00116 aconfig_in->load_defaults(defaults);
00117 actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1);
00118 assetlist_format = defaults->get("ASSETLIST_FORMAT", ASSETS_ICONS);
00119 aspect_w = defaults->get("ASPECTW", (float)4);
00120 aspect_h = defaults->get("ASPECTH", (float)3);
00121 for(int i = 0; i < ASSET_COLUMNS; i++)
00122 {
00123 sprintf(string, "ASSET_COLUMN%d", i);
00124 asset_columns[i] = defaults->get(string, 100);
00125 }
00126 audio_channels = defaults->get("ACHANNELS", 2);
00127 audio_tracks = defaults->get("ATRACKS", 2);
00128 auto_conf->load_defaults(defaults);
00129 autos_follow_edits = defaults->get("AUTOS_FOLLOW_EDITS", 1);
00130 brender_start = defaults->get("BRENDER_START", brender_start);
00131 cmodel_to_text(string, BC_RGBA8888);
00132 color_model = cmodel_from_text(defaults->get("COLOR_MODEL", string));
00133 interlace_mode = defaults->get("INTERLACE_MODE", interlace_mode);
00134 crop_x1 = defaults->get("CROP_X1", 0);
00135 crop_x2 = defaults->get("CROP_X2", 320);
00136 crop_y1 = defaults->get("CROP_Y1", 0);
00137 crop_y2 = defaults->get("CROP_Y2", 240);
00138 sprintf(current_folder, MEDIA_FOLDER);
00139 defaults->get("CURRENT_FOLDER", current_folder);
00140 cursor_on_frames = defaults->get("CURSOR_ON_FRAMES", 1);
00141 cwindow_dest = defaults->get("CWINDOW_DEST", 0);
00142 cwindow_mask = defaults->get("CWINDOW_MASK", 0);
00143 cwindow_meter = defaults->get("CWINDOW_METER", 1);
00144 cwindow_operation = defaults->get("CWINDOW_OPERATION", 0);
00145 cwindow_scrollbars = defaults->get("CWINDOW_SCROLLBARS", 1);
00146 cwindow_xscroll = defaults->get("CWINDOW_XSCROLL", 0);
00147 cwindow_yscroll = defaults->get("CWINDOW_YSCROLL", 0);
00148 cwindow_zoom = defaults->get("CWINDOW_ZOOM", (float)1);
00149 sprintf(default_atransition, "Crossfade");
00150 defaults->get("DEFAULT_ATRANSITION", default_atransition);
00151 sprintf(default_vtransition, "Dissolve");
00152 defaults->get("DEFAULT_VTRANSITION", default_vtransition);
00153 default_transition_length = defaults->get("DEFAULT_TRANSITION_LENGTH", (double)1);
00154 edit_handle_mode[0] = defaults->get("EDIT_HANDLE_MODE0", MOVE_ALL_EDITS);
00155 edit_handle_mode[1] = defaults->get("EDIT_HANDLE_MODE1", MOVE_ONE_EDIT);
00156 edit_handle_mode[2] = defaults->get("EDIT_HANDLE_MODE2", MOVE_NO_EDITS);
00157 editing_mode = defaults->get("EDITING_MODE", EDITING_IBEAM);
00158 enable_duplex = defaults->get("ENABLE_DUPLEX", 1);
00159 folderlist_format = defaults->get("FOLDERLIST_FORMAT", FOLDERS_ICONS);
00160 frame_rate = defaults->get("FRAMERATE", (double)30000.0/1001);
00161 frames_per_foot = defaults->get("FRAMES_PER_FOOT", (float)16);
00162 interpolation_type = defaults->get("INTERPOLATION_TYPE", interpolation_type);
00163 labels_follow_edits = defaults->get("LABELS_FOLLOW_EDITS", 1);
00164 plugins_follow_edits = defaults->get("PLUGINS_FOLLOW_EDITS", 1);
00165 auto_keyframes = defaults->get("AUTO_KEYFRAMES", 0);
00166 meter_format = defaults->get("METER_FORMAT", METER_DB);
00167 min_meter_db = defaults->get("MIN_METER_DB", -85);
00168 max_meter_db = defaults->get("MAX_METER_DB", 6);
00169 mpeg4_deblock = defaults->get("MPEG4_DEBLOCK", mpeg4_deblock);
00170 output_w = defaults->get("OUTPUTW", 720);
00171 output_h = defaults->get("OUTPUTH", 480);
00172 playback_buffer = defaults->get("PLAYBACK_BUFFER", 4096);
00173 playback_preload = defaults->get("PLAYBACK_PRELOAD", 0);
00174 playback_software_position = defaults->get("PLAYBACK_SOFTWARE_POSITION", 0);
00175 delete playback_config;
00176 playback_config = new PlaybackConfig;
00177 playback_config->load_defaults(defaults);
00178 real_time_playback = defaults->get("PLAYBACK_REALTIME", 0);
00179 real_time_record = defaults->get("REALTIME_RECORD", 0);
00180 record_software_position = defaults->get("RECORD_SOFTWARE_POSITION", 1);
00181 record_sync_drives = defaults->get("RECORD_SYNC_DRIVES", 0);
00182 record_speed = defaults->get("RECORD_SPEED", 8);
00183 record_write_length = defaults->get("RECORD_WRITE_LENGTH", 131072);
00184 safe_regions = defaults->get("SAFE_REGIONS", 1);
00185 sample_rate = defaults->get("SAMPLERATE", 48000);
00186 scrub_speed = defaults->get("SCRUB_SPEED", (float)2);
00187 si_useduration = defaults->get("SI_USEDURATION",0);
00188 si_duration = defaults->get("SI_DURATION",5);
00189
00190 show_assets = defaults->get("SHOW_ASSETS", 1);
00191 show_titles = defaults->get("SHOW_TITLES", 1);
00192
00193 time_format = defaults->get("TIME_FORMAT", TIME_HMS);
00194 for(int i = 0; i < 4; i++)
00195 {
00196 sprintf(string, "TIMECODE_OFFSET_%d", i);
00197 timecode_offset[i] = defaults->get(string, 0);
00198 }
00199 nudge_seconds = defaults->get("NUDGE_FORMAT", 1);
00200 tool_window = defaults->get("TOOL_WINDOW", 0);
00201 vconfig_in->load_defaults(defaults);
00202 for(int i = 0; i < MAXCHANNELS; i++)
00203 {
00204 int default_position = i * output_w;
00205 sprintf(string, "VCHANNEL_X_%d", i);
00206 vchannel_x[i] = defaults->get(string, default_position);
00207 sprintf(string, "VCHANNEL_Y_%d", i);
00208 vchannel_y[i] = defaults->get(string, 0);
00209 }
00210 video_channels = defaults->get("VCHANNELS", 1);
00211 video_every_frame = defaults->get("VIDEO_EVERY_FRAME", 0);
00212 video_tracks = defaults->get("VTRACKS", 1);
00213 video_write_length = defaults->get("VIDEO_WRITE_LENGTH", 30);
00214 view_follows_playback = defaults->get("VIEW_FOLLOWS_PLAYBACK", 1);
00215 vwindow_meter = defaults->get("VWINDOW_METER", 1);
00216
00217 vwindow_folder[0] = 0;
00218 vwindow_source = -1;
00219 vwindow_zoom = defaults->get("VWINDOW_ZOOM", (float)1);
00220 boundaries();
00221
00222 return 0;
00223 }
00224
00225 int EDLSession::save_defaults(Defaults *defaults)
00226 {
00227 char string[BCTEXTLEN];
00228
00229
00230 for(int i = 0; i < MAXCHANNELS; i++)
00231 {
00232 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00233 defaults->update(string, achannel_positions[i]);
00234 }
00235 defaults->update("ACHANNELS", audio_channels);
00236 aconfig_duplex->save_defaults(defaults);
00237 aconfig_in->save_defaults(defaults);
00238 for(int i = 0; i < ASSET_COLUMNS; i++)
00239 {
00240 sprintf(string, "ASSET_COLUMN%d", i);
00241 defaults->update(string, asset_columns[i]);
00242 }
00243 auto_conf->save_defaults(defaults);
00244 defaults->update("ACTUAL_FRAME_RATE", actual_frame_rate);
00245 defaults->update("ASSETLIST_FORMAT", assetlist_format);
00246 defaults->update("ASPECTW", aspect_w);
00247 defaults->update("ASPECTH", aspect_h);
00248 defaults->update("ATRACKS", audio_tracks);
00249 defaults->update("AUTOS_FOLLOW_EDITS", autos_follow_edits);
00250 defaults->update("BRENDER_START", brender_start);
00251 cmodel_to_text(string, color_model);
00252 defaults->update("COLOR_MODEL", string);
00253 defaults->update("INTERLACE_MODE", interlace_mode);
00254 defaults->update("CROP_X1", crop_x1);
00255 defaults->update("CROP_X2", crop_x2);
00256 defaults->update("CROP_Y1", crop_y1);
00257 defaults->update("CROP_Y2", crop_y2);
00258 defaults->update("CURRENT_FOLDER", current_folder);
00259 defaults->update("CURSOR_ON_FRAMES", cursor_on_frames);
00260 defaults->update("CWINDOW_DEST", cwindow_dest);
00261 defaults->update("CWINDOW_MASK", cwindow_mask);
00262 defaults->update("CWINDOW_METER", cwindow_meter);
00263 defaults->update("CWINDOW_OPERATION", cwindow_operation);
00264 defaults->update("CWINDOW_SCROLLBARS", cwindow_scrollbars);
00265 defaults->update("CWINDOW_XSCROLL", cwindow_xscroll);
00266 defaults->update("CWINDOW_YSCROLL", cwindow_yscroll);
00267 defaults->update("CWINDOW_ZOOM", cwindow_zoom);
00268 defaults->update("DEFAULT_ATRANSITION", default_atransition);
00269 defaults->update("DEFAULT_VTRANSITION", default_vtransition);
00270 defaults->update("DEFAULT_TRANSITION_LENGTH", default_transition_length);
00271 defaults->update("EDIT_HANDLE_MODE0", edit_handle_mode[0]);
00272 defaults->update("EDIT_HANDLE_MODE1", edit_handle_mode[1]);
00273 defaults->update("EDIT_HANDLE_MODE2", edit_handle_mode[2]);
00274 defaults->update("EDITING_MODE", editing_mode);
00275 defaults->update("ENABLE_DUPLEX", enable_duplex);
00276 defaults->update("FOLDERLIST_FORMAT", folderlist_format);
00277 defaults->update("FRAMERATE", frame_rate);
00278 defaults->update("FRAMES_PER_FOOT", frames_per_foot);
00279 defaults->update("HIGHLIGHTED_TRACK", highlighted_track);
00280 defaults->update("INTERPOLATION_TYPE", interpolation_type);
00281 defaults->update("LABELS_FOLLOW_EDITS", labels_follow_edits);
00282 defaults->update("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
00283 defaults->update("AUTO_KEYFRAMES", auto_keyframes);
00284 defaults->update("METER_FORMAT", meter_format);
00285 defaults->update("MIN_METER_DB", min_meter_db);
00286 defaults->update("MAX_METER_DB", max_meter_db);
00287 defaults->update("MPEG4_DEBLOCK", mpeg4_deblock);
00288 defaults->update("OUTPUTW", output_w);
00289 defaults->update("OUTPUTH", output_h);
00290 defaults->update("PLAYBACK_BUFFER", playback_buffer);
00291 defaults->update("PLAYBACK_PRELOAD", playback_preload);
00292 defaults->update("PLAYBACK_SOFTWARE_POSITION", playback_software_position);
00293 playback_config->save_defaults(defaults);
00294 defaults->update("PLAYBACK_REALTIME", real_time_playback);
00295 defaults->update("REALTIME_RECORD", real_time_record);
00296 defaults->update("RECORD_SOFTWARE_POSITION", record_software_position);
00297 defaults->update("RECORD_SYNC_DRIVES", record_sync_drives);
00298 defaults->update("RECORD_SPEED", record_speed);
00299 defaults->update("RECORD_WRITE_LENGTH", record_write_length);
00300 defaults->update("SAFE_REGIONS", safe_regions);
00301 defaults->update("SAMPLERATE", sample_rate);
00302 defaults->update("SCRUB_SPEED", scrub_speed);
00303 defaults->update("SI_USEDURATION",si_useduration);
00304 defaults->update("SI_DURATION",si_duration);
00305 defaults->update("SHOW_ASSETS", show_assets);
00306 defaults->update("SHOW_TITLES", show_titles);
00307
00308 defaults->update("TIME_FORMAT", time_format);
00309 for(int i = 0; i < 4; i++)
00310 {
00311 sprintf(string, "TIMECODE_OFFSET_%d", i);
00312 defaults->update(string, timecode_offset[i]);
00313 }
00314 defaults->update("NUDGE_FORMAT", nudge_seconds);
00315 defaults->update("TOOL_WINDOW", tool_window);
00316 vconfig_in->save_defaults(defaults);
00317 for(int i = 0; i < MAXCHANNELS; i++)
00318 {
00319 sprintf(string, "VCHANNEL_X_%d", i);
00320 defaults->update(string, vchannel_x[i]);
00321 sprintf(string, "VCHANNEL_Y_%d", i);
00322 defaults->update(string, vchannel_y[i]);
00323 }
00324 defaults->update("VCHANNELS", video_channels);
00325 defaults->update("VIDEO_EVERY_FRAME", video_every_frame);
00326 defaults->update("VTRACKS", video_tracks);
00327 defaults->update("VIDEO_WRITE_LENGTH", video_write_length);
00328 defaults->update("VIEW_FOLLOWS_PLAYBACK", view_follows_playback);
00329 defaults->update("VWINDOW_METER", vwindow_meter);
00330 defaults->update("VWINDOW_ZOOM", vwindow_zoom);
00331
00332 return 0;
00333 }
00334
00335
00336
00337
00338 #define BC_INFINITY 65536
00339
00340
00341 void EDLSession::boundaries()
00342 {
00343 Workarounds::clamp(audio_tracks, 0, (int)BC_INFINITY);
00344 Workarounds::clamp(audio_channels, 1, MAXCHANNELS - 1);
00345 Workarounds::clamp(sample_rate, 1, 1000000);
00346 Workarounds::clamp(video_tracks, 0, (int)BC_INFINITY);
00347 Workarounds::clamp(video_channels, 1, MAXCHANNELS - 1);
00348 Workarounds::clamp(frame_rate, 1.0, (double)BC_INFINITY);
00349 Workarounds::clamp(min_meter_db, -80, -20);
00350 Workarounds::clamp(max_meter_db, 0, 10);
00351 Workarounds::clamp(frames_per_foot, 1, 32);
00352 Workarounds::clamp(output_w, 16, (int)BC_INFINITY);
00353 Workarounds::clamp(output_h, 16, (int)BC_INFINITY);
00354 Workarounds::clamp(video_write_length, 1, 1000);
00355
00356 output_w /= 2;
00357 output_w *= 2;
00358 output_h /= 2;
00359 output_h *= 2;
00360
00361 Workarounds::clamp(crop_x1, 0, output_w);
00362 Workarounds::clamp(crop_x2, 0, output_w);
00363 Workarounds::clamp(crop_y1, 0, output_h);
00364 Workarounds::clamp(crop_y2, 0, output_h);
00365 if(brender_start < 0) brender_start = 0.0;
00366
00367 frame_rate = Units::fix_framerate(frame_rate);
00368
00369
00370
00371
00372 }
00373
00374
00375
00376 int EDLSession::load_video_config(FileXML *file, int append_mode, uint32_t load_flags)
00377 {
00378 char string[1024];
00379 if(append_mode) return 0;
00380 interpolation_type = file->tag.get_property("INTERPOLATION_TYPE", interpolation_type);
00381 cmodel_to_text(string, color_model);
00382 color_model = cmodel_from_text(file->tag.get_property("COLORMODEL", string));
00383 video_channels = file->tag.get_property("CHANNELS", video_channels);
00384 for(int i = 0; i < video_channels; i++)
00385 {
00386 int default_position = i * output_w;
00387 sprintf(string, "VCHANNEL_X_%d", i);
00388 vchannel_x[i] = file->tag.get_property(string, default_position);
00389 sprintf(string, "VCHANNEL_Y_%d", i);
00390 vchannel_y[i] = file->tag.get_property(string, 0);
00391 }
00392
00393 frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
00394 frames_per_foot = file->tag.get_property("FRAMES_PER_FOOT", frames_per_foot);
00395 output_w = file->tag.get_property("OUTPUTW", output_w);
00396 output_h = file->tag.get_property("OUTPUTH", output_h);
00397 aspect_w = file->tag.get_property("ASPECTW", aspect_w);
00398 aspect_h = file->tag.get_property("ASPECTH", aspect_h);
00399 return 0;
00400 }
00401
00402 int EDLSession::load_audio_config(FileXML *file, int append_mode, uint32_t load_flags)
00403 {
00404 char string[32];
00405
00406 if(append_mode) return 0;
00407 audio_channels = file->tag.get_property("CHANNELS", (int64_t)audio_channels);
00408
00409
00410 for(int i = 0; i < audio_channels; i++)
00411 {
00412 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00413 achannel_positions[i] = file->tag.get_property(string, achannel_positions[i]);
00414
00415 }
00416
00417 sample_rate = file->tag.get_property("SAMPLERATE", (int64_t)sample_rate);
00418 return 0;
00419 }
00420
00421 int EDLSession::load_xml(FileXML *file,
00422 int append_mode,
00423 uint32_t load_flags)
00424 {
00425 char string[BCTEXTLEN];
00426
00427 if(append_mode)
00428 {
00429 }
00430 else
00431 {
00432 assetlist_format = file->tag.get_property("ASSETLIST_FORMAT", assetlist_format);
00433 for(int i = 0; i < ASSET_COLUMNS; i++)
00434 {
00435 sprintf(string, "ASSET_COLUMN%d", i);
00436 asset_columns[i] = file->tag.get_property(string, asset_columns[i]);
00437 }
00438 auto_conf->load_xml(file);
00439 auto_keyframes = file->tag.get_property("AUTO_KEYFRAMES", auto_keyframes);
00440 autos_follow_edits = file->tag.get_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
00441 brender_start = file->tag.get_property("BRENDER_START", brender_start);
00442 crop_x1 = file->tag.get_property("CROP_X1", crop_x1);
00443 crop_y1 = file->tag.get_property("CROP_Y1", crop_y1);
00444 crop_x2 = file->tag.get_property("CROP_X2", crop_x2);
00445 crop_y2 = file->tag.get_property("CROP_Y2", crop_y2);
00446 file->tag.get_property("CURRENT_FOLDER", current_folder);
00447 cursor_on_frames = file->tag.get_property("CURSOR_ON_FRAMES", cursor_on_frames);
00448 cwindow_dest = file->tag.get_property("CWINDOW_DEST", cwindow_dest);
00449 cwindow_mask = file->tag.get_property("CWINDOW_MASK", cwindow_mask);
00450 cwindow_meter = file->tag.get_property("CWINDOW_METER", cwindow_meter);
00451 cwindow_operation = file->tag.get_property("CWINDOW_OPERATION", cwindow_operation);
00452 cwindow_scrollbars = file->tag.get_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
00453 cwindow_xscroll = file->tag.get_property("CWINDOW_XSCROLL", cwindow_xscroll);
00454 cwindow_yscroll = file->tag.get_property("CWINDOW_YSCROLL", cwindow_yscroll);
00455 cwindow_zoom = file->tag.get_property("CWINDOW_ZOOM", cwindow_zoom);
00456 file->tag.get_property("DEFAULT_ATRANSITION", default_atransition);
00457 file->tag.get_property("DEFAULT_VTRANSITION", default_vtransition);
00458 default_transition_length = file->tag.get_property("DEFAULT_TRANSITION_LENGTH", default_transition_length);
00459 editing_mode = file->tag.get_property("EDITING_MODE", editing_mode);
00460 folderlist_format = file->tag.get_property("FOLDERLIST_FORMAT", folderlist_format);
00461 highlighted_track = file->tag.get_property("HIGHLIGHTED_TRACK", 0);
00462 labels_follow_edits = file->tag.get_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
00463 mpeg4_deblock = file->tag.get_property("MPEG4_DEBLOCK", mpeg4_deblock);
00464 plugins_follow_edits = file->tag.get_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
00465 playback_preload = file->tag.get_property("PLAYBACK_PRELOAD", playback_preload);
00466 safe_regions = file->tag.get_property("SAFE_REGIONS", safe_regions);
00467 show_assets = file->tag.get_property("SHOW_ASSETS", 1);
00468 show_titles = file->tag.get_property("SHOW_TITLES", 1);
00469
00470 time_format = file->tag.get_property("TIME_FORMAT", time_format);
00471 for(int i = 0; i < 4; i++)
00472 {
00473 sprintf(string, "TIMECODE_OFFSET_%d", i);
00474 timecode_offset[i] = file->tag.get_property(string, timecode_offset[i]);
00475 }
00476 nudge_seconds = file->tag.get_property("NUDGE_FORMAT", nudge_seconds);
00477 tool_window = file->tag.get_property("TOOL_WINDOW", tool_window);
00478 vwindow_meter = file->tag.get_property("VWINDOW_METER", vwindow_meter);
00479 file->tag.get_property("VWINDOW_FOLDER", vwindow_folder);
00480 vwindow_source = file->tag.get_property("VWINDOW_SOURCE", vwindow_source);
00481 vwindow_zoom = file->tag.get_property("VWINDOW_ZOOM", vwindow_zoom);
00482 boundaries();
00483 }
00484
00485 return 0;
00486 }
00487
00488 int EDLSession::save_xml(FileXML *file)
00489 {
00490
00491 char string[BCTEXTLEN];
00492 file->tag.set_title("SESSION");
00493 file->tag.set_property("ASSETLIST_FORMAT", assetlist_format);
00494 for(int i = 0; i < ASSET_COLUMNS; i++)
00495 {
00496 sprintf(string, "ASSET_COLUMN%d", i);
00497 file->tag.set_property(string, asset_columns[i]);
00498 }
00499 auto_conf->save_xml(file);
00500 file->tag.set_property("AUTO_KEYFRAMES", auto_keyframes);
00501 file->tag.set_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
00502 file->tag.set_property("BRENDER_START", brender_start);
00503 file->tag.set_property("CROP_X1", crop_x1);
00504 file->tag.set_property("CROP_Y1", crop_y1);
00505 file->tag.set_property("CROP_X2", crop_x2);
00506 file->tag.set_property("CROP_Y2", crop_y2);
00507 file->tag.set_property("CURRENT_FOLDER", current_folder);
00508 file->tag.set_property("CURSOR_ON_FRAMES", cursor_on_frames);
00509 file->tag.set_property("CWINDOW_DEST", cwindow_dest);
00510 file->tag.set_property("CWINDOW_MASK", cwindow_mask);
00511 file->tag.set_property("CWINDOW_METER", cwindow_meter);
00512 file->tag.set_property("CWINDOW_OPERATION", cwindow_operation);
00513 file->tag.set_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
00514 file->tag.set_property("CWINDOW_XSCROLL", cwindow_xscroll);
00515 file->tag.set_property("CWINDOW_YSCROLL", cwindow_yscroll);
00516 file->tag.set_property("CWINDOW_ZOOM", cwindow_zoom);
00517 file->tag.set_property("DEFAULT_ATRANSITION", default_atransition);
00518 file->tag.set_property("DEFAULT_VTRANSITION", default_vtransition);
00519 file->tag.set_property("DEFAULT_TRANSITION_LENGTH", default_transition_length);
00520 file->tag.set_property("EDITING_MODE", editing_mode);
00521 file->tag.set_property("FOLDERLIST_FORMAT", folderlist_format);
00522 file->tag.set_property("HIGHLIGHTED_TRACK", highlighted_track);
00523 file->tag.set_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
00524 file->tag.set_property("MPEG4_DEBLOCK", mpeg4_deblock);
00525 file->tag.set_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
00526 file->tag.set_property("PLAYBACK_PRELOAD", playback_preload);
00527 file->tag.set_property("SAFE_REGIONS", safe_regions);
00528 file->tag.set_property("SHOW_ASSETS", show_assets);
00529 file->tag.set_property("SHOW_TITLES", show_titles);
00530 file->tag.set_property("TEST_PLAYBACK_EDITS", test_playback_edits);
00531 file->tag.set_property("TIME_FORMAT", time_format);
00532 for(int i = 0; i < 4; i++)
00533 {
00534 sprintf(string, "TIMECODE_OFFSET_%d", i);
00535 file->tag.set_property(string, timecode_offset[i]);
00536 }
00537 file->tag.set_property("NUDGE_SECONDS", nudge_seconds);
00538 file->tag.set_property("TOOL_WINDOW", tool_window);
00539 file->tag.set_property("VWINDOW_METER", vwindow_meter);
00540 file->tag.set_property("VWINDOW_FOLDER", vwindow_folder);
00541 file->tag.set_property("VWINDOW_SOURCE", vwindow_source);
00542 file->tag.set_property("VWINDOW_ZOOM", vwindow_zoom);
00543 file->append_tag();
00544 file->tag.set_title("/SESSION");
00545 file->append_tag();
00546 file->append_newline();
00547 file->append_newline();
00548
00549 return 0;
00550 }
00551
00552 int EDLSession::save_video_config(FileXML *file)
00553 {
00554 char string[1024];
00555 file->tag.set_title("VIDEO");
00556 file->tag.set_property("INTERPOLATION_TYPE", interpolation_type);
00557 cmodel_to_text(string, color_model);
00558 file->tag.set_property("COLORMODEL", string);
00559 file->tag.set_property("CHANNELS", video_channels);
00560 for(int i = 0; i < video_channels; i++)
00561 {
00562 sprintf(string, "VCHANNEL_X_%d", i);
00563 file->tag.set_property(string, vchannel_x[i]);
00564 sprintf(string, "VCHANNEL_Y_%d", i);
00565 file->tag.set_property(string, vchannel_y[i]);
00566 }
00567
00568 file->tag.set_property("FRAMERATE", frame_rate);
00569 file->tag.set_property("FRAMES_PER_FOOT", frames_per_foot);
00570 file->tag.set_property("OUTPUTW", output_w);
00571 file->tag.set_property("OUTPUTH", output_h);
00572 file->tag.set_property("ASPECTW", aspect_w);
00573 file->tag.set_property("ASPECTH", aspect_h);
00574 file->append_tag();
00575 file->tag.set_title("/VIDEO");
00576 file->append_tag();
00577 file->append_newline();
00578 file->append_newline();
00579 return 0;
00580 }
00581
00582 int EDLSession::save_audio_config(FileXML *file)
00583 {
00584 char string[1024];
00585 file->tag.set_title("AUDIO");
00586 file->tag.set_property("SAMPLERATE", (int64_t)sample_rate);
00587 file->tag.set_property("CHANNELS", (int64_t)audio_channels);
00588
00589 for(int i = 0; i < audio_channels; i++)
00590 {
00591 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00592 file->tag.set_property(string, achannel_positions[i]);
00593 }
00594
00595 file->append_tag();
00596 file->tag.set_title("/AUDIO");
00597 file->append_tag();
00598 file->append_newline();
00599 file->append_newline();
00600 return 0;
00601 }
00602
00603 int EDLSession::copy(EDLSession *session)
00604 {
00605
00606 for(int i = 0; i < MAXCHANNELS; i++)
00607 {
00608 achannel_positions[i] = session->achannel_positions[i];
00609 }
00610 aconfig_duplex->copy_from(session->aconfig_duplex);
00611 aconfig_in->copy_from(session->aconfig_in);
00612 actual_frame_rate = session->actual_frame_rate;
00613 for(int i = 0; i < ASSET_COLUMNS; i++)
00614 {
00615 asset_columns[i] = session->asset_columns[i];
00616 }
00617 assetlist_format = session->assetlist_format;
00618 auto_conf->copy_from(session->auto_conf);
00619 aspect_w = session->aspect_w;
00620 aspect_h = session->aspect_h;
00621 audio_channels = session->audio_channels;
00622 audio_tracks = session->audio_tracks;
00623 autos_follow_edits = session->autos_follow_edits;
00624 brender_start = session->brender_start;
00625 color_model = session->color_model;
00626 interlace_mode = session->interlace_mode;
00627 crop_x1 = session->crop_x1;
00628 crop_y1 = session->crop_y1;
00629 crop_x2 = session->crop_x2;
00630 crop_y2 = session->crop_y2;
00631 strcpy(current_folder, session->current_folder);
00632 cursor_on_frames = session->cursor_on_frames;
00633 cwindow_dest = session->cwindow_dest;
00634 cwindow_mask = session->cwindow_mask;
00635 cwindow_meter = session->cwindow_meter;
00636 cwindow_operation = session->cwindow_operation;
00637 cwindow_scrollbars = session->cwindow_scrollbars;
00638 cwindow_xscroll = session->cwindow_xscroll;
00639 cwindow_yscroll = session->cwindow_yscroll;
00640 cwindow_zoom = session->cwindow_zoom;
00641 strcpy(default_atransition, session->default_atransition);
00642 strcpy(default_vtransition, session->default_vtransition);
00643 default_transition_length = session->default_transition_length;
00644 edit_handle_mode[0] = session->edit_handle_mode[0];
00645 edit_handle_mode[1] = session->edit_handle_mode[1];
00646 edit_handle_mode[2] = session->edit_handle_mode[2];
00647 editing_mode = session->editing_mode;
00648 enable_duplex = session->enable_duplex;
00649 folderlist_format = session->folderlist_format;
00650 frame_rate = session->frame_rate;
00651 frames_per_foot = session->frames_per_foot;
00652 highlighted_track = session->highlighted_track;
00653 interpolation_type = session->interpolation_type;
00654 labels_follow_edits = session->labels_follow_edits;
00655 plugins_follow_edits = session->plugins_follow_edits;
00656 auto_keyframes = session->auto_keyframes;
00657
00658 meter_format = session->meter_format;
00659 min_meter_db = session->min_meter_db;
00660 max_meter_db = session->max_meter_db;
00661 mpeg4_deblock = session->mpeg4_deblock;
00662 output_w = session->output_w;
00663 output_h = session->output_h;
00664 playback_buffer = session->playback_buffer;
00665 delete playback_config;
00666 playback_config = new PlaybackConfig;
00667 playback_config->copy_from(session->playback_config);
00668 playback_cursor_visible = session->playback_cursor_visible;
00669 playback_preload = session->playback_preload;
00670 playback_software_position = session->playback_software_position;
00671 real_time_playback = session->real_time_playback;
00672 real_time_record = session->real_time_record;
00673 record_software_position = session->record_software_position;
00674 record_speed = session->record_speed;
00675 record_sync_drives = session->record_sync_drives;
00676 record_write_length = session->record_write_length;
00677 safe_regions = session->safe_regions;
00678 sample_rate = session->sample_rate;
00679 scrub_speed = session->scrub_speed;
00680 si_useduration = session->si_useduration;
00681 si_duration = session->si_duration;
00682 show_assets = session->show_assets;
00683 show_titles = session->show_titles;
00684 test_playback_edits = session->test_playback_edits;
00685 time_format = session->time_format;
00686 for(int i = 0; i < 4; i++)
00687 {
00688 timecode_offset[i] = session->timecode_offset[i];
00689 }
00690 nudge_seconds = session->nudge_seconds;
00691 tool_window = session->tool_window;
00692 for(int i = 0; i < MAXCHANNELS; i++)
00693 {
00694 vchannel_x[i] = session->vchannel_x[i];
00695 vchannel_y[i] = session->vchannel_y[i];
00696 }
00697 video_channels = session->video_channels;
00698 *vconfig_in = *session->vconfig_in;
00699 video_every_frame = session->video_every_frame;
00700 video_tracks = session->video_tracks;
00701 video_write_length = session->video_write_length;
00702 view_follows_playback = session->view_follows_playback;
00703 vwindow_meter = session->vwindow_meter;
00704 strcpy(vwindow_folder, session->vwindow_folder);
00705 vwindow_source = session->vwindow_source;
00706 vwindow_zoom = session->vwindow_zoom;
00707 return 0;
00708 }
00709
00710 int64_t EDLSession::get_frame_offset()
00711 {
00712 return int64_t((timecode_offset[3] * 3600 +
00713 timecode_offset[2] * 60 +
00714 timecode_offset[1]) *
00715 frame_rate +
00716 timecode_offset[0]);
00717 }
00718
00719 void EDLSession::dump()
00720 {
00721 printf("EDLSession::dump\n");
00722 printf(" audio_tracks=%d audio_channels=%d sample_rate=%lld\n"
00723 "video_tracks=%d frame_rate=%f output_w=%d output_h=%d aspect_w=%f aspect_h=%f\n",
00724 audio_tracks,
00725 audio_channels,
00726 sample_rate,
00727 video_tracks,
00728 frame_rate,
00729 output_w,
00730 output_h,
00731 aspect_w,
00732 aspect_h);
00733 }