4 * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "attachmentpoint.h"
26 #include "bcsignals.h"
27 #include "cplayback.h"
31 #include "edlsession.h"
33 #include "floatautos.h"
34 #include "keyframes.h"
35 #include "localsession.h"
36 #include "mainerror.h"
37 #include "mainprogress.h"
38 #include "menueffects.h"
40 #include "mwindowgui.h"
41 #include "playbackengine.h"
43 #include "pluginaclient.h"
44 #include "pluginaclientlad.h"
45 #include "pluginfclient.h"
46 #include "pluginclient.h"
47 #include "plugincommands.h"
48 #include "pluginserver.h"
49 #include "pluginvclient.h"
50 #include "preferences.h"
53 #include "mainsession.h"
55 #include "trackcanvas.h"
56 #include "transportque.h"
57 #include "vdevicex11.h"
59 #include "videodevice.h"
60 #include "virtualanode.h"
61 #include "virtualvnode.h"
69 #include <sys/types.h>
75 void PluginServer::init()
78 this->plugin_type = PLUGIN_TYPE_UNKNOWN;
79 plugin_obj = new PluginObj();
80 modules = new ArrayList<Module*>;
81 nodes = new ArrayList<VirtualNode*>;
85 PluginServer::PluginServer()
90 PluginServer::PluginServer(MWindow *mwindow, const char *path, int type)
92 char fpath[BCTEXTLEN];
94 this->plugin_type = type;
95 this->mwindow = mwindow;
96 if( type == PLUGIN_TYPE_FFMPEG ) {
97 ff_name = cstrdup(path);
98 sprintf(fpath, "ff_%s", path);
104 PluginServer::PluginServer(PluginServer &that)
107 plugin_type = that.plugin_type;
108 plugin_obj = that.plugin_obj;
109 plugin_obj->add_user();
110 title = !that.title ? 0 : cstrdup(that.title);
111 tip = !that.tip ? 0 : cstrdup(that.tip);
112 path = !that.path ? 0 : cstrdup(that.path);
113 ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name);
114 modules = new ArrayList<Module*>;
115 nodes = new ArrayList<VirtualNode*>;
117 attachment = that.attachment;
118 realtime = that.realtime;
119 multichannel = that.multichannel;
120 preferences = that.preferences;
121 synthesis = that.synthesis;
125 fileio = that.fileio;
126 uses_gui = that.uses_gui;
127 mwindow = that.mwindow;
128 keyframe = that.keyframe;
129 new_plugin = that.new_plugin;
131 lad_descriptor = that.lad_descriptor;
132 lad_descriptor_function = that.lad_descriptor_function;
133 lad_index = that.lad_index;
136 PluginServer::~PluginServer()
146 plugin_obj->remove_user();
149 // Done only once at creation
150 int PluginServer::reset_parameters()
161 lad_descriptor_function = 0;
167 start_auto = end_auto = 0;
171 realtime = multichannel = fileio = 0;
173 audio = video = theme = 0;
180 for( int i=sizeof(args)/sizeof(args[0]); --i>=0; ) args[i] = 0;
195 // Done every time the plugin is opened or closed
196 int PluginServer::cleanup_plugin()
198 in_buffer_size = out_buffer_size = 0;
199 total_in_buffers = total_out_buffers = 0;
204 written_samples = written_frames = 0;
211 void PluginServer::set_mwindow(MWindow *mwindow)
213 this->mwindow = mwindow;
216 void PluginServer::set_attachmentpoint(AttachmentPoint *attachmentpoint)
218 this->attachmentpoint = attachmentpoint;
221 void PluginServer::set_keyframe(KeyFrame *keyframe)
223 this->keyframe = keyframe;
226 void PluginServer::set_prompt(MenuEffectPrompt *prompt)
228 this->prompt = prompt;
231 void PluginServer::set_lad_index(int i)
236 int PluginServer::get_lad_index()
238 return this->lad_index;
241 int PluginServer::is_unknown()
243 return plugin_type == PLUGIN_TYPE_UNKNOWN ? 1 : 0;
246 int PluginServer::is_executable()
248 return plugin_type == PLUGIN_TYPE_EXECUTABLE ? 1 : 0;
251 int PluginServer::is_builtin()
253 return plugin_type == PLUGIN_TYPE_BUILTIN ? 1 : 0;
256 int PluginServer::is_ladspa()
258 return plugin_type == PLUGIN_TYPE_LADSPA ? 1 : 0;
261 int PluginServer::is_ffmpeg()
263 return plugin_type == PLUGIN_TYPE_FFMPEG ? 1 : 0;
266 int PluginServer::is_lv2()
268 return plugin_type == PLUGIN_TYPE_LV2 ? 1 : 0;
271 void PluginServer::set_path(const char *path)
273 delete [] this->path;
274 this->path = cstrdup(path);
277 char* PluginServer::get_path()
282 int PluginServer::get_synthesis()
288 void PluginServer::set_title(const char *string)
291 title = cstrdup(string);
294 void PluginServer::generate_display_title(char *string)
296 char ltitle[BCTEXTLEN];
297 if(BC_Resources::locale_utf8)
298 strcpy(ltitle, _(title));
300 BC_Resources::encode(BC_Resources::encoding, 0,
301 _(title),strlen(title)+1, ltitle,BCTEXTLEN);
302 if(plugin && plugin->track)
303 sprintf(string, "%s: %s", plugin->track->title, ltitle);
305 strcpy(string, ltitle);
308 void *PluginObj::load(const char *plugin_dir, const char *path)
310 char dlpath[BCTEXTLEN], *dp = dlpath;
311 const char *cp = path;
313 const char *bp = plugin_dir;
314 while( *bp ) *dp++ = *bp++;
317 while( *cp ) *dp++ = *cp++;
319 return dlobj = load(dlpath);
322 int PluginServer::load_obj()
324 void *obj = plugin_obj->obj();
325 if( !obj ) obj =plugin_obj->load(preferences->plugin_dir, path);
329 const char *PluginServer::load_error()
331 return plugin_obj->load_error();
334 void *PluginServer::get_sym(const char *sym)
336 if( !plugin_obj->obj() ) return 0;
337 return plugin_obj->load_sym(sym);
340 // Open plugin for signal processing
341 int PluginServer::open_plugin(int master,
342 Preferences *preferences,
346 if(plugin_open) return 0;
348 this->preferences = preferences;
349 this->plugin = plugin;
351 if( !is_ffmpeg() && !is_lv2() && !is_executable() && !load_obj() ) {
352 // If the load failed, can't use error string to detect executable
353 // because locale and language selection changes the load_error() message
354 // if( !strstr(string, "executable") ) { set_title(path); plugin_type = PLUGIN_TYPE_EXECUTABLE; }
355 eprintf("PluginServer::open_plugin: load_obj %s = %s\n", path, load_error());
356 return PLUGINSERVER_NOT_RECOGNIZED;
358 if( is_unknown() || is_builtin() ) {
360 (PluginClient* (*)(PluginServer*)) get_sym("new_plugin");
362 plugin_type = PLUGIN_TYPE_BUILTIN;
364 if( is_unknown() || is_ladspa() ) {
365 lad_descriptor_function =
366 (LADSPA_Descriptor_Function) get_sym("ladspa_descriptor");
367 if( lad_descriptor_function ) {
368 if( lad_index < 0 ) return PLUGINSERVER_IS_LAD;
369 lad_descriptor = lad_descriptor_function(lad_index);
370 if( !lad_descriptor )
371 return PLUGINSERVER_NOT_RECOGNIZED;
372 plugin_type = PLUGIN_TYPE_LADSPA;
376 fprintf(stderr, "PluginServer::open_plugin "
377 " %d: plugin undefined in %s\n", __LINE__, path);
378 return PLUGINSERVER_NOT_RECOGNIZED;
380 switch( plugin_type ) {
381 case PLUGIN_TYPE_EXECUTABLE:
382 return PLUGINSERVER_OK;
383 case PLUGIN_TYPE_BUILTIN:
384 client = new_plugin(this);
386 case PLUGIN_TYPE_FFMPEG:
387 client = new_ffmpeg_plugin();
389 case PLUGIN_TYPE_LADSPA:
390 client = new PluginAClientLAD(this);
392 case PLUGIN_TYPE_LV2:
393 client = new_lv2_plugin();
400 return PLUGINSERVER_NOT_RECOGNIZED;
402 // Run initialization functions
403 realtime = client->is_realtime();
404 // Don't load defaults when probing the directory.
407 client->load_defaults_xml();
409 client->load_defaults();
411 audio = client->is_audio();
412 video = client->is_video();
413 theme = client->is_theme();
414 fileio = client->is_fileio();
415 uses_gui = client->uses_gui();
416 multichannel = client->is_multichannel();
417 synthesis = client->is_synthesis();
418 transition = client->is_transition();
419 set_title(client->plugin_title());
421 //printf("PluginServer::open_plugin 2\n");
423 return PLUGINSERVER_OK;
426 int PluginServer::close_plugin()
428 if(!plugin_open) return 0;
432 // Defaults are saved in the thread.
433 // if(client->defaults) client->save_defaults();
437 // shared object is persistent since plugin deletion would unlink its own object
443 void PluginServer::client_side_close()
445 // Last command executed in client thread
447 mwindow->hide_plugin(plugin, 1);
451 prompt->lock_window();
453 prompt->unlock_window();
457 void PluginServer::render_stop()
460 client->render_stop();
463 void PluginServer::write_table(FILE *fp, const char *path, int idx, int64_t mtime)
466 fprintf(fp, "%d \"%s\" \"%s\" %jd %d %d %d %d %d %d %d %d %d %d %d\n",
467 plugin_type, path, title, mtime, idx, audio, video, theme, realtime,
468 fileio, uses_gui, multichannel, synthesis, transition, lad_index);
471 int PluginServer::scan_table(char *text, int &type, char *path, char *title, int64_t &mtime)
473 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %jd", &type, path, title, &mtime);
474 return n < 4 ? 1 : 0;
477 int PluginServer::read_table(char *text)
479 char path[BCTEXTLEN], title[BCTEXTLEN];
481 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %jd %d %d %d %d %d %d %d %d %d %d %d",
482 &plugin_type, path, title, &mtime, &dir_idx, &audio, &video, &theme, &realtime,
483 &fileio, &uses_gui, &multichannel, &synthesis, &transition, &lad_index);
484 if( n != 15 ) return 1;
489 int PluginServer::init_realtime(int realtime_sched,
490 int total_in_buffers,
494 if(!plugin_open) return 0;
496 // set for realtime priority
498 // Call start_realtime
499 this->total_in_buffers = this->total_out_buffers = total_in_buffers;
500 client->plugin_init_realtime(realtime_sched,
508 // Replaced by pull method but still needed for transitions
509 void PluginServer::process_transition(VFrame *input,
511 int64_t current_position,
514 if(!plugin_open) return;
515 PluginVClient *vclient = (PluginVClient*)client;
517 vclient->source_position = current_position;
518 vclient->source_start = 0;
519 vclient->total_len = total_len;
521 vclient->input = new VFrame*[1];
522 vclient->output = new VFrame*[1];
524 vclient->input[0] = input;
525 vclient->output[0] = output;
527 vclient->process_realtime(input, output);
529 delete [] vclient->input;
530 delete [] vclient->output;
534 void PluginServer::process_transition(Samples *input,
536 int64_t current_position,
537 int64_t fragment_size,
540 if(!plugin_open) return;
541 PluginAClient *aclient = (PluginAClient*)client;
543 aclient->source_position = current_position;
544 aclient->total_len = total_len;
545 aclient->source_start = 0;
546 aclient->process_realtime(fragment_size,
552 void PluginServer::process_buffer(VFrame **frame,
553 int64_t current_position,
558 if(!plugin_open) return;
559 PluginVClient *vclient = (PluginVClient*)client;
561 vclient->source_position = current_position;
562 vclient->total_len = total_len;
563 vclient->frame_rate = frame_rate;
564 vclient->input = new VFrame*[total_in_buffers];
565 vclient->output = new VFrame*[total_in_buffers];
566 for(int i = 0; i < total_in_buffers; i++)
568 vclient->input[i] = frame[i];
569 vclient->output[i] = frame[i];
574 vclient->source_start = (int64_t)plugin->startproject *
576 vclient->project_frame_rate;
578 vclient->direction = direction;
582 //printf("plugin=%p source_start=%ld\n", plugin, vclient->source_start);
584 vclient->begin_process_buffer();
587 vclient->process_buffer(frame, current_position, frame_rate);
591 vclient->process_buffer(frame[0], current_position, frame_rate);
593 vclient->end_process_buffer();
595 for(int i = 0; i < total_in_buffers; i++)
596 frame[i]->push_prev_effect(title);
598 delete [] vclient->input;
599 delete [] vclient->output;
605 void PluginServer::process_buffer(Samples **buffer,
606 int64_t current_position,
607 int64_t fragment_size,
612 if(!plugin_open) return;
613 PluginAClient *aclient = (PluginAClient*)client;
615 aclient->source_position = current_position;
616 aclient->total_len = total_len;
617 aclient->sample_rate = sample_rate;
620 aclient->source_start = plugin->startproject *
622 aclient->project_sample_rate;
624 aclient->direction = direction;
625 aclient->begin_process_buffer();
628 aclient->process_buffer(fragment_size,
635 aclient->process_buffer(fragment_size,
640 aclient->end_process_buffer();
644 void PluginServer::send_render_gui(void *data)
646 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
647 if(attachmentpoint) attachmentpoint->render_gui(data, this);
650 void PluginServer::send_render_gui(void *data, int size)
652 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
653 if(attachmentpoint) attachmentpoint->render_gui(data, size, this);
656 void PluginServer::render_gui(void *data)
658 if(client) client->plugin_render_gui(data);
661 void PluginServer::render_gui(void *data, int size)
663 if(client) client->plugin_render_gui(data, size);
666 MainProgressBar* PluginServer::start_progress(char *string, int64_t length)
668 mwindow->gui->lock_window();
669 MainProgressBar *result = mwindow->mainprogress->start_progress(string, length);
670 mwindow->gui->unlock_window();
674 int64_t PluginServer::get_written_samples()
676 if(!plugin_open) return 0;
677 return written_samples;
680 int64_t PluginServer::get_written_frames()
682 if(!plugin_open) return 0;
683 return written_frames;
695 // ======================= Non-realtime plugin
697 int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
699 if(!plugin_open) return 0;
701 client->start = start;
703 client->source_start = start;
704 client->total_len = end - start;
705 client->total_in_buffers = channels;
708 //printf(" source_start=%ld total_len=%ld\n", client->source_start, client->total_len);
710 return client->plugin_get_parameters();
713 int PluginServer::set_interactive()
715 if(!plugin_open) return 0;
716 client->set_interactive();
720 void PluginServer::append_module(Module *module)
722 modules->append(module);
725 void PluginServer::append_node(VirtualNode *node)
730 void PluginServer::reset_nodes()
735 int PluginServer::set_error()
741 int PluginServer::set_realtime_sched()
743 //struct sched_param params;
744 //params.sched_priority = 1;
745 //sched_setscheduler(0, SCHED_RR, ¶m);
750 int PluginServer::process_loop(VFrame **buffers, int64_t &write_length)
752 if(!plugin_open) return 1;
753 return client->plugin_process_loop(buffers, write_length);
756 int PluginServer::process_loop(Samples **buffers, int64_t &write_length)
758 if(!plugin_open) return 1;
759 return client->plugin_process_loop(buffers, write_length);
763 int PluginServer::start_loop(int64_t start,
768 if(!plugin_open) return 0;
769 client->plugin_start_loop(start, end, buffer_size, total_buffers);
773 int PluginServer::stop_loop()
775 if(!plugin_open) return 0;
776 return client->plugin_stop_loop();
779 int PluginServer::read_frame(VFrame *buffer,
781 int64_t start_position)
783 ((VModule*)modules->values[channel])->render(buffer,
786 mwindow->edl->session->frame_rate,
792 int PluginServer::read_samples(Samples *buffer,
795 int64_t start_position,
798 // len is now in buffer
799 if(!multichannel) channel = 0;
801 if(nodes->total > channel)
802 return ((VirtualANode*)nodes->values[channel])->read_data(buffer,
807 if(modules->total > channel)
808 return ((AModule*)modules->values[channel])->render(buffer,
816 printf("PluginServer::read_samples no object available for channel=%d\n",
824 int PluginServer::read_samples(Samples *buffer,
826 int64_t start_position,
829 // total_samples is now set in buffer
830 ((AModule*)modules->values[channel])->render(buffer,
834 mwindow->edl->session->sample_rate,
839 int PluginServer::read_frame(VFrame *buffer,
841 int64_t start_position,
845 // Data source depends on whether we're part of a virtual console or a
849 // If we're a VirtualNode, read_data in the virtual plugin node handles
850 // backward propogation and produces the data.
851 // If we're a Module, render in the module produces the data.
855 if(!multichannel) channel = 0;
857 // Push our name on the next effect stack
858 buffer->push_next_effect(title);
859 //printf("PluginServer::read_frame %p\n", buffer);
860 //buffer->dump_stacks();
862 if(nodes->total > channel)
864 //printf("PluginServer::read_frame %d\n", __LINE__);
865 result = ((VirtualVNode*)nodes->values[channel])->read_data(buffer,
871 if(modules->total > channel)
873 //printf("PluginServer::read_frame %d\n", __LINE__);
874 result = ((VModule*)modules->values[channel])->render(buffer,
885 printf("PluginServer::read_frame no object available for channel=%d\n",
889 // Pop our name from the next effect stack
890 buffer->pop_next_effect();
915 int PluginServer::get_gui_status()
918 return plugin->show ? GUI_ON : GUI_OFF;
923 void PluginServer::raise_window()
925 if(!plugin_open) return;
926 client->raise_window();
929 void PluginServer::show_gui()
931 if(!plugin_open) return;
932 if(plugin) client->total_len = plugin->length;
933 if(plugin) client->source_start = plugin->startproject;
936 client->source_position = Units::to_int64(
937 mwindow->edl->local_session->get_selectionstart(1) *
938 mwindow->edl->session->frame_rate);
943 client->source_position = Units::to_int64(
944 mwindow->edl->local_session->get_selectionstart(1) *
945 mwindow->edl->session->sample_rate);
948 client->update_display_title();
952 void PluginServer::hide_gui()
954 if(!plugin_open) return;
955 if(client->defaults) client->save_defaults();
959 void PluginServer::update_gui()
961 if(!plugin_open || !plugin) return;
963 client->total_len = plugin->length;
964 client->source_start = plugin->startproject;
968 client->source_position = Units::to_int64(
969 mwindow->edl->local_session->get_selectionstart(1) *
970 mwindow->edl->session->frame_rate);
975 client->source_position = Units::to_int64(
976 mwindow->edl->local_session->get_selectionstart(1) *
977 mwindow->edl->session->sample_rate);
980 client->plugin_update_gui();
983 void PluginServer::update_title()
985 if(!plugin_open) return;
987 client->update_display_title();
991 int PluginServer::set_string(char *string)
993 if(!plugin_open) return 0;
995 client->set_string_client(string);
999 int PluginServer::gui_open()
1001 if(attachmentpoint) return attachmentpoint->gui_open();
1005 void PluginServer::set_use_opengl(int value, VideoDevice *vdevice)
1007 this->use_opengl = value;
1008 this->vdevice = vdevice;
1011 int PluginServer::get_use_opengl()
1017 void PluginServer::run_opengl(PluginClient *plugin_client)
1020 ((VDeviceX11*)vdevice->get_output_base())->run_plugin(plugin_client);
1023 // ============================= queries
1025 void PluginServer::get_defaults_path(char *path)
1027 // Get plugin name from path
1028 char *ptr1 = strrchr(get_path(), '/');
1029 char *ptr2 = strrchr(get_path(), '.');
1030 if(!ptr1) ptr1 = get_path();
1031 if(!ptr2) ptr2 = get_path() + strlen(get_path());
1032 char string2[BCTEXTLEN], *ptr3 = string2;
1033 while( ptr1 < ptr2 ) *ptr3++ = *ptr1++;
1035 sprintf(path, "%s/%s.xml", File::get_config_path(), string2);
1038 void PluginServer::save_defaults()
1040 if(client) client->save_defaults();
1043 int PluginServer::get_samplerate()
1045 if(!plugin_open) return 0;
1048 return client->get_samplerate();
1052 return mwindow->edl->session->sample_rate;
1055 printf("PluginServer::get_samplerate audio and mwindow == NULL\n");
1061 double PluginServer::get_framerate()
1063 if(!plugin_open) return 0;
1066 return client->get_framerate();
1070 return mwindow->edl->session->frame_rate;
1073 printf("PluginServer::get_framerate video and mwindow == NULL\n");
1078 int PluginServer::get_project_samplerate()
1081 return mwindow->edl->session->sample_rate;
1084 return edl->session->sample_rate;
1087 printf("PluginServer::get_project_samplerate mwindow and edl are NULL.\n");
1092 double PluginServer::get_project_framerate()
1095 return mwindow->edl->session->frame_rate;
1098 return edl->session->frame_rate;
1101 printf("PluginServer::get_project_framerate mwindow and edl are NULL.\n");
1108 int PluginServer::detach_buffers()
1110 ring_buffers_out.remove_all();
1111 offset_out_render.remove_all();
1112 double_buffer_out_render.remove_all();
1113 realtime_out_size.remove_all();
1115 ring_buffers_in.remove_all();
1116 offset_in_render.remove_all();
1117 double_buffer_in_render.remove_all();
1118 realtime_in_size.remove_all();
1120 out_buffer_size = 0;
1122 total_out_buffers = 0;
1124 total_in_buffers = 0;
1128 int PluginServer::arm_buffer(int buffer_number,
1131 int double_buffer_in,
1132 int double_buffer_out)
1134 offset_in_render.values[buffer_number] = offset_in;
1135 offset_out_render.values[buffer_number] = offset_out;
1136 double_buffer_in_render.values[buffer_number] = double_buffer_in;
1137 double_buffer_out_render.values[buffer_number] = double_buffer_out;
1142 int PluginServer::set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse)
1144 this->autos = autos;
1145 this->start_auto = start_auto;
1146 this->end_auto = end_auto;
1147 this->reverse = reverse;
1153 void PluginServer::save_data(KeyFrame *keyframe)
1155 if(!plugin_open) return;
1156 client->save_data(keyframe);
1159 KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
1161 KeyFrame *result = 0;
1163 result = plugin->get_prev_keyframe(position, client->direction);
1169 KeyFrame* PluginServer::get_next_keyframe(int64_t position)
1171 KeyFrame *result = 0;
1173 result = plugin->get_next_keyframe(position, client->direction);
1180 KeyFrame* PluginServer::get_keyframe()
1183 // Realtime plugin case
1184 return plugin->get_keyframe();
1186 // Rendered plugin case
1191 void PluginServer::apply_keyframe(KeyFrame *src)
1195 keyframe->copy_data(src);
1200 plugin->keyframes->update_parameter(src);
1208 void PluginServer::get_camera(float *x, float *y, float *z,
1209 int64_t position, int direction)
1211 plugin->track->automation->get_camera(x, y, z, position, direction);
1214 void PluginServer::get_projector(float *x, float *y, float *z,
1215 int64_t position, int direction)
1217 plugin->track->automation->get_projector(x, y, z, position, direction);
1221 int PluginServer::get_interpolation_type()
1223 return plugin->edl->session->interpolation_type;
1226 Theme* PluginServer::new_theme()
1230 return client->new_theme();
1236 Theme* PluginServer::get_theme()
1238 if(mwindow) return mwindow->theme;
1239 printf("PluginServer::get_theme mwindow not set\n");
1244 void PluginServer::get_plugin_png_name(char *png_name)
1246 char *pp = png_name, *ep = pp + BCSTRLEN-1;
1247 char *cp = strrchr(path, '/');
1248 cp = !cp ? path : cp+1;
1249 char *sp = strrchr(cp, '.');
1250 if( !sp ) sp = cp+strlen(cp);
1251 while( pp < ep && cp < sp ) *pp++ = *cp++;
1252 snprintf(pp, ep-pp, ".png");
1255 int PluginServer::get_plugin_png_path(char *png_path, const char *plugin_icons)
1257 char png_name[BCSTRLEN];
1258 get_plugin_png_name(png_name);
1259 char *pp = png_path, *ep = pp + BCTEXTLEN-1;
1260 pp += snprintf(pp, ep-pp, "%s/picon/%s/%s",
1261 File::get_plugin_path(), plugin_icons, png_name);
1262 return access(png_path,R_OK) ? 1 : 0;
1265 int PluginServer::get_plugin_png_path(char *png_path)
1267 int ret = get_plugin_png_path(png_path, mwindow->preferences->plugin_icons);
1268 if( ret ) ret = get_plugin_png_path(png_path, DEFAULT_PICON);
1272 VFrame *PluginServer::get_plugin_images()
1274 char png_path[BCTEXTLEN];
1275 if( !get_plugin_png_path(png_path) )
1276 return VFramePng::vframe_png(png_path,0,0);
1277 char png_name[BCSTRLEN];
1278 get_plugin_png_name(png_name);
1279 unsigned char *data = mwindow->theme->get_image_data(png_name, 0);
1280 return data ? new VFramePng(data, 0.) : 0;
1283 VFrame *PluginServer::get_picon()
1286 picon = get_plugin_images();
1290 // Called when plugin interface is tweeked
1291 void PluginServer::sync_parameters()
1293 if(video) mwindow->restart_brender();
1294 mwindow->sync_parameters();
1295 mwindow->update_keyframe_guis();
1296 if(mwindow->edl->session->auto_conf->plugins)
1298 mwindow->gui->lock_window("PluginServer::sync_parameters");
1299 mwindow->gui->draw_overlays(1);
1300 mwindow->gui->unlock_window();
1306 void PluginServer::dump(FILE *fp)
1308 fprintf(fp," PluginServer %d %p %s %s %d\n",
1309 __LINE__, this, path, title, realtime);