X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindow.C;h=bd7f556b2cf6aba1db1f59112d390a4b99b6268f;hp=3223b577f8f268821cf79c9c6bbde6efa84b72de;hb=7ffa6954689f14a41a3bae7a0fdb3f2abeaa9679;hpb=9fed7535470aa37781733db836068da3b4c17a0d diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 3223b577..bd7f556b 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -27,6 +27,7 @@ #include "awindowgui.h" #include "awindow.h" #include "batchrender.h" +#include "bccmodels.h" #include "bcdisplayinfo.h" #include "bcprogressbox.h" #include "bcsignals.h" @@ -40,9 +41,9 @@ #include "channelinfo.h" #include "clip.h" #include "clipedls.h" -#include "bccmodels.h" #include "commercials.h" #include "confirmsave.h" +#include "convert.h" #include "cplayback.h" #include "ctimebar.h" #include "cwindowgui.h" @@ -129,7 +130,9 @@ #include "vwindowgui.h" #include "vwindow.h" #include "wavecache.h" +#include "wintv.h" #include "wwindow.h" +#include "x10tv.h" #include "zoombar.h" #include "zwindow.h" #include "zwindowgui.h" @@ -179,7 +182,6 @@ extern "C" } - extern long cin_timezone; ArrayList* MWindow::plugindb = 0; @@ -225,6 +227,7 @@ MWindow::MWindow() create_bd = 0; create_dvd = 0; batch_render = 0; + convert_render = 0; render = 0; edl = 0; gui = 0; @@ -239,8 +242,10 @@ MWindow::MWindow() screens = 1; in_destructor = 0; speed_edl = 0; - proxy_beep = 0; + beeper = 0; shuttle = 0; + wintv = 0; + x10tv = 0; mixers_align = 0; } @@ -260,11 +265,20 @@ MWindow::~MWindow() #ifdef HAVE_DVB gui->channel_info->stop(); #endif - delete proxy_beep; + delete beeper; delete create_bd; create_bd = 0; delete create_dvd; create_dvd = 0; +#ifdef HAVE_SHUTTLE delete shuttle; shuttle = 0; +#endif +#ifdef HAVE_WINTV + delete wintv; wintv = 0; +#endif +#ifdef HAVE_X10TV + delete x10tv; x10tv = 0; +#endif delete batch_render; batch_render = 0; + delete convert_render; convert_render = 0; delete render; render = 0; delete mixers_align; mixers_align = 0; commit_commercial(); @@ -361,7 +375,6 @@ MWindow::~MWindow() colormodels.remove_all_objects(); interlace_project_modes.remove_all_objects(); interlace_asset_modes.remove_all_objects(); - interlace_asset_fixmethods.remove_all_objects(); sighandler->terminate(); delete sighandler; delete run_lock; @@ -664,6 +677,7 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences) int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences) { +#ifdef HAVE_LADSPA char *path = getenv("LADSPA_PATH"); char ladspa_path[BCTEXTLEN]; if( !path ) { @@ -708,6 +722,7 @@ int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences) } fclose(fp); } +#endif return 1; } @@ -731,7 +746,7 @@ void MWindow::scan_plugin_index(MWindow *mwindow, Preferences *preferences, FILE char plugin_path[BCTEXTLEN]; sprintf(plugin_path, "%s/%s", plug_dir, plug_path); FileSystem fs; - fs.set_filter( "[*.plugin][*.so]" ); + fs.set_filter( "[*.plugin][*.so][*.dll]" ); int result = fs.update(plugin_path); if( result || !fs.dir_list.total ) return; int vis_id = idx++; @@ -1310,7 +1325,7 @@ void MWindow::stop_mixers() } } -void MWindow::close_mixers(int destroy) +void MWindow::close_mixers(int result) { ArrayList closed; zwindows_lock->lock("MWindow::close_mixers"); @@ -1318,10 +1333,9 @@ void MWindow::close_mixers(int destroy) ZWindow *zwindow = zwindows[i]; if( zwindow->idx < 0 ) continue; zwindow->idx = -1; - zwindow->destroy = destroy; ZWindowGUI *zgui = zwindow->zgui; zgui->lock_window("MWindow::select_zwindow 0"); - zgui->set_done(0); + zgui->set_done(result); zgui->unlock_window(); closed.append(zwindow); } @@ -1454,7 +1468,7 @@ void MWindow::tile_mixers() int bw = lt + BC_DisplayInfo::get_right_border(); // borders int bh = top + BC_DisplayInfo::get_bottom_border(); int zx = 0, zy = 0; // window origins - int mw = 10+10, mh = 10+10; // canvas margins + int mw = xS(10+10), mh = yS(10+10); // canvas margins int rsz = 0, n = 0, dz = 0; int ow = edl->session->output_w, oh = edl->session->output_h; for( int i=0; i mx ) xx = mx; if( yy > my ) yy = my; - xx += lt + dz; yy += top + dz; + xx += lt + xS(dz); yy += top + yS(dz); zwindow->reposition(xx,yy, ww,hh); if( zwindow->running() ) { ZWindowGUI *gui = (ZWindowGUI *)zwindow->get_gui(); @@ -1531,9 +1545,6 @@ void MWindow::init_menus() #define ILACEASSETMODELISTADD(x) ilacemode_to_text(string, x); \ interlace_asset_modes.append(new InterlacemodeItem(string, x)); -#define ILACEFIXMETHODLISTADD(x) ilacefixmethod_to_text(string, x); \ - interlace_asset_fixmethods.append(new InterlacefixmethodItem(string, x)); - // Interlacing Modes ILACEASSETMODELISTADD(ILACE_MODE_UNDETECTED); // Not included in the list for the project options. @@ -1546,11 +1557,6 @@ void MWindow::init_menus() ILACEASSETMODELISTADD(ILACE_MODE_NOTINTERLACED); ILACEPROJECTMODELISTADD(ILACE_MODE_NOTINTERLACED); - // Interlacing Fixing Methods - ILACEFIXMETHODLISTADD(ILACE_FIXMETHOD_NONE); - ILACEFIXMETHODLISTADD(ILACE_FIXMETHOD_UPONE); - ILACEFIXMETHODLISTADD(ILACE_FIXMETHOD_DOWNONE); - mixers_align = new MixersAlign(this); } @@ -1587,6 +1593,7 @@ void MWindow::init_exportedl() exportedl = new ExportEDL(this); } + void MWindow::init_shuttle() { #ifdef HAVE_SHUTTLE @@ -1602,6 +1609,23 @@ void MWindow::init_shuttle() } #endif } +void MWindow::init_wintv() +{ +#ifdef HAVE_WINTV + wintv = WinTV::probe(this); + if( wintv ) + wintv->start(); +#endif +} +void MWindow::init_x10tv() +{ +#ifdef HAVE_X10TV + x10tv = X10TV::probe(this); + if( x10tv ) + x10tv->start(); +#endif +} + void MWindow::init_brender() { @@ -1833,19 +1857,98 @@ void MWindow::undo_after(const char *description, uint32_t load_flags, int chang void MWindow::beep(double freq, double secs, double gain) { - if( !proxy_beep ) proxy_beep = new ProxyBeep(this); - proxy_beep->tone(freq, secs, gain); + if( !beeper ) beeper = new Beeper(this); + beeper->tone(freq, secs, gain); +} + +Beeper::Beeper(MWindow *mwindow) + : Thread(1, 0, 0) +{ + this->mwindow = mwindow; + audio = new AudioDevice(mwindow); + playing_audio = 0; + interrupted = -1; +} + +Beeper::~Beeper() +{ + stop(0); + delete audio; +} + +void Beeper::run() +{ + int channels = 2; + int64_t bfrsz = BEEP_SAMPLE_RATE; + EDL *edl = mwindow->edl; + EDLSession *session = edl->session; + AudioOutConfig *aconfig = session->playback_config->aconfig; + audio->open_output(aconfig, BEEP_SAMPLE_RATE, bfrsz, channels, 0); + audio->start_playback(); + + double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 }; + const double two_pi = 2*M_PI; + int64_t audio_len = BEEP_SAMPLE_RATE * secs; + const double dt = two_pi * freq/BEEP_SAMPLE_RATE; + double th = 0; + + audio_pos = 0; + playing_audio = 1; + while( !interrupted ) { + int len = audio_len - audio_pos; + if( len <= 0 ) break; + if( len > bfrsz ) len = bfrsz; + int k = audio_pos; + for( int i=0; i= 0 ) th = t; + out0[i] = out1[i] = sin(th) * gain; + } + audio->write_buffer(out, channels, len); + audio_pos = k; + } + + if( !interrupted ) + audio->set_last_buffer(); + audio->stop_audio(interrupted ? 0 : 1); + playing_audio = 0; + + audio->close_all(); +} + +void Beeper::start() +{ + if( running() ) return; + audio_pos = -1; + interrupted = 0; + Thread::start(); +} + +void Beeper::stop(int wait) +{ + if( running() && !interrupted ) { + interrupted = 1; + audio->stop_audio(wait); + } + Thread::join(); +} + +void Beeper::tone(double freq, double secs, double gain) +{ + stop(0); + this->freq = freq; + this->secs = secs; + this->gain = gain; + start(); } + int MWindow::load_filenames(ArrayList *filenames, - int load_mode, - int update_filename) + int load_mode, int edl_mode, int update_filename) { ArrayList new_edls; ArrayList new_assets; ArrayList new_files; - const int debug = 0; -if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // save_defaults(); gui->start_hourglass(); @@ -1855,11 +1958,9 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); gui->unlock_window(); stop_playback(1); gui->lock_window("MWindow::load_filenames 0"); - -if(debug) printf("MWindow::load_filenames %d\n", __LINE__); undo_before(); - +const int debug = 0; if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // Define new_edls and new_assets to load @@ -1870,12 +1971,11 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); File *new_file = new File; Asset *new_asset = new Asset(filenames->get(i)); EDL *new_edl = new EDL; - char string[BCTEXTLEN]; - new_edl->create_objects(); new_edl->copy_session(edl, -1); new_file->set_program(edl->session->program_no); + char string[BCTEXTLEN]; sprintf(string, _("Loading %s"), new_asset->path); gui->show_message(string); @@ -1884,43 +1984,40 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); result = 1; switch( ftype ) { // Convert media file to EDL - case FILE_OK: + case FILE_OK: { // Warn about odd image dimensions if( new_asset->video_data && ((new_asset->width % 2) || (new_asset->height % 2)) ) { - char string[BCTEXTLEN]; - sprintf(string, _("%s's resolution is %dx%d.\n" + eprintf(_("%s's resolution is %dx%d.\n" "Images with odd dimensions may not decode properly."), new_asset->path, new_asset->width, new_asset->height); - MainError::show_error(string); } if( new_asset->program >= 0 && edl->session->program_no != new_asset->program ) { - char string[BCTEXTLEN]; - sprintf(string, _("%s's index was built for program number %d\n" + eprintf(_("%s's index was built for program number %d\n" "Playback preference is %d.\n Using program %d."), new_asset->path, new_asset->program, edl->session->program_no, new_asset->program); - MainError::show_error(string); } - if( load_mode != LOADMODE_RESOURCESONLY ) { - RecordLabels *labels = edl->session->label_cells ? - new RecordLabels(new_file) : 0; - asset_to_edl(new_edl, new_asset, labels); - new_edls.append(new_edl); - new_edl->add_user(); - delete labels; - } - else { + if( load_mode == LOADMODE_RESOURCESONLY ) { new_assets.append(new_asset); new_asset->add_user(); + result = 0; + break; } -// Set filename to nothing for assets since save EDL would overwrite them. + RecordLabels *labels = edl->session->label_cells ? + new RecordLabels(new_file) : 0; + asset_to_edl(new_edl, new_asset, labels); + new_edls.append(new_edl); + new_edl->add_user(); + delete labels; + if( load_mode == LOADMODE_REPLACE || load_mode == LOADMODE_REPLACE_CONCATENATE ) { +// Set filename to nothing for assets since save EDL would overwrite them. set_filename(""); // Reset timeline position for( int i=0; ilocal_session->track_start[i] = 0; } } - result = 0; - break; + break; } -// File not found - case FILE_NOT_FOUND: + case FILE_NOT_FOUND: { + eprintf(_("Failed to open %s"), new_asset->path); sprintf(string, _("Failed to open %s"), new_asset->path); gui->show_message(string, theme->message_error); gui->update_default_message(); - break; + break; } // Unknown format case FILE_UNRECOGNIZED_CODEC: { @@ -1964,11 +2060,6 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // Prompt user if( result ) { - char string[BCTEXTLEN]; - FileSystem fs; - fs.extract_name(string, new_asset->path); - - strcat(string, _("'s format couldn't be determined.")); new_asset->audio_data = 1; new_asset->format = FILE_PCM; new_asset->channels = defaults->get("AUDIO_CHANNELS", 2); @@ -1978,6 +2069,9 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); new_asset->signed_ = defaults->get("SIGNED_", 1); new_asset->header = defaults->get("HEADER", 0); + FileSystem fs; + fs.extract_name(string, new_asset->path); + strcat(string, _("'s format couldn't be determined.")); FileFormat fwindow(this); fwindow.create_objects(new_asset, string); result = fwindow.run_window(); @@ -1990,7 +2084,6 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); defaults->update("HEADER", new_asset->header); save_defaults(); } - // Append to list if( !result ) { // Recalculate length @@ -2011,14 +2104,15 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); new_asset->add_user(); } } - else { - result = 1; - } break; } case FILE_IS_XML: { FileXML xml_file; - xml_file.read_from_file(filenames->get(i)); + const char *filename = filenames->get(i); + if( xml_file.read_from_file(filename, 1) ) { + eprintf(_("Error: unable to open:\n %s"), filename); + break; + } const char *cin_version = 0; while( !xml_file.read_tag() ) { if( xml_file.tag.title_is("EDL") ) { @@ -2028,61 +2122,73 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); } xml_file.rewind(); if( !cin_version ) { - eprintf(_("XML file %s\n not from cinelerra."),filenames->get(i)); + eprintf(_("XML file %s\n not from cinelerra."),filename); char string[BCTEXTLEN]; - sprintf(string,_("Unknown %s"), filenames->get(i)); + sprintf(string,_("Unknown %s"), filename); gui->show_message(string); - result = 1; break; } if( strcmp(cin_version, CINELERRA_VERSION) && strcmp(cin_version, "Unify") && strcmp(cin_version, "5.1") ) { - char string[BCTEXTLEN]; - snprintf(string, sizeof(string), - _("Warning: XML from cinelerra version %s\n" + eprintf(_("Warning: XML from cinelerra version %s\n" "Session data may be incompatible."), cin_version); - show_warning(&preferences->warn_version, string); } - if( load_mode == LOADMODE_NESTED ) { -// Load temporary EDL for nesting. - EDL *nested_edl = new EDL; - nested_edl->create_objects(); - nested_edl->load_xml(&xml_file, LOAD_ALL); - int groups = nested_edl->regroup(session->group_number); - session->group_number += groups; - new_edl->create_nested(nested_edl); - new_edl->set_path(filenames->get(i)); - nested_edl->Garbage::remove_user(); + if( new_edl->load_xml(&xml_file, LOAD_ALL) ) { + eprintf(_("Error: unable to load:\n %s"), filename); + break; } - else { -// Load EDL for pasting - new_edl->load_xml(&xml_file, LOAD_ALL); - int groups = new_edl->regroup(session->group_number); - session->group_number += groups; - test_plugins(new_edl, filenames->get(i)); - - if( load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE ) { - strcpy(session->filename, filenames->get(i)); - strcpy(new_edl->local_session->clip_title, - filenames->get(i)); - if(update_filename) - set_filename(new_edl->local_session->clip_title); - } - else if( load_mode == LOADMODE_RESOURCESONLY ) { - strcpy(new_edl->local_session->clip_title, - filenames->get(i)); - struct stat st; - time_t t = !stat(filenames->get(i),&st) ? - st.st_mtime : time(&t); - ctime_r(&t, new_edl->local_session->clip_notes); + test_plugins(new_edl, filename); + int groups = new_edl->regroup(session->group_number); + session->group_number += groups; + switch( edl_mode ) { + case LOADMODE_EDL_CLIP: { + strcpy(new_edl->local_session->clip_title, + filenames->get(i)); + struct stat st; + time_t t = !stat(filenames->get(i),&st) ? + st.st_mtime : time(&t); + ctime_r(&t, new_edl->local_session->clip_notes); + switch( load_mode ) { + case LOADMODE_REPLACE: + case LOADMODE_REPLACE_CONCATENATE: + strcpy(session->filename, filename); + if( update_filename ) set_filename(filename); + break; } + result = 0; + break; } + case LOADMODE_EDL_NESTED: { + EDL *nested_edl = new EDL; + nested_edl->create_objects(); + nested_edl->copy_session(edl, -1); + nested_edl->create_nested(new_edl); + nested_edl->set_path(filename); + new_edl->remove_user(); + new_edl = nested_edl; + result = 0; + break; } + case LOADMODE_EDL_FILEREF: { + result = create_ref(new_asset, new_edl); + if( result ) break; + new_assets.append(new_asset); + new_asset->add_user(); + new_edl->remove_user(); + new_edl = new EDL; + new_edl->create_objects(); + new_edl->copy_session(edl, -1); + asset_to_edl(new_edl, new_asset); + delete new_file; + new_file = new File; + result = new_file->open_file(preferences, new_asset, 1, 0); + break; } } - - new_edls.append(new_edl); - new_edl->add_user(); - result = 0; + if( !result ) { + new_edls.append(new_edl); + new_edl->add_user(); + } + else + eprintf(_("Error: Unable to load xml:\n %s"), new_asset->path); break; } } @@ -2095,21 +2201,18 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); if(debug) printf("MWindow::load_filenames %d\n", __LINE__); - if(!result) { gui->reset_default_message(); gui->default_message(); } - if(debug) printf("MWindow::load_filenames %d\n", __LINE__); // Paste them. // Don't back up here. if( new_edls.size() ) { // For pasting, clear the active region - if( load_mode == LOADMODE_PASTE || - load_mode == LOADMODE_NESTED ) { + if( load_mode == LOADMODE_PASTE ) { double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); if(!EQUIV(start, end)) @@ -2124,8 +2227,15 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); edl->session->autos_follow_edits, 0); // overwrite } - else + else if( load_mode == LOADMODE_NEW_TRACKS && + edl_mode != LOADMODE_EDL_CLIP ) + paste_edls(&new_edls, load_mode, 0, -1, 0, 0, 0, 0); + else if( load_mode != LOADMODE_RESOURCESONLY || + edl_mode == LOADMODE_EDL_CLIP ) paste_edls(&new_edls, load_mode, 0, -1, 1, 1, 1, 0); + else + paste_edls(&new_edls, LOADMODE_NOTHING, 0, -1, 0, 0, 0, 0); + } // Add new assets to EDL and schedule assets for index building. @@ -2133,7 +2243,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); for( int i=0; inested_edls.size(); ++j ) { - mainindexes->add_next_asset(0, new_edl->nested_edls[j]); + mainindexes->add_indexable(new_edl->nested_edls[j]); edl->nested_edls.update_index(new_edl->nested_edls[j]); got_indexes = 1; } @@ -2142,18 +2252,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); for( int i=0; iasset->path, new_asset->path) ) { - got_it = 1; - break; - } - } - - mainindexes->add_next_asset(got_it ? new_file : 0, new_asset); + mainindexes->add_indexable(new_asset); edl->assets->update(new_asset); got_indexes = 1; } @@ -2162,32 +2261,12 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); if(got_indexes) mainindexes->start_build(); // Open plugin GUIs - Track *track = edl->tracks->first; - while( track ) { - for( int j = 0; j < track->plugin_set.size(); j++ ) { - PluginSet *plugins = track->plugin_set[j]; - Plugin *plugin = plugins->get_first_plugin(); - - while(plugin) { - if( load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE ) { - if( plugin->plugin_type == PLUGIN_STANDALONE && - plugin->show ) { - show_plugin(plugin); - } - } - - plugin = (Plugin*)plugin->next; - } - } - - track = track->next; - } + show_plugins(); - // if just opening one new resource in replace mode - if( ftype != FILE_IS_XML && - ( load_mode == LOADMODE_REPLACE || - load_mode == LOADMODE_REPLACE_CONCATENATE ) ) { + // opening new session + if( ( load_mode == LOADMODE_REPLACE || + load_mode == LOADMODE_REPLACE_CONCATENATE ) && + (ftype != FILE_IS_XML || edl_mode != LOADMODE_EDL_CLIP) ) { select_asset(0, 0); edl->session->proxy_scale = 1; edl->session->proxy_disabled_scale = 1; @@ -2227,11 +2306,12 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); gui->unlock_window(); // to update progress bar int ret = render_proxy(orig_idxbls); gui->lock_window("MWindow::load_filenames"); - if( ret >= 0 && edl->session->proxy_beep ) { + float gain = edl->session->proxy_beep; + if( ret >= 0 && gain > 0 ) { if( ret > 0 ) - beep(2000., 1.5, 0.5); + beep(2000., 1.5, gain); else - beep(4000., 0.25, 0.5); + beep(4000., 0.25, gain); } } @@ -2284,9 +2364,8 @@ int MWindow::render_proxy(ArrayList &new_idxbls) Asset *format_asset = new Asset; format_asset->format = FILE_FFMPEG; format_asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); - ProxyRender proxy_render(this, format_asset); int new_scale = edl->session->proxy_scale; - int use_scaler = edl->session->proxy_use_scaler; + ProxyRender proxy_render(this, format_asset, new_scale); for( int i=0; i &new_idxbls) // render needed proxies int result = proxy_render.create_needed_proxies(new_scale); if( !result ) { - add_proxy(use_scaler, - &proxy_render.orig_idxbls, &proxy_render.orig_proxies); + add_proxy(&proxy_render.orig_idxbls, &proxy_render.orig_proxies); } format_asset->remove_user(); return !result ? proxy_render.needed_proxies.size() : -1; @@ -2317,14 +2395,19 @@ int MWindow::enable_proxy() edl->session->proxy_disabled_scale != 1 ) { int new_scale = edl->session->proxy_disabled_scale; int new_use_scaler = edl->session->proxy_use_scaler; - edl->session->proxy_disabled_scale = 1; Asset *asset = new Asset; asset->format = FILE_FFMPEG; asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); ret = to_proxy(asset, new_scale, new_use_scaler); asset->remove_user(); - if( ret > 0 ) - beep(2000., 1.5, 0.5); + if( ret > 0 ) { + float gain = edl->session->proxy_beep; + beep(2000., 1.5, gain); + } + edl->session->proxy_disabled_scale = 1; + gui->lock_window("MWindow::to_proxy"); + update_project(LOADMODE_REPLACE); + gui->unlock_window(); } return 1; } @@ -2333,14 +2416,17 @@ int MWindow::disable_proxy() { if( edl->session->proxy_scale != 1 && edl->session->proxy_disabled_scale == 1 ) { - int new_scale = 1; + int old_scale = edl->session->proxy_scale, new_scale = 1; int new_use_scaler = edl->session->proxy_use_scaler; - edl->session->proxy_disabled_scale = edl->session->proxy_scale; Asset *asset = new Asset; asset->format = FILE_FFMPEG; asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0); to_proxy(asset, new_scale, new_use_scaler); asset->remove_user(); + edl->session->proxy_disabled_scale = old_scale; + gui->lock_window("MWindow::to_proxy"); + update_project(LOADMODE_REPLACE); + gui->unlock_window(); } return 1; } @@ -2353,7 +2439,9 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) edl->Garbage::add_user(); save_backup(); undo_before(_("proxy"), this); - ProxyRender proxy_render(this, asset); + int asset_scale = new_scale == 1 ? 0 : + !new_use_scaler ? 1 : new_scale; + ProxyRender proxy_render(this, asset, asset_scale); // revert project to original size from current size // remove all session proxy assets at the at the current proxy_scale @@ -2469,14 +2557,10 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) edl->Garbage::remove_user(); restart_brender(); - gui->lock_window("MWindow::to_proxy"); - update_project(LOADMODE_REPLACE); - gui->unlock_window(); - return !result ? proxy_render.needed_proxies.size() : -1; } -void MWindow::test_plugins(EDL *new_edl, char *path) +void MWindow::test_plugins(EDL *new_edl, const char *path) { char string[BCTEXTLEN]; @@ -2594,6 +2678,10 @@ void MWindow::create_objects(int want_gui, strcat(string, "/" FONT_SEARCHPATH); BC_Resources::init_fontconfig(string); if(debug) PRINT_TRACE +// use if plugged + init_x10tv(); + if( !x10tv ) + init_wintv(); // Default project created here init_edl(); @@ -2644,7 +2732,7 @@ void MWindow::create_objects(int want_gui, if(debug) printf("MWindow::create_objects %d total_time=%d\n", __LINE__, (int)timer.get_difference()); - plugin_guis = new ArrayList; + plugin_guis = new PluginGUIs(this); dead_plugins = new ArrayList; keyframe_threads = new ArrayList; @@ -2718,7 +2806,9 @@ void MWindow::create_objects(int want_gui, gui->show_window(); gui->raise_window(); gui->unlock_window(); - + cwindow->gui->lock_window("MWindow::create_objects 1"); + cwindow->gui->tool_panel->raise_tool(); + cwindow->gui->unlock_window(); if(debug) PRINT_TRACE if(preferences->use_tipwindow) @@ -2991,7 +3081,16 @@ void MWindow::set_auto_keyframes(int value) gui->mbuttons->edit_panel->keyframe->update(value); gui->flush(); cwindow->gui->lock_window("MWindow::set_auto_keyframes"); - cwindow->gui->edit_panel->keyframe->update(value); + cwindow->gui->flush(); + cwindow->gui->unlock_window(); +} + +void MWindow::set_span_keyframes(int value) +{ + edl->session->span_keyframes = value; + gui->mbuttons->edit_panel->span_keyframe->update(value); + gui->flush(); + cwindow->gui->lock_window("MWindow::set_span_keyframes"); cwindow->gui->flush(); cwindow->gui->unlock_window(); } @@ -3137,10 +3236,9 @@ void MWindow::show_keyframe_gui(Plugin *plugin) { keyframe_gui_lock->lock("MWindow::show_keyframe_gui"); // Find existing thread - for(int i = 0; i < keyframe_threads->size(); i++) - { - if(keyframe_threads->get(i)->plugin == plugin) - { + for( int i=0; isize(); ++i ) { + int plugin_id = keyframe_threads->get(i)->plugin_id; + if( plugin_id == plugin->orig_id ) { keyframe_threads->get(i)->start_window(plugin, 0); keyframe_gui_lock->unlock(); return; @@ -3148,10 +3246,8 @@ void MWindow::show_keyframe_gui(Plugin *plugin) } // Find unused thread - for(int i = 0; i < keyframe_threads->size(); i++) - { - if(!keyframe_threads->get(i)->plugin) - { + for( int i=0; isize(); ++i ) { + if( keyframe_threads->get(i)->plugin_id < 0 ) { keyframe_threads->get(i)->start_window(plugin, 0); keyframe_gui_lock->unlock(); return; @@ -3162,14 +3258,10 @@ void MWindow::show_keyframe_gui(Plugin *plugin) KeyFrameThread *thread = new KeyFrameThread(this); keyframe_threads->append(thread); thread->start_window(plugin, 0); - keyframe_gui_lock->unlock(); } - - - void MWindow::show_plugin(Plugin *plugin) { int done = 0; @@ -3183,14 +3275,12 @@ SET_TRACE //printf("MWindow::show_plugin %d\n", __LINE__); SET_TRACE - plugin_gui_lock->lock("MWindow::show_plugin"); - for(int i = 0; i < plugin_guis->total; i++) - { -// Pointer comparison - if(plugin_guis->get(i)->plugin == plugin) - { - plugin_guis->get(i)->raise_window(); + for( int i=0; itotal; ++i ) { +// Pointer/id comparison + PluginServer *plugin_gui = plugin_guis->get(i); + if( plugin_gui->plugin_id == plugin->orig_id ) { + plugin_gui->raise_window(); done = 1; break; } @@ -3219,6 +3309,8 @@ SET_TRACE } } plugin_gui_lock->unlock(); +// update show/gui_id + sync_parameters(CHANGE_PARAMS); //printf("MWindow::show_plugin %d\n", __LINE__); SET_TRACE //sleep(1); @@ -3228,28 +3320,33 @@ SET_TRACE void MWindow::hide_plugin(Plugin *plugin, int lock) { plugin->show = 0; + return hide_plugin(plugin->orig_id, lock); +} + +void MWindow::hide_plugin(int plugin_id, int lock) +{ // Update the toggle gui->lock_window("MWindow::hide_plugin"); gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0); gui->unlock_window(); if(lock) plugin_gui_lock->lock("MWindow::hide_plugin"); - for(int i = 0; i < plugin_guis->total; i++) - { - if(plugin_guis->get(i)->plugin == plugin) - { - PluginServer *ptr = plugin_guis->get(i); - plugin_guis->remove(ptr); + for( int i=0; itotal; ++i ) { + PluginServer *plugin_gui = plugin_guis->get(i); + if( plugin_gui->plugin_id == plugin_id ) { + plugin_guis->remove(plugin_gui); if(lock) plugin_gui_lock->unlock(); // Last command executed in client side close // Schedule for deletion - ptr->hide_gui(); - delete_plugin(ptr); + plugin_gui->hide_gui(); + delete_plugin(plugin_gui); //sleep(1); return; } } if(lock) plugin_gui_lock->unlock(); +// update show/gui_id + sync_parameters(CHANGE_PARAMS); } void MWindow::delete_plugin(PluginServer *plugin) @@ -3291,11 +3388,10 @@ void MWindow::hide_keyframe_guis() void MWindow::hide_keyframe_gui(Plugin *plugin) { keyframe_gui_lock->lock("MWindow::hide_keyframe_gui"); - for(int i = 0; i < keyframe_threads->size(); i++) - { - if(keyframe_threads->get(i)->plugin == plugin) - { - keyframe_threads->get(i)->close_window(); + for( int i = 0; i < keyframe_threads->size(); i++) { + KeyFrameThread *keyframe_gui = keyframe_threads->get(i); + if( keyframe_gui->plugin_id == plugin->orig_id ) { + keyframe_gui->close_window(); break; } } @@ -3369,15 +3465,13 @@ void MWindow::update_keyframe_guis() { // Send new configuration to keyframe GUI's keyframe_gui_lock->lock("MWindow::update_keyframe_guis"); - for(int i = 0; i < keyframe_threads->size(); i++) - { - KeyFrameThread *ptr = keyframe_threads->get(i); - if(edl->tracks->plugin_exists(ptr->plugin)) - ptr->update_gui(1); + for( int i=0; isize(); ++i ) { + KeyFrameThread *keyframe_gui = keyframe_threads->get(i); + Plugin *plugin = edl->tracks->plugin_exists(keyframe_gui->plugin_id); + if( plugin ) + keyframe_gui->update_gui(1); else - { - ptr->close_window(); - } + keyframe_gui->close_window(); } keyframe_gui_lock->unlock(); } @@ -3387,139 +3481,134 @@ void MWindow::update_plugin_guis(int do_keyframe_guis) // Send new configuration to plugin GUI's plugin_gui_lock->lock("MWindow::update_plugin_guis"); - for(int i = 0; i < plugin_guis->size(); i++) - { - PluginServer *ptr = plugin_guis->get(i); - if(edl->tracks->plugin_exists(ptr->plugin)) - ptr->update_gui(); - else - { -// Schedule for deletion if no plugin - plugin_guis->remove_number(i); - i--; - - ptr->hide_gui(); - delete_plugin(ptr); + for( int i=0; isize(); ++i ) { + PluginServer *plugin_gui = plugin_guis->get(i); + Plugin *plugin = edl->tracks->plugin_exists(plugin_gui->plugin_id); + if( plugin && plugin->show ) + plugin_gui->update_gui(); + else { +// Schedule for deletion if no plugin or not shown + plugin_guis->remove_number(i--); + plugin_gui->hide_gui(); + delete_plugin(plugin_gui); } } // Change plugin variable if not visible Track *track = edl->tracks->first; - while(track) - { - for(int i = 0; i < track->plugin_set.size(); i++) - { + for( ; track; track=track->next ) { + for( int i=0; i < track->plugin_set.size(); ++i ) { Plugin *plugin = (Plugin*)track->plugin_set[i]->first; - while(plugin) - { + for( ; plugin; plugin = (Plugin*)plugin->next ) { int got_it = 0; - for(int i = 0; i < plugin_guis->size(); i++) - { + for( int i=0; isize(); ++i ) { PluginServer *server = plugin_guis->get(i); - if(server->plugin == plugin) - { + if( server->plugin_id == plugin->orig_id ) { got_it = 1; break; } } - - if(!got_it) plugin->show = 0; - - plugin = (Plugin*)plugin->next; + if( !got_it ) plugin->show = 0; } } - - track = track->next; } plugin_gui_lock->unlock(); + if( do_keyframe_guis ) + update_keyframe_guis(); +} +void MWindow::stop_plugin_guis() +{ +// Send new configuration to plugin GUI's + plugin_gui_lock->lock("MWindow::stop_plugin_guis"); - if(do_keyframe_guis) update_keyframe_guis(); + for( int i=0; isize(); ++i ) { + PluginServer *plugin_gui = plugin_guis->get(i); + plugin_gui->render_stop(); + } + plugin_gui_lock->unlock(); } int MWindow::plugin_gui_open(Plugin *plugin) { - int result = 0; + int gui_id = plugin->gui_id; + if( gui_id < 0 ) return 0; plugin_gui_lock->lock("MWindow::plugin_gui_open"); - for(int i = 0; i < plugin_guis->total; i++) - { - if(plugin_guis->get(i)->plugin->identical_location(plugin)) - { - result = 1; - break; - } - } + PluginServer *plugin_server = plugin_guis->gui_server(gui_id); + int result = plugin_server ? 1 : 0; plugin_gui_lock->unlock(); return result; } + void MWindow::render_plugin_gui(void *data, Plugin *plugin) { - plugin_gui_lock->lock("MWindow::render_plugin_gui"); - for(int i = 0; i < plugin_guis->total; i++) - { - if(plugin_guis->get(i)->plugin->identical_location(plugin)) - { - plugin_guis->get(i)->render_gui(data); - break; - } - } + int gui_id = plugin->gui_id; + if( gui_id < 0 ) return; + plugin_gui_lock->lock("MWindow::render_plugin_gui 0"); + PluginServer *plugin_server = plugin_guis->gui_server(gui_id); + if( plugin_server ) + plugin_server->render_gui(data); plugin_gui_lock->unlock(); } void MWindow::render_plugin_gui(void *data, int size, Plugin *plugin) { - plugin_gui_lock->lock("MWindow::render_plugin_gui"); - for(int i = 0; i < plugin_guis->total; i++) - { - if(plugin_guis->get(i)->plugin->identical_location(plugin)) - { - plugin_guis->get(i)->render_gui(data, size); - break; - } - } + int gui_id = plugin->gui_id; + if( gui_id < 0 ) return; + plugin_gui_lock->lock("MWindow::render_plugin_gui 1"); + PluginServer *plugin_server = plugin_guis->gui_server(gui_id); + if( plugin_server ) + plugin_server->render_gui(data, size); plugin_gui_lock->unlock(); } +void MWindow::reset_plugin_gui_frames(Plugin *plugin) +{ + int gui_id = plugin->gui_id; + if( gui_id < 0 ) return; + plugin_gui_lock->lock("MWindow::reset_plugin_gui_frames"); + PluginServer *plugin_server = plugin_guis->gui_server(gui_id); + if( plugin_server ) + plugin_server->reset_plugin_gui_frames(); + plugin_gui_lock->unlock(); +} + +void MWindow::render_plugin_gui_frames(PluginClientFrames *frames, Plugin *plugin) +{ + int gui_id = plugin->gui_id; + if( gui_id < 0 ) return; + plugin_gui_lock->lock("MWindow::render_plugin_gui_frames"); + PluginServer *plugin_server = plugin_guis->gui_server(gui_id); + if( plugin_server ) + plugin_server->render_plugin_gui_frames(frames); + plugin_gui_lock->unlock(); +} + +double MWindow::get_tracking_position() +{ + return edl->local_session->get_selectionstart(1); +} + +int MWindow::get_tracking_direction() +{ + return cwindow->playback_engine->get_direction(); +} void MWindow::update_plugin_states() { plugin_gui_lock->lock("MWindow::update_plugin_states"); - for(int i = 0; i < plugin_guis->total; i++) - { - int result = 0; + for( int i=0; itotal; ++i ) { // Get a plugin GUI - Plugin *src_plugin = plugin_guis->get(i)->plugin; PluginServer *src_plugingui = plugin_guis->get(i); - -// Search for plugin in EDL. Only the master EDL shows plugin GUIs. - for(Track *track = edl->tracks->first; - track && !result; - track = track->next) - { - for(int j = 0; - j < track->plugin_set.total && !result; - j++) - { - PluginSet *plugin_set = track->plugin_set[j]; - for(Plugin *plugin = (Plugin*)plugin_set->first; - plugin && !result; - plugin = (Plugin*)plugin->next) - { - if(plugin == src_plugin && - !strcmp(plugin->title, src_plugingui->title)) result = 1; - } - } - } - - + int plugin_id = src_plugingui->plugin_id; + Plugin *src_plugin = edl->tracks->plugin_exists(plugin_id); // Doesn't exist anymore - if(!result) - { - hide_plugin(src_plugin, 0); - i--; + if( !src_plugin ) { + hide_plugin(plugin_id, 0); + --i; } } plugin_gui_lock->unlock(); @@ -3528,10 +3617,8 @@ void MWindow::update_plugin_states() void MWindow::update_plugin_titles() { - for(int i = 0; i < plugin_guis->total; i++) - { + for( int i=0; itotal; ++i ) plugin_guis->get(i)->update_title(); - } } int MWindow::asset_to_edl(EDL *new_edl, @@ -3602,6 +3689,7 @@ if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__); //printf("MWindow::asset_to_edl 4 %s\n", string); if(debug) printf("MWindow::asset_to_edl %d\n", __LINE__); + new_edl->local_session->asset2edl = 1; return 0; } @@ -3666,12 +3754,17 @@ void MWindow::update_project(int load_mode) zwindow->set_title(mixer->title); zwindow->start(); } + cwindow->gui->canvas->set_zoom(edl, 0); } update_vwindow(); if(debug) PRINT_TRACE cwindow->gui->lock_window("MWindow::update_project 2"); cwindow->gui->timebar->update(0); + Track *track = cwindow->calculate_affected_track(); + cwindow->mask_track_id = track ? track->get_id() : -1; + cwindow->gui->tool_panel->raise_tool(); + cwindow->gui->update_canvas(0); cwindow->gui->unlock_window(); if(debug) PRINT_TRACE @@ -3686,6 +3779,277 @@ void MWindow::update_project(int load_mode) if(debug) PRINT_TRACE } +void MWindow::stack_push(EDL *new_edl, Indexable *idxbl) +{ + int got_indexes = 0; + for( int i=0; inested_edls.size(); ++i ) { + EDL *nested_edl = new_edl->nested_edls[i]; + mainindexes->add_indexable(nested_edl); + edl->nested_edls.update_index(nested_edl); + got_indexes = 1; + } + for( Asset *asset=new_edl->assets->first; asset; asset=asset->next ) { + mainindexes->add_indexable(asset); + edl->assets->update(asset); + got_indexes = 1; + } +// Start examining next batch of index files + if( got_indexes ) + mainindexes->start_build(); + +// needs gui lock + gui->lock_window("MWindow::stack_push"); + if( stack.size() < 9 ) { + save_backup(); + hide_plugins(); + undo_before(); + StackItem &item = stack.append(); + item.edl = edl; + item.new_edl = new_edl; + item.undo = undo; + item.idxbl = idxbl; + item.mtime = 0; + if( idxbl && idxbl->is_asset ) { + struct stat st; + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF && + !stat(asset->path, &st) ) + item.mtime = st.st_mtime; + } + edl = new_edl; + edl->add_user(); + strcpy(session->filename, edl->path); + undo = new MainUndo(this); + gui->stack_button->update(); + update_project(LOADMODE_REPLACE); + } + gui->unlock_window(); + show_plugins(); +} + +void MWindow::stack_pop() +{ + if( !stack.size() ) return; +// writes on config_path/backup%d.xml + save_backup(); + hide_plugins(); +// already have gui lock + StackItem &item = stack.last(); +// session edl replaced, overwrite and save clip data + if( item.new_edl != edl ) + item.new_edl->overwrite_clip(edl); + edl->remove_user(); + edl = item.edl; + delete undo; + undo = item.undo; + Indexable *idxbl = item.idxbl; + int64_t mtime = item.mtime; + stack.remove(); + if( idxbl ) { + gui->unlock_window(); + remove_from_caches(idxbl); + remove_indexfile(idxbl); + mainindexes->add_indexable(idxbl); + mainindexes->start_build(); + awindow->gui->async_update_assets(); + gui->lock_window("MWindow::stack_pop"); + } + strcpy(session->filename, edl->path); + update_project(LOADMODE_REPLACE); + undo_after(_("open edl"), LOAD_ALL); + show_plugins(); + gui->stack_button->update(); + if( mtime && idxbl && idxbl->is_asset ) { + struct stat st; + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF && !stat(asset->path, &st) && + item.mtime == st.st_mtime ) { + char text[BCTEXTLEN]; + snprintf(text, sizeof(text), + _("Warning: Asset not updated: %s"), asset->path); + show_warning(&preferences->warn_stack, text); + } + } +} + +int MWindow::save(EDL *edl, char *filename, int stat) +{ + FileXML file; + edl->save_xml(&file, filename); + file.terminate_string(); + if( file.write_to_file(filename) ) { + eprintf(_("Couldn't open %s"), filename); + return 1; + } + if( stat ) { + char string[BCTEXTLEN]; + char *filename = stack.size() ? + stack[0].edl->path : session->filename; + sprintf(string, _("\"%s\" %jdC written"), + filename, file.length()); + gui->lock_window("SaveAs::run"); + gui->show_message(string); + gui->unlock_window(); + } + return 0; +} + +int MWindow::save(int save_as) +{ + char new_path[BCTEXTLEN]; new_path[0] = 0; + char *path = stack.size() ? stack[0].edl->path : session->filename; + if( save_as || !path[0] ) { + if( ConfirmSave::get_save_path(this, new_path) ) + return 1; + if( stack.size() ) { + strcpy(path, new_path); + set_titlebar(new_path); + } + else + set_filename(new_path); + gui->mainmenu->add_load(new_path); + path = new_path; + } + for( int i=stack.size(); --i>=0; ) { + StackItem &item = stack[i]; + Indexable *idxbl = item.idxbl; + if( idxbl->is_asset ) { + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF ) { + if( save(item.new_edl, asset->path, 0) ) + return 1; + } + } + else if( item.new_edl != item.idxbl ) + item.new_edl->overwrite_clip((EDL*)item.idxbl); + } + EDL *new_edl = stack.size() ? stack[0].edl : edl; + save(new_edl, path, 1); + return 0; +} + +void MWindow::show_plugins() +{ + for( Track *track=edl->tracks->first; track; track=track->next ) { + for( int i=0; iplugin_set.size(); ++i ) { + PluginSet *plugins = track->plugin_set[i]; + Plugin *plugin = plugins->get_first_plugin(); + for( ; plugin; plugin=(Plugin*)plugin->next ) { + if( plugin->plugin_type == PLUGIN_STANDALONE && + plugin->show ) + show_plugin(plugin); + } + } + } +} + +void MWindow::clip_to_media() +{ + if( edl->session->proxy_scale != 1 ) { + eprintf("Nesting not allowed when proxy scale != 1"); + return; + } + undo_before(); + int clips_total = session->drag_clips->total; + for( int i=0; idrag_clips->values[i]; + time_t dt; time(&dt); + struct tm dtm; localtime_r(&dt, &dtm); + char path[BCTEXTLEN], *cp = path, *ep = cp+sizeof(path)-1; +// path_basename = "Nested_-