00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "awindowgui.h"
00004 #include "awindow.h"
00005 #include "batchrender.h"
00006 #include "bcdisplayinfo.h"
00007 #include "brender.h"
00008 #include "cache.h"
00009 #include "channel.h"
00010 #include "channeldb.h"
00011 #include "clip.h"
00012 #include "colormodels.h"
00013 #include "cplayback.h"
00014 #include "ctimebar.h"
00015 #include "cwindowgui.h"
00016 #include "cwindow.h"
00017 #include "defaults.h"
00018 #include "editpanel.h"
00019 #include "edl.h"
00020 #include "edlsession.h"
00021 #include "errorbox.h"
00022 #include "fileformat.h"
00023 #include "file.h"
00024 #include "filesystem.h"
00025 #include "filexml.h"
00026 #include "gwindow.h"
00027 #include "gwindowgui.h"
00028 #include "indexfile.h"
00029 #include "interlacemodes.h"
00030 #include "language.h"
00031 #include "levelwindowgui.h"
00032 #include "levelwindow.h"
00033 #include "loadfile.inc"
00034 #include "localsession.h"
00035 #include "maincursor.h"
00036 #include "mainindexes.h"
00037 #include "mainmenu.h"
00038 #include "mainprogress.h"
00039 #include "mainsession.h"
00040 #include "mainundo.h"
00041 #include "mbuttons.h"
00042 #include "mutex.h"
00043 #include "mwindowgui.h"
00044 #include "mwindow.h"
00045 #include "new.h"
00046 #include "patchbay.h"
00047 #include "playbackengine.h"
00048 #include "plugin.h"
00049 #include "pluginserver.h"
00050 #include "pluginset.h"
00051 #include "preferences.h"
00052 #include "record.h"
00053 #include "recordlabel.h"
00054 #include "render.h"
00055 #include "samplescroll.h"
00056 #include "sighandler.h"
00057 #include "splashgui.h"
00058 #include "statusbar.h"
00059 #include "theme.h"
00060 #include "threadloader.h"
00061 #include "timebar.h"
00062 #include "tipwindow.h"
00063 #include "trackcanvas.h"
00064 #include "track.h"
00065 #include "tracking.h"
00066 #include "trackscroll.h"
00067 #include "tracks.h"
00068 #include "transition.h"
00069 #include "transportque.h"
00070 #include "vframe.h"
00071 #include "videodevice.inc"
00072 #include "videowindow.h"
00073 #include "vplayback.h"
00074 #include "vwindowgui.h"
00075 #include "vwindow.h"
00076 #include "zoombar.h"
00077
00078 #include <string.h>
00079
00080
00081
00082 extern "C"
00083 {
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 int atexit(void (*function)(void))
00111 {
00112 return 0;
00113 }
00114
00115
00116
00117 }
00118
00119
00120
00121
00122
00123 MWindow::MWindow()
00124 {
00125 plugin_gui_lock = new Mutex("MWindow::plugin_gui_lock");
00126 brender_lock = new Mutex("MWindow::brender_lock");
00127 brender = 0;
00128 session = 0;
00129 channeldb_buz = new ChannelDB;
00130 channeldb_v4l2jpeg = new ChannelDB;
00131 }
00132
00133 MWindow::~MWindow()
00134 {
00135 brender_lock->lock("MWindow::~MWindow");
00136 if(brender) delete brender;
00137 brender = 0;
00138 brender_lock->unlock();
00139 delete brender_lock;
00140
00141 delete mainindexes;
00142
00143 TRACE("MWindow::~MWindow 1\n");
00144 clean_indexes();
00145 TRACE("MWindow::~MWindow 2\n");
00146
00147 save_defaults();
00148 TRACE("MWindow::~MWindow 3\n");
00149
00150 exit(0);
00151
00152 TRACE("MWindow::~MWindow 4\n");
00153 delete mainprogress;
00154 delete audio_cache;
00155 delete video_cache;
00156 if(gui) delete gui;
00157 delete undo;
00158 delete preferences;
00159 delete defaults;
00160 delete render;
00161
00162 delete awindow;
00163 delete vwindow;
00164 delete cwindow;
00165 delete lwindow;
00166 plugin_guis->remove_all_objects();
00167 delete plugin_guis;
00168 delete plugin_gui_lock;
00169 }
00170
00171 void MWindow::init_defaults(Defaults* &defaults, char *config_path)
00172 {
00173 char path[BCTEXTLEN];
00174
00175 if(config_path[0])
00176 {
00177 strcpy(path, config_path);
00178 }
00179 else
00180 {
00181
00182 FileSystem fs;
00183
00184 sprintf(path, "%s", BCASTDIR);
00185 fs.complete_path(path);
00186 if(fs.is_dir(path))
00187 {
00188 fs.create_dir(path);
00189 }
00190
00191
00192 strcat(path, "Cinelerra_rc");
00193 }
00194
00195 defaults = new Defaults(path);
00196 defaults->load();
00197 }
00198
00199 void MWindow::init_plugin_path(Preferences *preferences,
00200 ArrayList<PluginServer*>* &plugindb,
00201 FileSystem *fs,
00202 SplashGUI *splash_window,
00203 int *counter)
00204 {
00205 int result = 0;
00206 PluginServer *newplugin;
00207
00208 if(!result)
00209 {
00210 for(int i = 0; i < fs->dir_list.total; i++)
00211 {
00212 char path[BCTEXTLEN];
00213 strcpy(path, fs->dir_list.values[i]->path);
00214
00215
00216 if(!fs->is_dir(path))
00217 {
00218 continue;
00219 }
00220 else
00221 {
00222
00223 fs->complete_path(path);
00224
00225 PluginServer *new_plugin = new PluginServer(path);
00226 int result = new_plugin->open_plugin(1, preferences, 0, 0, -1);
00227
00228 if(!result)
00229 {
00230 plugindb->append(new_plugin);
00231 new_plugin->close_plugin();
00232 if(splash_window)
00233 splash_window->operation->update(_(new_plugin->title));
00234 }
00235 else
00236 if(result == PLUGINSERVER_IS_LAD)
00237 {
00238 delete new_plugin;
00239
00240 int id = 0;
00241 do
00242 {
00243 new_plugin = new PluginServer(path);
00244 result = new_plugin->open_plugin(1,
00245 preferences,
00246 0,
00247 0,
00248 id);
00249 id++;
00250 if(!result)
00251 {
00252 plugindb->append(new_plugin);
00253 new_plugin->close_plugin();
00254 if(splash_window)
00255 splash_window->operation->update(_(new_plugin->title));
00256 }
00257 }while(!result);
00258 }
00259 else
00260 {
00261
00262 delete new_plugin;
00263 }
00264 }
00265 if(splash_window) splash_window->progress->update((*counter)++);
00266 }
00267 }
00268 }
00269
00270 void MWindow::init_plugins(Preferences *preferences,
00271 ArrayList<PluginServer*>* &plugindb,
00272 SplashGUI *splash_window)
00273 {
00274 plugindb = new ArrayList<PluginServer*>;
00275
00276
00277
00278 FileSystem cinelerra_fs;
00279 ArrayList<FileSystem*> lad_fs;
00280 int result = 0;
00281
00282
00283 cinelerra_fs.set_filter("[*.plugin][*.so]");
00284 result = cinelerra_fs.update(preferences->global_plugin_dir);
00285
00286 if(result)
00287 {
00288 fprintf(stderr,
00289 _("MWindow::init_plugins: couldn't open %s directory\n"),
00290 preferences->global_plugin_dir);
00291 }
00292
00293
00294 char *env = getenv("LADSPA_PATH");
00295 if(env)
00296 {
00297 char string[BCTEXTLEN];
00298 char *ptr1 = env;
00299 while(ptr1)
00300 {
00301 char *ptr = strchr(ptr1, ':');
00302 char *end;
00303 if(ptr)
00304 {
00305 end = ptr;
00306 }
00307 else
00308 {
00309 end = env + strlen(env);
00310 }
00311
00312 if(end > ptr1)
00313 {
00314 int len = end - ptr1;
00315 memcpy(string, ptr1, len);
00316 string[len] = 0;
00317
00318
00319 FileSystem *fs = new FileSystem;
00320 lad_fs.append(fs);
00321 fs->set_filter("*.so");
00322 result = fs->update(string);
00323
00324 if(result)
00325 {
00326 fprintf(stderr,
00327 _("MWindow::init_plugins: couldn't open %s directory\n"),
00328 string);
00329 }
00330 }
00331
00332 if(ptr)
00333 ptr1 = ptr + 1;
00334 else
00335 ptr1 = ptr;
00336 };
00337 }
00338
00339 int total = cinelerra_fs.total_files();
00340 int counter = 0;
00341 for(int i = 0; i < lad_fs.total; i++)
00342 total += lad_fs.values[i]->total_files();
00343 if(splash_window) splash_window->progress->update_length(total);
00344
00345
00346 #ifndef DO_STATIC
00347 init_plugin_path(preferences,
00348 plugindb,
00349 &cinelerra_fs,
00350 splash_window,
00351 &counter);
00352 #else
00353
00354 #endif
00355
00356
00357 for(int i = 0; i < lad_fs.total; i++)
00358 init_plugin_path(preferences,
00359 plugindb,
00360 lad_fs.values[i],
00361 splash_window,
00362 &counter);
00363
00364 lad_fs.remove_all_objects();
00365 }
00366
00367 void MWindow::delete_plugins()
00368 {
00369 for(int i = 0; i < plugindb->total; i++)
00370 {
00371 delete plugindb->values[i];
00372 }
00373 delete plugindb;
00374 }
00375
00376 void MWindow::create_plugindb(int do_audio,
00377 int do_video,
00378 int is_realtime,
00379 int is_transition,
00380 int is_theme,
00381 ArrayList<PluginServer*> &plugindb)
00382 {
00383
00384 for(int i = 0; i < this->plugindb->total; i++)
00385 {
00386 PluginServer *current = this->plugindb->values[i];
00387
00388 if(current->audio == do_audio &&
00389 current->video == do_video &&
00390 (current->realtime == is_realtime || is_realtime < 0) &&
00391 current->transition == is_transition &&
00392 current->theme == is_theme)
00393 plugindb.append(current);
00394 }
00395
00396
00397 int done = 0;
00398 while(!done)
00399 {
00400 done = 1;
00401
00402 for(int i = 0; i < plugindb.total - 1; i++)
00403 {
00404 PluginServer *value1 = plugindb.values[i];
00405 PluginServer *value2 = plugindb.values[i + 1];
00406 if(strcmp(_(value1->title), _(value2->title)) > 0)
00407 {
00408 done = 0;
00409 plugindb.values[i] = value2;
00410 plugindb.values[i + 1] = value1;
00411 }
00412 }
00413 }
00414 }
00415
00416 PluginServer* MWindow::scan_plugindb(char *title,
00417 int data_type)
00418 {
00419 if(data_type < 0)
00420 {
00421 printf("MWindow::scan_plugindb data_type < 0\n");
00422 return 0;
00423 }
00424
00425 for(int i = 0; i < plugindb->total; i++)
00426 {
00427 PluginServer *server = plugindb->values[i];
00428 if(!strcasecmp(server->title, title) &&
00429 ((data_type == TRACK_AUDIO && server->audio) ||
00430 (data_type == TRACK_VIDEO && server->video)))
00431 return plugindb->values[i];
00432 }
00433 return 0;
00434 }
00435
00436 void MWindow::init_preferences()
00437 {
00438 preferences = new Preferences;
00439 preferences->load_defaults(defaults);
00440 session = new MainSession(this);
00441 session->load_defaults(defaults);
00442 }
00443
00444 void MWindow::clean_indexes()
00445 {
00446 FileSystem fs;
00447 int total_excess;
00448 long oldest;
00449 int oldest_item = -1;
00450 int result;
00451 char string[BCTEXTLEN];
00452 char string2[BCTEXTLEN];
00453
00454
00455 fs.set_filter("*.idx");
00456 fs.complete_path(preferences->index_directory);
00457 fs.update(preferences->index_directory);
00458
00459
00460
00461 result = 1;
00462 while(result)
00463 {
00464 result = 0;
00465 for(int i = 0; i < fs.dir_list.total && !result; i++)
00466 {
00467 fs.join_names(string, preferences->index_directory, fs.dir_list.values[i]->name);
00468 if(!fs.is_dir(string))
00469 {
00470 delete fs.dir_list.values[i];
00471 fs.dir_list.remove_number(i);
00472 result = 1;
00473 }
00474 }
00475 }
00476 total_excess = fs.dir_list.total - preferences->index_count;
00477
00478
00479 while(total_excess > 0)
00480 {
00481
00482 for(int i = 0; i < fs.dir_list.total; i++)
00483 {
00484 fs.join_names(string, preferences->index_directory, fs.dir_list.values[i]->name);
00485
00486 if(i == 0 || fs.get_date(string) <= oldest)
00487 {
00488 oldest = fs.get_date(string);
00489 oldest_item = i;
00490 }
00491 }
00492
00493 if(oldest_item >= 0)
00494 {
00495
00496 fs.join_names(string,
00497 preferences->index_directory,
00498 fs.dir_list.values[oldest_item]->name);
00499
00500 if(remove(string))
00501 perror("delete_indexes");
00502 delete fs.dir_list.values[oldest_item];
00503 fs.dir_list.remove_number(oldest_item);
00504
00505
00506 strcpy(string2, string);
00507 char *ptr = strrchr(string2, '.');
00508 if(ptr)
00509 {
00510
00511 sprintf(ptr, ".toc");
00512 remove(string2);
00513 }
00514 }
00515
00516 total_excess--;
00517 }
00518 }
00519
00520 void MWindow::init_awindow()
00521 {
00522 awindow = new AWindow(this);
00523 awindow->create_objects();
00524 }
00525
00526 void MWindow::init_gwindow()
00527 {
00528 gwindow = new GWindow(this);
00529 gwindow->create_objects();
00530 }
00531
00532 void MWindow::init_tipwindow()
00533 {
00534 twindow = new TipWindow(this);
00535 twindow->start();
00536 }
00537
00538 void MWindow::init_theme()
00539 {
00540 theme = 0;
00541
00542
00543 if(!strcasecmp(preferences->theme, "Blond"))
00544 strcpy(preferences->theme, DEFAULT_THEME);
00545
00546 for(int i = 0; i < plugindb->total; i++)
00547 {
00548 if(plugindb->values[i]->theme &&
00549 !strcasecmp(preferences->theme, plugindb->values[i]->title))
00550 {
00551 PluginServer plugin = *plugindb->values[i];
00552 plugin.open_plugin(0, preferences, 0, 0, -1);
00553 theme = plugin.new_theme();
00554 theme->mwindow = this;
00555 strcpy(theme->path, plugin.path);
00556 plugin.close_plugin();
00557 }
00558 }
00559
00560 if(!theme)
00561 {
00562 fprintf(stderr, _("MWindow::init_theme: theme %s not found.\n"), preferences->theme);
00563 exit(1);
00564 }
00565
00566
00567 theme->Theme::initialize();
00568
00569 theme->initialize();
00570
00571 theme->build_menus();
00572 init_menus();
00573
00574 theme->check_used();
00575 }
00576
00577 void MWindow::init_edl()
00578 {
00579 edl = new EDL;
00580 edl->create_objects();
00581 edl->load_defaults(defaults);
00582 edl->create_default_tracks();
00583 edl->tracks->update_y_pixels(theme);
00584 }
00585
00586 void MWindow::init_compositor()
00587 {
00588 cwindow = new CWindow(this);
00589 cwindow->create_objects();
00590 }
00591
00592 void MWindow::init_levelwindow()
00593 {
00594 lwindow = new LevelWindow(this);
00595 lwindow->create_objects();
00596 }
00597
00598 void MWindow::init_viewer()
00599 {
00600 vwindow = new VWindow(this);
00601 vwindow->load_defaults();
00602 vwindow->create_objects();
00603 }
00604
00605 void MWindow::init_cache()
00606 {
00607 audio_cache = new CICache(edl, preferences, plugindb);
00608 video_cache = new CICache(edl, preferences, plugindb);
00609 }
00610
00611 void MWindow::init_channeldb()
00612 {
00613 channeldb_buz->load("channeldb_buz");
00614 channeldb_v4l2jpeg->load("channeldb_v4l2jpeg");
00615 }
00616
00617 void MWindow::init_menus()
00618 {
00619 char string[BCTEXTLEN];
00620
00621
00622 cmodel_to_text(string, BC_RGB888);
00623 colormodels.append(new ColormodelItem(string, BC_RGB888));
00624 cmodel_to_text(string, BC_RGBA8888);
00625 colormodels.append(new ColormodelItem(string, BC_RGBA8888));
00626
00627
00628
00629
00630 cmodel_to_text(string, BC_RGB_FLOAT);
00631 colormodels.append(new ColormodelItem(string, BC_RGB_FLOAT));
00632 cmodel_to_text(string, BC_RGBA_FLOAT);
00633 colormodels.append(new ColormodelItem(string, BC_RGBA_FLOAT));
00634 cmodel_to_text(string, BC_YUV888);
00635 colormodels.append(new ColormodelItem(string, BC_YUV888));
00636 cmodel_to_text(string, BC_YUVA8888);
00637 colormodels.append(new ColormodelItem(string, BC_YUVA8888));
00638
00639
00640
00641
00642
00643 #define ILACEPROJECTMODELISTADD(x) ilacemode_to_text(string, x); \
00644 interlace_project_modes.append(new InterlacemodeItem(string, x));
00645
00646 #define ILACEASSETMODELISTADD(x) ilacemode_to_text(string, x); \
00647 interlace_asset_modes.append(new InterlacemodeItem(string, x));
00648
00649 #define ILACEFIXMETHODLISTADD(x) ilacefixmethod_to_text(string, x); \
00650 interlace_asset_fixmethods.append(new InterlacefixmethodItem(string, x));
00651
00652
00653 ILACEASSETMODELISTADD(BC_ILACE_MODE_UNDETECTED);
00654
00655 ILACEASSETMODELISTADD(BC_ILACE_MODE_TOP_FIRST);
00656 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_TOP_FIRST);
00657
00658 ILACEASSETMODELISTADD(BC_ILACE_MODE_BOTTOM_FIRST);
00659 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_BOTTOM_FIRST);
00660
00661 ILACEASSETMODELISTADD(BC_ILACE_MODE_NOTINTERLACED);
00662 ILACEPROJECTMODELISTADD(BC_ILACE_MODE_NOTINTERLACED);
00663
00664
00665 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_NONE);
00666 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_UPONE);
00667 ILACEFIXMETHODLISTADD(BC_ILACE_FIXMETHOD_DOWNONE);
00668 }
00669
00670 void MWindow::init_indexes()
00671 {
00672 mainindexes = new MainIndexes(this);
00673 mainindexes->start_loop();
00674 }
00675
00676 void MWindow::init_gui()
00677 {
00678 gui = new MWindowGUI(this);
00679 gui->create_objects();
00680 gui->load_defaults(defaults);
00681 }
00682
00683 void MWindow::init_signals()
00684 {
00685 sighandler = new SigHandler;
00686 sighandler->initialize();
00687 ENABLE_BUFFER
00688 }
00689
00690 void MWindow::init_render()
00691 {
00692 render = new Render(this);
00693
00694 batch_render = new BatchRenderThread(this);
00695 }
00696
00697 void MWindow::init_brender()
00698 {
00699 if(preferences->use_brender && !brender)
00700 {
00701 brender_lock->lock("MWindow::init_brender 1");
00702 brender = new BRender(this);
00703 brender->initialize();
00704 session->brender_end = 0;
00705 brender_lock->unlock();
00706 }
00707 else
00708 if(!preferences->use_brender && brender)
00709 {
00710 brender_lock->lock("MWindow::init_brender 2");
00711 delete brender;
00712 brender = 0;
00713 session->brender_end = 0;
00714 brender_lock->unlock();
00715 }
00716 if(brender) brender->restart(edl);
00717 }
00718
00719 void MWindow::restart_brender()
00720 {
00721
00722 if(brender) brender->restart(edl);
00723 }
00724
00725 void MWindow::stop_brender()
00726 {
00727 if(brender) brender->stop();
00728 }
00729
00730 int MWindow::brender_available(int position)
00731 {
00732 int result = 0;
00733 brender_lock->lock("MWindow::brender_available 1");
00734 if(brender)
00735 {
00736 if(brender->map_valid)
00737 {
00738 brender->map_lock->lock("MWindow::brender_available 2");
00739 if(position < brender->map_size &&
00740 position >= 0)
00741 {
00742
00743 if(brender->map[position] == BRender::RENDERED)
00744 result = 1;
00745 }
00746 brender->map_lock->unlock();
00747 }
00748 }
00749 brender_lock->unlock();
00750 return result;
00751 }
00752
00753 void MWindow::set_brender_start()
00754 {
00755 edl->session->brender_start = edl->local_session->get_selectionstart();
00756 restart_brender();
00757 gui->canvas->draw_overlays();
00758 gui->canvas->flash();
00759 }
00760
00761
00762
00763 int MWindow::load_filenames(ArrayList<char*> *filenames,
00764 int load_mode,
00765 int update_filename,
00766 char *reel_name,
00767 int reel_number,
00768 int overwrite_reel)
00769 {
00770 TRACE("MWindow::load_filenames 1");
00771 ArrayList<EDL*> new_edls;
00772 ArrayList<Asset*> new_assets;
00773 ArrayList<File*> new_files;
00774
00775 save_defaults();
00776 gui->start_hourglass();
00777
00778
00779
00780 cwindow->playback_engine->que->send_command(STOP,
00781 CHANGE_NONE,
00782 0,
00783 0);
00784 vwindow->playback_engine->que->send_command(STOP,
00785 CHANGE_NONE,
00786 0,
00787 0);
00788 cwindow->playback_engine->interrupt_playback(0);
00789 vwindow->playback_engine->interrupt_playback(0);
00790
00791
00792 TRACE("MWindow::load_filenames 80");
00793
00794
00795 int result = 0;
00796 for(int i = 0; i < filenames->total; i++)
00797 {
00798
00799 File *new_file = new File;
00800 Asset *new_asset = new Asset(filenames->values[i]);
00801 EDL *new_edl = new EDL;
00802 char string[BCTEXTLEN];
00803
00804
00805
00806
00807
00808 if(overwrite_reel)
00809 {
00810 char source_filename[BCTEXTLEN];
00811 char index_filename[BCTEXTLEN];
00812
00813 strcpy(new_asset->reel_name, reel_name);
00814 new_asset->reel_number = reel_number;
00815
00816 IndexFile::get_index_filename(source_filename,
00817 preferences->index_directory,
00818 index_filename,
00819 new_asset->path);
00820 remove(index_filename);
00821 new_asset->index_status = INDEX_NOTTESTED;
00822 }
00823
00824 new_edl->create_objects();
00825 new_edl->copy_session(edl);
00826
00827 sprintf(string, "Loading %s", new_asset->path);
00828 gui->show_message(string);
00829 TRACE("MWindow::load_filenames 81");
00830 result = new_file->open_file(preferences, new_asset, 1, 0, 0, 0);
00831 TRACE("MWindow::load_filenames 82");
00832
00833 switch(result)
00834 {
00835
00836 case FILE_OK:
00837 if(load_mode != LOAD_RESOURCESONLY)
00838 {
00839 TRACE("MWindow::load_filenames 83");
00840 asset_to_edl(new_edl, new_asset);
00841 TRACE("MWindow::load_filenames 84");
00842 new_edls.append(new_edl);
00843 TRACE("MWindow::load_filenames 85");
00844 delete new_asset;
00845 new_asset = 0;
00846 TRACE("MWindow::load_filenames 86");
00847 }
00848 else
00849 {
00850 new_assets.append(new_asset);
00851 }
00852
00853
00854 if(load_mode == LOAD_REPLACE ||
00855 load_mode == LOAD_REPLACE_CONCATENATE)
00856 {
00857 set_filename("");
00858
00859 new_edl->local_session->view_start = 0;
00860 new_edl->local_session->track_start = 0;
00861 }
00862
00863 result = 0;
00864 break;
00865
00866
00867 case FILE_NOT_FOUND:
00868 sprintf(string, _("Failed to open %s"), new_asset->path);
00869 gui->show_message(string, theme->message_error);
00870 result = 1;
00871 break;
00872
00873
00874 case FILE_UNRECOGNIZED_CODEC:
00875 {
00876
00877 IndexFile indexfile(this);
00878 result = indexfile.open_index(this, new_asset);
00879 if(!result)
00880 {
00881 indexfile.close_index();
00882 }
00883
00884
00885 if(result)
00886 {
00887 for(int j = 0; j < new_edls.total + 1; j++)
00888 {
00889 Asset *old_asset;
00890 if(j == new_edls.total)
00891 {
00892 if(old_asset = edl->assets->get_asset(new_asset->path))
00893 {
00894 *new_asset = *old_asset;
00895 result = 0;
00896 }
00897 }
00898 else
00899 {
00900 if(old_asset = new_edls.values[j]->assets->get_asset(new_asset->path))
00901 {
00902 *new_asset = *old_asset;
00903 result = 0;
00904 }
00905 }
00906 }
00907 }
00908
00909
00910 if(result)
00911 {
00912 char string[BCTEXTLEN];
00913 FileSystem fs;
00914 fs.extract_name(string, new_asset->path);
00915
00916 strcat(string, _("'s format couldn't be determined."));
00917 new_asset->audio_data = 1;
00918 new_asset->format = FILE_PCM;
00919 new_asset->channels = defaults->get("AUDIO_CHANNELS", 2);
00920 new_asset->sample_rate = defaults->get("SAMPLE_RATE", 44100);
00921 new_asset->bits = defaults->get("AUDIO_BITS", 16);
00922 new_asset->byte_order = defaults->get("BYTE_ORDER", 1);
00923 new_asset->signed_ = defaults->get("SIGNED_", 1);
00924 new_asset->header = defaults->get("HEADER", 0);
00925
00926 FileFormat fwindow(this);
00927 fwindow.create_objects(new_asset, string);
00928 result = fwindow.run_window();
00929
00930 defaults->update("AUDIO_CHANNELS", new_asset->channels);
00931 defaults->update("SAMPLE_RATE", new_asset->sample_rate);
00932 defaults->update("AUDIO_BITS", new_asset->bits);
00933 defaults->update("BYTE_ORDER", new_asset->byte_order);
00934 defaults->update("SIGNED_", new_asset->signed_);
00935 defaults->update("HEADER", new_asset->header);
00936 save_defaults();
00937 }
00938
00939
00940 if(!result)
00941 {
00942
00943 delete new_file;
00944 new_file = new File;
00945 result = new_file->open_file(preferences, new_asset, 1, 0, 0, 0);
00946
00947 if(load_mode != LOAD_RESOURCESONLY)
00948 {
00949 asset_to_edl(new_edl, new_asset);
00950 new_edls.append(new_edl);
00951 delete new_asset;
00952 new_asset = 0;
00953 }
00954 else
00955 {
00956 new_assets.append(new_asset);
00957 }
00958 }
00959 else
00960 {
00961 result = 1;
00962 }
00963 break;
00964 }
00965
00966 case FILE_IS_XML:
00967 {
00968 FileXML xml_file;
00969 xml_file.read_from_file(filenames->values[i]);
00970
00971 new_edl->load_xml(plugindb, &xml_file, LOAD_ALL);
00972 test_plugins(new_edl, filenames->values[i]);
00973
00974
00975 strcpy(new_asset->reel_name, "");
00976 reel_number = -1;
00977
00978 if(load_mode == LOAD_REPLACE ||
00979 load_mode == LOAD_REPLACE_CONCATENATE)
00980 {
00981 strcpy(session->filename, filenames->values[i]);
00982 strcpy(new_edl->local_session->clip_title, filenames->values[i]);
00983 if(update_filename)
00984 set_filename(new_edl->local_session->clip_title);
00985 }
00986
00987 new_edls.append(new_edl);
00988 result = 0;
00989 break;
00990 }
00991 }
00992
00993 TRACE("MWindow::load_filenames 87");
00994 if(result)
00995 {
00996 delete new_edl;
00997 delete new_asset;
00998 new_edl = 0;
00999 new_asset = 0;
01000 }
01001 TRACE("MWindow::load_filenames 88");
01002
01003
01004 new_files.append(new_file);
01005 TRACE("MWindow::load_filenames 89");
01006 }
01007
01008
01009
01010 if(!result) gui->statusbar->default_message();
01011
01012
01013
01014 TRACE("MWindow::load_filenames 90");
01015
01016
01017
01018
01019
01020
01021
01022 if(new_edls.total)
01023 {
01024 SET_TRACE
01025
01026 if(load_mode == LOAD_PASTE)
01027 {
01028 SET_TRACE
01029 double start = edl->local_session->get_selectionstart();
01030 SET_TRACE
01031 double end = edl->local_session->get_selectionend();
01032 SET_TRACE
01033 if(!EQUIV(start, end))
01034 edl->clear(start,
01035 end,
01036 edl->session->labels_follow_edits,
01037 edl->session->plugins_follow_edits);
01038 SET_TRACE
01039 }
01040
01041 SET_TRACE
01042 paste_edls(&new_edls,
01043 load_mode,
01044 0,
01045 -1,
01046 edl->session->labels_follow_edits,
01047 edl->session->plugins_follow_edits);
01048 SET_TRACE
01049 }
01050
01051
01052
01053
01054
01055
01056 TRACE("MWindow::load_filenames 91");
01057
01058 if(new_assets.total)
01059 {
01060 for(int i = 0; i < new_assets.total; i++)
01061 {
01062 Asset *new_asset = new_assets.values[i];
01063 File *new_file = 0;
01064 File *index_file = 0;
01065 int got_it = 0;
01066 for(int j = 0; j < new_files.total; j++)
01067 {
01068 new_file = new_files.values[j];
01069 if(!strcmp(new_file->asset->path,
01070 new_asset->path))
01071 {
01072 got_it = 1;
01073 break;
01074 }
01075 }
01076
01077 mainindexes->add_next_asset(got_it ? new_file : 0,
01078 new_assets.values[i]);
01079 edl->assets->update(new_assets.values[i]);
01080 }
01081
01082
01083
01084 mainindexes->start_build();
01085 }
01086
01087 TRACE("MWindow::load_filenames 100");
01088 update_project(load_mode);
01089 TRACE("MWindow::load_filenames 110");
01090
01091
01092
01093
01094 new_edls.remove_all_objects();
01095 TRACE("MWindow::load_filenames 120\n");
01096 new_assets.remove_all_objects();
01097 TRACE("MWindow::load_filenames 130\n");
01098 new_files.remove_all_objects();
01099 TRACE("MWindow::load_filenames 140\n");
01100
01101 undo->update_undo(_("load"), LOAD_ALL, 0);
01102
01103
01104 gui->stop_hourglass();
01105 UNTRACE
01106
01107 return 0;
01108 }
01109
01110
01111
01112
01113 void MWindow::test_plugins(EDL *new_edl, char *path)
01114 {
01115
01116 for(Track *track = new_edl->tracks->first; track; track = track->next)
01117 {
01118 for(int k = 0; k < track->plugin_set.total; k++)
01119 {
01120 PluginSet *plugin_set = track->plugin_set.values[k];
01121 for(Plugin *plugin = (Plugin*)plugin_set->first;
01122 plugin;
01123 plugin = (Plugin*)plugin->next)
01124 {
01125 if(plugin->plugin_type == PLUGIN_STANDALONE)
01126 {
01127
01128 int plugin_found = 0;
01129 for(int j = 0; j < plugindb->total; j++)
01130 {
01131 PluginServer *server = plugindb->values[j];
01132 if(!strcasecmp(server->title, plugin->title) &&
01133 ((track->data_type == TRACK_AUDIO && server->audio) ||
01134 (track->data_type == TRACK_VIDEO && server->video)) &&
01135 (!server->transition))
01136 plugin_found = 1;
01137 }
01138 if (!plugin_found)
01139 {
01140 printf("\nWARNING: The plugin '%s' named in file '%s' is not part of your installation of Cinelerra. This means project will not be rendered as it was meant and it might result in Cinelerra crashing.\n", plugin->title, path);
01141 }
01142 }
01143 }
01144 }
01145 for(Edit *edit = (Edit*)track->edits->first;
01146 edit;
01147 edit = (Edit*)edit->next)
01148 {
01149 if (edit->transition)
01150 {
01151
01152 int transition_found = 0;
01153 for(int j = 0; j < plugindb->total; j++)
01154 {
01155 PluginServer *server = plugindb->values[j];
01156 if(!strcasecmp(server->title, edit->transition->title) &&
01157 ((track->data_type == TRACK_AUDIO && server->audio) ||
01158 (track->data_type == TRACK_VIDEO && server->video)) &&
01159 (server->transition))
01160 transition_found = 1;
01161 }
01162 if (!transition_found)
01163 {
01164 printf("\nWARNING: The transition '%s' named in file '%s' is not part of your installation of Cinelerra. This means project will not be rendered as it was meant and it might result in Cinelerra crashing.\n", edit->transition->title, path);
01165 }
01166 }
01167 }
01168 }
01169 }
01170
01171
01172
01173
01174
01175
01176 void MWindow::create_objects(int want_gui,
01177 int want_new,
01178 char *config_path)
01179 {
01180 char string[BCTEXTLEN];
01181 FileSystem fs;
01182 edl = 0;
01183
01184
01185 show_splash();
01186
01187
01188
01189 init_signals();
01190
01191
01192 TRACE("MWindow::create_objects 1");
01193 init_defaults(defaults, config_path);
01194 TRACE("MWindow::create_objects 2");
01195 init_preferences();
01196 TRACE("MWindow::create_objects 3");
01197 init_plugins(preferences, plugindb, splash_window);
01198 if(splash_window) splash_window->operation->update(_("Initializing GUI"));
01199 TRACE("MWindow::create_objects 4");
01200 init_theme();
01201
01202 TRACE("MWindow::create_objects 5");
01203 init_edl();
01204
01205 TRACE("MWindow::create_objects 6");
01206 init_awindow();
01207 TRACE("MWindow::create_objects 7");
01208 init_compositor();
01209 TRACE("MWindow::create_objects 8");
01210 init_levelwindow();
01211 TRACE("MWindow::create_objects 9");
01212 init_viewer();
01213 TRACE("MWindow::create_objects 10");
01214 init_cache();
01215 TRACE("MWindow::create_objects 11");
01216 init_indexes();
01217 TRACE("MWindow::create_objects 12");
01218 init_channeldb();
01219 TRACE("MWindow::create_objects 13");
01220
01221 init_gui();
01222 init_gwindow();
01223 TRACE("MWindow::create_objects 14");
01224 init_render();
01225 init_brender();
01226 mainprogress = new MainProgress(this, gui);
01227 undo = new MainUndo(this);
01228
01229 plugin_guis = new ArrayList<PluginServer*>;
01230
01231 TRACE("MWindow::create_objects 15");
01232 if(session->show_vwindow) vwindow->gui->show_window();
01233 if(session->show_cwindow) cwindow->gui->show_window();
01234 if(session->show_awindow) awindow->gui->show_window();
01235 if(session->show_lwindow) lwindow->gui->show_window();
01236 if(session->show_gwindow) gwindow->gui->show_window();
01237 TRACE("MWindow::create_objects 16");
01238
01239
01240 gui->mainmenu->load_defaults(defaults);
01241 TRACE("MWindow::create_objects 17");
01242 gui->mainmenu->update_toggles(0);
01243 TRACE("MWindow::create_objects 18");
01244 gui->patchbay->update();
01245 TRACE("MWindow::create_objects 19");
01246 gui->canvas->draw();
01247 TRACE("MWindow::create_objects 20");
01248 gui->cursor->draw();
01249 TRACE("MWindow::create_objects 21");
01250 gui->show_window();
01251 gui->raise_window();
01252
01253 if(preferences->use_tipwindow)
01254 init_tipwindow();
01255
01256 TRACE("MWindow::create_objects 22");
01257 TRACE("MWindow::create_objects 23");
01258
01259 hide_splash();
01260 UNTRACE
01261 }
01262
01263
01264 void MWindow::show_splash()
01265 {
01266 #include "data/heroine_logo12_png.h"
01267 VFrame *frame = new VFrame(heroine_logo12_png);
01268 BC_DisplayInfo display_info;
01269 splash_window = new SplashGUI(frame,
01270 display_info.get_root_w() / 2 - frame->get_w() / 2,
01271 display_info.get_root_h() / 2 - frame->get_h() / 2);
01272 splash_window->create_objects();
01273 }
01274
01275 void MWindow::hide_splash()
01276 {
01277 if(splash_window)
01278 delete splash_window;
01279 splash_window = 0;
01280 }
01281
01282
01283 void MWindow::start()
01284 {
01285 vwindow->start();
01286 awindow->start();
01287 cwindow->start();
01288 lwindow->start();
01289 gwindow->start();
01290 gui->run_window();
01291 }
01292
01293 void MWindow::show_vwindow()
01294 {
01295 session->show_vwindow = 1;
01296 vwindow->gui->lock_window("MWindow::show_vwindow");
01297 vwindow->gui->show_window();
01298 vwindow->gui->raise_window();
01299 vwindow->gui->flush();
01300 vwindow->gui->unlock_window();
01301 gui->mainmenu->show_vwindow->set_checked(1);
01302 }
01303
01304 void MWindow::show_awindow()
01305 {
01306 session->show_awindow = 1;
01307 awindow->gui->lock_window("MWindow::show_awindow");
01308 awindow->gui->show_window();
01309 awindow->gui->raise_window();
01310 awindow->gui->flush();
01311 awindow->gui->unlock_window();
01312 gui->mainmenu->show_awindow->set_checked(1);
01313 }
01314
01315 void MWindow::show_cwindow()
01316 {
01317 session->show_cwindow = 1;
01318 cwindow->show_window();
01319 gui->mainmenu->show_cwindow->set_checked(1);
01320 }
01321
01322 void MWindow::show_gwindow()
01323 {
01324 session->show_gwindow = 1;
01325
01326 SET_TRACE
01327 gwindow->gui->lock_window("MWindow::show_gwindow");
01328 SET_TRACE
01329 gwindow->gui->show_window();
01330 SET_TRACE
01331 gwindow->gui->raise_window();
01332 SET_TRACE
01333 gwindow->gui->flush();
01334 SET_TRACE
01335 gwindow->gui->unlock_window();
01336 SET_TRACE
01337
01338 gui->mainmenu->show_gwindow->set_checked(1);
01339 SET_TRACE
01340 }
01341
01342 void MWindow::show_lwindow()
01343 {
01344 session->show_lwindow = 1;
01345 lwindow->gui->lock_window("MWindow::show_lwindow");
01346 lwindow->gui->show_window();
01347 lwindow->gui->raise_window();
01348 lwindow->gui->flush();
01349 lwindow->gui->unlock_window();
01350 gui->mainmenu->show_lwindow->set_checked(1);
01351 }
01352
01353 void MWindow::tile_windows()
01354 {
01355 session->default_window_positions();
01356 gui->default_positions();
01357 }
01358
01359 void MWindow::toggle_loop_playback()
01360 {
01361 edl->local_session->loop_playback = !edl->local_session->loop_playback;
01362 set_loop_boundaries();
01363 save_backup();
01364
01365 gui->canvas->draw_overlays();
01366 gui->canvas->flash();
01367 sync_parameters(CHANGE_PARAMS);
01368 }
01369
01370 void MWindow::set_titles(int value)
01371 {
01372 edl->session->show_titles = value;
01373 trackmovement(edl->local_session->track_start);
01374 }
01375
01376 void MWindow::set_auto_keyframes(int value)
01377 {
01378 gui->lock_window("MWindow::set_auto_keyframes");
01379 edl->session->auto_keyframes = value;
01380 gui->mbuttons->edit_panel->keyframe->update(value);
01381 gui->flush();
01382 gui->unlock_window();
01383 cwindow->gui->lock_window("MWindow::set_auto_keyframes");
01384 cwindow->gui->edit_panel->keyframe->update(value);
01385 cwindow->gui->flush();
01386 cwindow->gui->unlock_window();
01387 }
01388
01389 int MWindow::set_editing_mode(int new_editing_mode)
01390 {
01391 gui->lock_window("MWindow::set_editing_mode");
01392 edl->session->editing_mode = new_editing_mode;
01393 gui->mbuttons->edit_panel->editing_mode = edl->session->editing_mode;
01394 gui->mbuttons->edit_panel->update();
01395 gui->canvas->update_cursor();
01396 gui->unlock_window();
01397 cwindow->gui->lock_window("MWindow::set_editing_mode");
01398 cwindow->gui->edit_panel->update();
01399 cwindow->gui->edit_panel->editing_mode = edl->session->editing_mode;
01400 cwindow->gui->unlock_window();
01401 return 0;
01402 }
01403
01404
01405 void MWindow::sync_parameters(int change_type)
01406 {
01407
01408
01409 if(cwindow->playback_engine->is_playing_back)
01410 {
01411 if(change_type == CHANGE_PARAMS)
01412 {
01413
01414 cwindow->playback_engine->sync_parameters(edl);
01415 }
01416 else
01417
01418 {
01419 int command = cwindow->playback_engine->command->command;
01420 cwindow->playback_engine->que->send_command(STOP,
01421 CHANGE_NONE,
01422 0,
01423 0);
01424
01425
01426
01427
01428 cwindow->playback_engine->interrupt_playback(0);
01429 cwindow->playback_engine->que->send_command(command,
01430 change_type,
01431 edl,
01432 1,
01433 0);
01434 }
01435 }
01436 else
01437 {
01438 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01439 change_type,
01440 edl,
01441 1);
01442 }
01443 }
01444
01445 void MWindow::update_caches()
01446 {
01447 audio_cache->set_edl(edl);
01448 video_cache->set_edl(edl);
01449 }
01450
01451 void MWindow::show_plugin(Plugin *plugin)
01452 {
01453 int done = 0;
01454
01455 plugin_gui_lock->lock("MWindow::show_plugin");
01456 for(int i = 0; i < plugin_guis->total; i++)
01457 {
01458
01459 if(plugin_guis->values[i]->plugin == plugin)
01460 {
01461 plugin_guis->values[i]->raise_window();
01462 done = 1;
01463 break;
01464 }
01465 }
01466
01467
01468 if(!done)
01469 {
01470 if(!plugin->track)
01471 {
01472 printf("MWindow::show_plugin track not defined.\n");
01473 }
01474 PluginServer *server = scan_plugindb(plugin->title,
01475 plugin->track->data_type);
01476
01477
01478 if(server && server->uses_gui)
01479 {
01480 PluginServer *gui = plugin_guis->append(new PluginServer(*server));
01481
01482 gui->set_mwindow(this);
01483 gui->open_plugin(0, preferences, edl, plugin, -1);
01484 gui->show_gui();
01485 plugin->show = 1;
01486 }
01487 }
01488 plugin_gui_lock->unlock();
01489
01490 }
01491
01492 void MWindow::hide_plugin(Plugin *plugin, int lock)
01493 {
01494 if(lock) plugin_gui_lock->lock("MWindow::hide_plugin");
01495 plugin->show = 0;
01496 for(int i = 0; i < plugin_guis->total; i++)
01497 {
01498 if(plugin_guis->values[i]->plugin == plugin)
01499 {
01500 PluginServer *ptr = plugin_guis->values[i];
01501 plugin_guis->remove(ptr);
01502 if(lock) plugin_gui_lock->unlock();
01503
01504 delete ptr;
01505 return;
01506 }
01507 }
01508 if(lock) plugin_gui_lock->unlock();
01509 }
01510
01511 void MWindow::hide_plugins()
01512 {
01513 plugin_gui_lock->lock("MWindow::hide_plugins");
01514 plugin_guis->remove_all_objects();
01515 plugin_gui_lock->unlock();
01516 }
01517
01518 void MWindow::update_plugin_guis()
01519 {
01520 plugin_gui_lock->lock("MWindow::update_plugin_guis");
01521
01522 for(int i = 0; i < plugin_guis->total; i++)
01523 {
01524 plugin_guis->values[i]->update_gui();
01525 }
01526 plugin_gui_lock->unlock();
01527 }
01528
01529 void MWindow::render_plugin_gui(void *data, Plugin *plugin)
01530 {
01531 plugin_gui_lock->lock("MWindow::render_plugin_gui");
01532 for(int i = 0; i < plugin_guis->total; i++)
01533 {
01534 if(plugin_guis->values[i]->plugin->identical_location(plugin))
01535 {
01536 plugin_guis->values[i]->render_gui(data);
01537 break;
01538 }
01539 }
01540 plugin_gui_lock->unlock();
01541 }
01542
01543 void MWindow::render_plugin_gui(void *data, int size, Plugin *plugin)
01544 {
01545 plugin_gui_lock->lock("MWindow::render_plugin_gui");
01546 for(int i = 0; i < plugin_guis->total; i++)
01547 {
01548 if(plugin_guis->values[i]->plugin->identical_location(plugin))
01549 {
01550 plugin_guis->values[i]->render_gui(data, size);
01551 break;
01552 }
01553 }
01554 plugin_gui_lock->unlock();
01555 }
01556
01557
01558 void MWindow::update_plugin_states()
01559 {
01560 plugin_gui_lock->lock("MWindow::update_plugin_states");
01561 for(int i = 0; i < plugin_guis->total; i++)
01562 {
01563 int result = 0;
01564
01565 Plugin *src_plugin = plugin_guis->values[i]->plugin;
01566 PluginServer *src_plugingui = plugin_guis->values[i];
01567
01568
01569 for(Track *track = edl->tracks->first;
01570 track && !result;
01571 track = track->next)
01572 {
01573 for(int j = 0;
01574 j < track->plugin_set.total && !result;
01575 j++)
01576 {
01577 PluginSet *plugin_set = track->plugin_set.values[j];
01578 for(Plugin *plugin = (Plugin*)plugin_set->first;
01579 plugin && !result;
01580 plugin = (Plugin*)plugin->next)
01581 {
01582 if(plugin == src_plugin &&
01583 !strcmp(plugin->title, src_plugingui->title)) result = 1;
01584 }
01585 }
01586 }
01587
01588
01589
01590 if(!result)
01591 {
01592 hide_plugin(src_plugin, 0);
01593 i--;
01594 }
01595 }
01596 plugin_gui_lock->unlock();
01597 }
01598
01599
01600 void MWindow::update_plugin_titles()
01601 {
01602 for(int i = 0; i < plugin_guis->total; i++)
01603 {
01604 plugin_guis->values[i]->update_title();
01605 }
01606 }
01607
01608 int MWindow::asset_to_edl(EDL *new_edl,
01609 Asset *new_asset,
01610 RecordLabels *labels)
01611 {
01612
01613
01614
01615
01616
01617
01618 if(new_asset->video_data)
01619 {
01620 new_edl->session->video_tracks = new_asset->layers;
01621
01622
01623
01624 }
01625 else
01626 new_edl->session->video_tracks = 0;
01627
01628
01629
01630
01631
01632
01633 if(new_asset->audio_data)
01634 {
01635 new_edl->session->audio_tracks = new_asset->channels;
01636
01637 }
01638 else
01639 new_edl->session->audio_tracks = 0;
01640
01641
01642 new_edl->create_default_tracks();
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660 new_edl->insert_asset(new_asset, 0, 0, labels);
01661
01662
01663
01664
01665
01666
01667 char string[BCTEXTLEN];
01668 FileSystem fs;
01669 fs.extract_name(string, new_asset->path);
01670
01671
01672 strcpy(new_edl->local_session->clip_title, string);
01673
01674
01675
01676 return 0;
01677 }
01678
01679
01680 void MWindow::update_project(int load_mode)
01681 {
01682 restart_brender();
01683
01684 edl->tracks->update_y_pixels(theme);
01685
01686
01687
01688 update_caches();
01689
01690 TRACE("MWindow::update_project 3");
01691 gui->update(1, 1, 1, 1, 1, 1, 1);
01692
01693 TRACE("MWindow::update_project 4");
01694 cwindow->update(0, 0, 1, 1, 1);
01695
01696 TRACE("MWindow::update_project 5");
01697
01698 if(load_mode == LOAD_REPLACE ||
01699 load_mode == LOAD_REPLACE_CONCATENATE)
01700 {
01701 vwindow->change_source();
01702 }
01703 else
01704 {
01705 vwindow->update(1);
01706 }
01707
01708 TRACE("MWindow::update_project 6");
01709
01710 cwindow->gui->slider->set_position();
01711 TRACE("MWindow::update_project 6.1");
01712 cwindow->gui->timebar->update(1, 1);
01713 TRACE("MWindow::update_project 6.2");
01714 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01715 CHANGE_ALL,
01716 edl,
01717 1);
01718
01719 TRACE("MWindow::update_project 7");
01720 awindow->gui->lock_window("MWindow::update_project");
01721 awindow->gui->update_assets();
01722 awindow->gui->flush();
01723 awindow->gui->unlock_window();
01724 gui->flush();
01725 TRACE("MWindow::update_project 100");
01726 }
01727
01728
01729 void MWindow::rebuild_indices()
01730 {
01731 char source_filename[BCTEXTLEN], index_filename[BCTEXTLEN];
01732
01733 for(int i = 0; i < session->drag_assets->total; i++)
01734 {
01735
01736
01737 IndexFile::get_index_filename(source_filename,
01738 preferences->index_directory,
01739 index_filename,
01740 session->drag_assets->values[i]->path);
01741 remove(index_filename);
01742
01743 session->drag_assets->values[i]->index_status = INDEX_NOTTESTED;
01744 mainindexes->add_next_asset(0, session->drag_assets->values[i]);
01745 }
01746 mainindexes->start_build();
01747 }
01748
01749
01750 void MWindow::save_backup()
01751 {
01752 FileXML file;
01753 edl->set_project_path(session->filename);
01754 edl->save_xml(plugindb,
01755 &file,
01756 BACKUP_PATH,
01757 0,
01758 0);
01759 file.terminate_string();
01760 char path[BCTEXTLEN];
01761 FileSystem fs;
01762 strcpy(path, BACKUP_PATH);
01763 fs.complete_path(path);
01764
01765 if(file.write_to_file(path))
01766 {
01767 char string2[256];
01768 sprintf(string2, _("Couldn't open %s for writing."), BACKUP_PATH);
01769 gui->show_message(string2);
01770 }
01771 }
01772
01773
01774 int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
01775 {
01776 int denominator;
01777 if(!width || !height) return 1;
01778 float fraction = (float)width / height;
01779
01780 for(denominator = 1;
01781 denominator < 100 &&
01782 fabs(fraction * denominator - (int)(fraction * denominator)) > .001;
01783 denominator++)
01784 ;
01785
01786 w = denominator * width / height;
01787 h = denominator;
01788 return 0;
01789 }
01790
01791
01792
01793 void MWindow::remove_assets_from_project(int push_undo)
01794 {
01795
01796 for(int i = 0; i < session->drag_assets->total; i++)
01797 {
01798 audio_cache->delete_entry(session->drag_assets->values[i]);
01799 video_cache->delete_entry(session->drag_assets->values[i]);
01800 }
01801
01802 printf("MWindow::remove_assets_from_project 1\n");
01803 video_cache->dump();
01804 audio_cache->dump();
01805 printf("MWindow::remove_assets_from_project 100\n");
01806
01807
01808 for(int i = 0; i < session->drag_clips->total; i++)
01809 {
01810 if(session->drag_clips->values[i] == vwindow->get_edl())
01811 {
01812 vwindow->gui->lock_window("MWindow::remove_assets_from_project 1");
01813 vwindow->remove_source();
01814 vwindow->gui->unlock_window();
01815 }
01816 }
01817
01818 for(int i = 0; i < session->drag_assets->total; i++)
01819 {
01820 if(session->drag_assets->values[i] == vwindow->get_asset())
01821 {
01822 vwindow->gui->lock_window("MWindow::remove_assets_from_project 2");
01823 vwindow->remove_source();
01824 vwindow->gui->unlock_window();
01825 }
01826 }
01827
01828 edl->remove_from_project(session->drag_assets);
01829 edl->remove_from_project(session->drag_clips);
01830 save_backup();
01831 if(push_undo) undo->update_undo(_("remove assets"), LOAD_ALL);
01832 restart_brender();
01833
01834 gui->lock_window("MWindow::remove_assets_from_project 3");
01835 gui->update(1,
01836 1,
01837 1,
01838 1,
01839 0,
01840 1,
01841 0);
01842 gui->unlock_window();
01843
01844 awindow->gui->lock_window("MWindow::remove_assets_from_project 4");
01845 awindow->gui->update_assets();
01846 awindow->gui->flush();
01847 awindow->gui->unlock_window();
01848
01849
01850 sync_parameters(CHANGE_ALL);
01851 }
01852
01853 void MWindow::remove_assets_from_disk()
01854 {
01855
01856 for(int i = 0; i < session->drag_assets->total; i++)
01857 {
01858 remove(session->drag_assets->values[i]->path);
01859 }
01860
01861 remove_assets_from_project(1);
01862 }
01863
01864 void MWindow::dump_plugins()
01865 {
01866 for(int i = 0; i < plugindb->total; i++)
01867 {
01868 printf("audio=%d video=%d realtime=%d transition=%d theme=%d %s\n",
01869 plugindb->values[i]->audio,
01870 plugindb->values[i]->video,
01871 plugindb->values[i]->realtime,
01872 plugindb->values[i]->transition,
01873 plugindb->values[i]->theme,
01874 plugindb->values[i]->title);
01875 }
01876 }
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902 int MWindow::save_defaults()
01903 {
01904 gui->save_defaults(defaults);
01905 edl->save_defaults(defaults);
01906 session->save_defaults(defaults);
01907 preferences->save_defaults(defaults);
01908
01909 defaults->save();
01910 return 0;
01911 }
01912
01913 int MWindow::run_script(FileXML *script)
01914 {
01915 int result = 0, result2 = 0;
01916 while(!result && !result2)
01917 {
01918 result = script->read_tag();
01919 if(!result)
01920 {
01921 if(script->tag.title_is("new_project"))
01922 {
01923
01924
01925 }
01926 else
01927 if(script->tag.title_is("record"))
01928 {
01929
01930 ;
01931
01932
01933 result2 = 1;
01934 }
01935 else
01936 {
01937 printf("MWindow::run_script: Unrecognized command: %s\n",script->tag.get_title() );
01938 }
01939 }
01940 }
01941 return result2;
01942 }
01943
01944
01945
01946
01947 int MWindow::interrupt_indexes()
01948 {
01949 mainindexes->interrupt_build();
01950 return 0;
01951 }
01952
01953
01954
01955 void MWindow::next_time_format()
01956 {
01957 switch(edl->session->time_format)
01958 {
01959 case TIME_HMS: edl->session->time_format = TIME_HMSF; break;
01960 case TIME_HMSF: edl->session->time_format = TIME_SAMPLES; break;
01961 case TIME_SAMPLES: edl->session->time_format = TIME_SAMPLES_HEX; break;
01962 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_FRAMES; break;
01963 case TIME_FRAMES: edl->session->time_format = TIME_FEET_FRAMES; break;
01964 case TIME_FEET_FRAMES: edl->session->time_format = TIME_SECONDS; break;
01965 case TIME_SECONDS: edl->session->time_format = TIME_HMS; break;
01966 }
01967
01968 time_format_common();
01969 }
01970
01971 void MWindow::prev_time_format()
01972 {
01973 switch(edl->session->time_format)
01974 {
01975 case TIME_HMS: edl->session->time_format = TIME_SECONDS; break;
01976 case TIME_SECONDS: edl->session->time_format = TIME_FEET_FRAMES; break;
01977 case TIME_FEET_FRAMES: edl->session->time_format = TIME_FRAMES; break;
01978 case TIME_FRAMES: edl->session->time_format = TIME_SAMPLES_HEX; break;
01979 case TIME_SAMPLES_HEX: edl->session->time_format = TIME_SAMPLES; break;
01980 case TIME_SAMPLES: edl->session->time_format = TIME_HMSF; break;
01981 case TIME_HMSF: edl->session->time_format = TIME_HMS; break;
01982 }
01983
01984 time_format_common();
01985 }
01986
01987 void MWindow::time_format_common()
01988 {
01989 gui->lock_window("MWindow::next_time_format");
01990 gui->redraw_time_dependancies();
01991 char string[BCTEXTLEN], string2[BCTEXTLEN];
01992 sprintf(string, _("Using %s."), Units::print_time_format(edl->session->time_format, string2));
01993 gui->show_message(string);
01994 gui->flush();
01995 gui->unlock_window();
01996 }
01997
01998
01999 int MWindow::set_filename(char *filename)
02000 {
02001 strcpy(session->filename, filename);
02002 if(gui)
02003 {
02004 if(filename[0] == 0)
02005 {
02006 gui->set_title(PROGRAM_NAME);
02007 }
02008 else
02009 {
02010 FileSystem dir;
02011 char string[BCTEXTLEN], string2[BCTEXTLEN];
02012 dir.extract_name(string, filename);
02013 sprintf(string2, PROGRAM_NAME ": %s", string);
02014 gui->set_title(string2);
02015 }
02016 }
02017 return 0;
02018 }
02019
02020
02021
02022
02023
02024
02025
02026
02027 int MWindow::set_loop_boundaries()
02028 {
02029 double start = edl->local_session->get_selectionstart();
02030 double end = edl->local_session->get_selectionend();
02031
02032 if(start !=
02033 end)
02034 {
02035 ;
02036 }
02037 else
02038 if(edl->tracks->total_length())
02039 {
02040 start = 0;
02041 end = edl->tracks->total_length();
02042 }
02043 else
02044 {
02045 start = end = 0;
02046 }
02047
02048 if(edl->local_session->loop_playback && start != end)
02049 {
02050 edl->local_session->loop_start = start;
02051 edl->local_session->loop_end = end;
02052 }
02053 return 0;
02054 }
02055
02056
02057
02058
02059
02060
02061
02062 int MWindow::reset_meters()
02063 {
02064 cwindow->gui->lock_window("MWindow::reset_meters 1");
02065 cwindow->gui->meters->reset_meters();
02066 cwindow->gui->unlock_window();
02067
02068 vwindow->gui->lock_window("MWindow::reset_meters 2");
02069 vwindow->gui->meters->reset_meters();
02070 vwindow->gui->unlock_window();
02071
02072 lwindow->gui->lock_window("MWindow::reset_meters 3");
02073 lwindow->gui->panel->reset_meters();
02074 lwindow->gui->unlock_window();
02075
02076 gui->lock_window("MWindow::reset_meters 4");
02077 gui->patchbay->reset_meters();
02078 gui->unlock_window();
02079 return 0;
02080 }
02081