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*>;
84 PluginServer::PluginServer()
89 PluginServer::PluginServer(MWindow *mwindow, char *path, int type)
91 char fpath[BCTEXTLEN];
93 this->plugin_type = type;
94 this->mwindow = mwindow;
95 if( type == PLUGIN_TYPE_FFMPEG ) {
96 ff_name = cstrdup(path);
97 sprintf(fpath, "ff_%s", path);
103 PluginServer::PluginServer(PluginServer &that)
106 plugin_type = that.plugin_type;
107 plugin_obj = that.plugin_obj;
108 plugin_obj->add_user();
109 title = !that.title ? 0 : cstrdup(that.title);
110 path = !that.path ? 0 : cstrdup(that.path);
111 ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name);
112 modules = new ArrayList<Module*>;
113 nodes = new ArrayList<VirtualNode*>;
115 attachment = that.attachment;
116 realtime = that.realtime;
117 multichannel = that.multichannel;
118 preferences = that.preferences;
119 synthesis = that.synthesis;
123 fileio = that.fileio;
124 uses_gui = that.uses_gui;
125 mwindow = that.mwindow;
126 keyframe = that.keyframe;
127 new_plugin = that.new_plugin;
129 lad_descriptor = that.lad_descriptor;
130 lad_descriptor_function = that.lad_descriptor_function;
131 lad_index = that.lad_index;
134 PluginServer::~PluginServer()
143 plugin_obj->remove_user();
146 // Done only once at creation
147 int PluginServer::reset_parameters()
155 lad_descriptor_function = 0;
162 lad_descriptor_function = 0;
168 start_auto = end_auto = 0;
172 realtime = multichannel = fileio = 0;
174 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_ladspa()
243 return plugin_type == PLUGIN_TYPE_LADSPA ? 1 : 0;
246 int PluginServer::is_ffmpeg()
248 return plugin_type == PLUGIN_TYPE_FFMPEG ? 1 : 0;
251 void PluginServer::set_path(const char *path)
253 delete [] this->path;
254 this->path = cstrdup(path);
257 char* PluginServer::get_path()
262 int PluginServer::get_synthesis()
268 void PluginServer::set_title(const char *string)
270 if(title) delete [] title;
271 title = cstrdup(string);
274 void PluginServer::generate_display_title(char *string)
276 char ltitle[BCTEXTLEN];
277 if(BC_Resources::locale_utf8)
278 strcpy(ltitle, _(title));
280 BC_Resources::encode(BC_Resources::encoding, 0,
281 _(title),strlen(title)+1, ltitle,BCTEXTLEN);
282 if(plugin && plugin->track)
283 sprintf(string, "%s: %s", plugin->track->title, ltitle);
285 strcpy(string, ltitle);
288 void *PluginObj::load(const char *plugin_dir, const char *path)
290 char dlpath[BCTEXTLEN], *dp = dlpath;
291 const char *cp = path;
293 const char *bp = plugin_dir;
294 while( *bp ) *dp++ = *bp++;
297 while( *cp ) *dp++ = *cp++;
299 return dlobj = load(dlpath);
302 int PluginServer::load_obj()
304 void *obj = plugin_obj->obj();
305 if( !obj ) obj =plugin_obj->load(preferences->plugin_dir, path);
309 const char *PluginServer::load_error()
311 return plugin_obj->load_error();
314 void *PluginServer::get_sym(const char *sym)
316 if( !plugin_obj->obj() ) return 0;
317 return plugin_obj->load_sym(sym);
320 // Open plugin for signal processing
321 int PluginServer::open_plugin(int master,
322 Preferences *preferences,
326 if(plugin_open) return 0;
328 this->preferences = preferences;
329 this->plugin = plugin;
331 if( plugin_type != PLUGIN_TYPE_FFMPEG && plugin_type != PLUGIN_TYPE_EXECUTABLE && !load_obj() ) {
332 // If the load failed, can't use error to detect executable
333 // because locale and language selection change the load_error()
334 // if( !strstr(string, "executable") ) { set_title(path); plugin_type = PLUGIN_TYPE_EXECUTABLE; }
335 eprintf("PluginServer::open_plugin: load_obj %s = %s\n", path, load_error());
336 return PLUGINSERVER_NOT_RECOGNIZED;
338 if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_BUILTIN ) {
340 (PluginClient* (*)(PluginServer*)) get_sym("new_plugin");
342 plugin_type = PLUGIN_TYPE_BUILTIN;
344 if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_LADSPA ) {
345 lad_descriptor_function =
346 (LADSPA_Descriptor_Function) get_sym("ladspa_descriptor");
347 if( lad_descriptor_function ) {
348 if( lad_index < 0 ) return PLUGINSERVER_IS_LAD;
349 lad_descriptor = lad_descriptor_function(lad_index);
350 if( !lad_descriptor )
351 return PLUGINSERVER_NOT_RECOGNIZED;
352 plugin_type = PLUGIN_TYPE_LADSPA;
355 if( plugin_type == PLUGIN_TYPE_UNKNOWN ) {
356 fprintf(stderr, "PluginServer::open_plugin "
357 " %d: plugin undefined in %s\n", __LINE__, path);
358 return PLUGINSERVER_NOT_RECOGNIZED;
360 switch( plugin_type ) {
361 case PLUGIN_TYPE_EXECUTABLE:
362 return PLUGINSERVER_OK;
363 case PLUGIN_TYPE_BUILTIN:
364 client = new_plugin(this);
366 case PLUGIN_TYPE_LADSPA:
367 client = new PluginAClientLAD(this);
369 case PLUGIN_TYPE_FFMPEG:
370 client = new_ffmpeg_plugin();
377 return PLUGINSERVER_NOT_RECOGNIZED;
379 // Run initialization functions
380 realtime = client->is_realtime();
381 // Don't load defaults when probing the directory.
384 client->load_defaults_xml();
386 client->load_defaults();
388 audio = client->is_audio();
389 video = client->is_video();
390 theme = client->is_theme();
391 fileio = client->is_fileio();
392 uses_gui = client->uses_gui();
393 multichannel = client->is_multichannel();
394 synthesis = client->is_synthesis();
395 transition = client->is_transition();
396 set_title(client->plugin_title());
398 //printf("PluginServer::open_plugin 2\n");
400 return PLUGINSERVER_OK;
403 int PluginServer::close_plugin()
405 if(!plugin_open) return 0;
409 // Defaults are saved in the thread.
410 // if(client->defaults) client->save_defaults();
414 // shared object is persistent since plugin deletion would unlink its own object
420 void PluginServer::client_side_close()
422 // Last command executed in client thread
424 mwindow->hide_plugin(plugin, 1);
428 prompt->lock_window();
430 prompt->unlock_window();
434 void PluginServer::render_stop()
437 client->render_stop();
440 void PluginServer::write_table(FILE *fp, const char *path, int idx, int64_t mtime)
443 fprintf(fp, "%d \"%s\" \"%s\" %jd %d %d %d %d %d %d %d %d %d %d %d\n",
444 plugin_type, path, title, mtime, idx, audio, video, theme, realtime,
445 fileio, uses_gui, multichannel, synthesis, transition, lad_index);
448 int PluginServer::scan_table(char *text, int &type, char *path, char *title, int64_t &mtime)
450 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %jd", &type, path, title, &mtime);
451 return n < 4 ? 1 : 0;
454 int PluginServer::read_table(char *text)
456 char path[BCTEXTLEN], title[BCTEXTLEN];
458 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %jd %d %d %d %d %d %d %d %d %d %d %d",
459 &plugin_type, path, title, &mtime, &dir_idx, &audio, &video, &theme, &realtime,
460 &fileio, &uses_gui, &multichannel, &synthesis, &transition, &lad_index);
461 if( n != 15 ) return 1;
466 int PluginServer::init_realtime(int realtime_sched,
467 int total_in_buffers,
471 if(!plugin_open) return 0;
473 // set for realtime priority
475 // Call start_realtime
476 this->total_in_buffers = this->total_out_buffers = total_in_buffers;
477 client->plugin_init_realtime(realtime_sched,
485 // Replaced by pull method but still needed for transitions
486 void PluginServer::process_transition(VFrame *input,
488 int64_t current_position,
491 if(!plugin_open) return;
492 PluginVClient *vclient = (PluginVClient*)client;
494 vclient->source_position = current_position;
495 vclient->source_start = 0;
496 vclient->total_len = total_len;
498 vclient->input = new VFrame*[1];
499 vclient->output = new VFrame*[1];
501 vclient->input[0] = input;
502 vclient->output[0] = output;
504 vclient->process_realtime(input, output);
506 delete [] vclient->input;
507 delete [] vclient->output;
511 void PluginServer::process_transition(Samples *input,
513 int64_t current_position,
514 int64_t fragment_size,
517 if(!plugin_open) return;
518 PluginAClient *aclient = (PluginAClient*)client;
520 aclient->source_position = current_position;
521 aclient->total_len = total_len;
522 aclient->source_start = 0;
523 aclient->process_realtime(fragment_size,
529 void PluginServer::process_buffer(VFrame **frame,
530 int64_t current_position,
535 if(!plugin_open) return;
536 PluginVClient *vclient = (PluginVClient*)client;
538 vclient->source_position = current_position;
539 vclient->total_len = total_len;
540 vclient->frame_rate = frame_rate;
541 vclient->input = new VFrame*[total_in_buffers];
542 vclient->output = new VFrame*[total_in_buffers];
543 for(int i = 0; i < total_in_buffers; i++)
545 vclient->input[i] = frame[i];
546 vclient->output[i] = frame[i];
551 vclient->source_start = (int64_t)plugin->startproject *
553 vclient->project_frame_rate;
555 vclient->direction = direction;
559 //printf("plugin=%p source_start=%ld\n", plugin, vclient->source_start);
561 vclient->begin_process_buffer();
564 vclient->process_buffer(frame, current_position, frame_rate);
568 vclient->process_buffer(frame[0], current_position, frame_rate);
570 vclient->end_process_buffer();
572 for(int i = 0; i < total_in_buffers; i++)
573 frame[i]->push_prev_effect(title);
575 delete [] vclient->input;
576 delete [] vclient->output;
582 void PluginServer::process_buffer(Samples **buffer,
583 int64_t current_position,
584 int64_t fragment_size,
589 if(!plugin_open) return;
590 PluginAClient *aclient = (PluginAClient*)client;
592 aclient->source_position = current_position;
593 aclient->total_len = total_len;
594 aclient->sample_rate = sample_rate;
597 aclient->source_start = plugin->startproject *
599 aclient->project_sample_rate;
601 aclient->direction = direction;
602 aclient->begin_process_buffer();
605 aclient->process_buffer(fragment_size,
612 aclient->process_buffer(fragment_size,
617 aclient->end_process_buffer();
621 void PluginServer::send_render_gui(void *data)
623 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
624 if(attachmentpoint) attachmentpoint->render_gui(data, this);
627 void PluginServer::send_render_gui(void *data, int size)
629 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
630 if(attachmentpoint) attachmentpoint->render_gui(data, size, this);
633 void PluginServer::render_gui(void *data)
635 if(client) client->plugin_render_gui(data);
638 void PluginServer::render_gui(void *data, int size)
640 if(client) client->plugin_render_gui(data, size);
643 MainProgressBar* PluginServer::start_progress(char *string, int64_t length)
645 mwindow->gui->lock_window();
646 MainProgressBar *result = mwindow->mainprogress->start_progress(string, length);
647 mwindow->gui->unlock_window();
651 int64_t PluginServer::get_written_samples()
653 if(!plugin_open) return 0;
654 return written_samples;
657 int64_t PluginServer::get_written_frames()
659 if(!plugin_open) return 0;
660 return written_frames;
672 // ======================= Non-realtime plugin
674 int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
676 if(!plugin_open) return 0;
678 client->start = start;
680 client->source_start = start;
681 client->total_len = end - start;
682 client->total_in_buffers = channels;
685 //printf(" source_start=%ld total_len=%ld\n", client->source_start, client->total_len);
687 return client->plugin_get_parameters();
690 int PluginServer::set_interactive()
692 if(!plugin_open) return 0;
693 client->set_interactive();
697 void PluginServer::append_module(Module *module)
699 modules->append(module);
702 void PluginServer::append_node(VirtualNode *node)
707 void PluginServer::reset_nodes()
712 int PluginServer::set_error()
718 int PluginServer::set_realtime_sched()
720 //struct sched_param params;
721 //params.sched_priority = 1;
722 //sched_setscheduler(0, SCHED_RR, ¶m);
727 int PluginServer::process_loop(VFrame **buffers, int64_t &write_length)
729 if(!plugin_open) return 1;
730 return client->plugin_process_loop(buffers, write_length);
733 int PluginServer::process_loop(Samples **buffers, int64_t &write_length)
735 if(!plugin_open) return 1;
736 return client->plugin_process_loop(buffers, write_length);
740 int PluginServer::start_loop(int64_t start,
745 if(!plugin_open) return 0;
746 client->plugin_start_loop(start, end, buffer_size, total_buffers);
750 int PluginServer::stop_loop()
752 if(!plugin_open) return 0;
753 return client->plugin_stop_loop();
756 int PluginServer::read_frame(VFrame *buffer,
758 int64_t start_position)
760 ((VModule*)modules->values[channel])->render(buffer,
763 mwindow->edl->session->frame_rate,
769 int PluginServer::read_samples(Samples *buffer,
772 int64_t start_position,
775 // len is now in buffer
776 if(!multichannel) channel = 0;
778 if(nodes->total > channel)
779 return ((VirtualANode*)nodes->values[channel])->read_data(buffer,
784 if(modules->total > channel)
785 return ((AModule*)modules->values[channel])->render(buffer,
793 printf("PluginServer::read_samples no object available for channel=%d\n",
801 int PluginServer::read_samples(Samples *buffer,
803 int64_t start_position,
806 // total_samples is now set in buffer
807 ((AModule*)modules->values[channel])->render(buffer,
811 mwindow->edl->session->sample_rate,
816 int PluginServer::read_frame(VFrame *buffer,
818 int64_t start_position,
822 // Data source depends on whether we're part of a virtual console or a
826 // If we're a VirtualNode, read_data in the virtual plugin node handles
827 // backward propogation and produces the data.
828 // If we're a Module, render in the module produces the data.
832 if(!multichannel) channel = 0;
834 // Push our name on the next effect stack
835 buffer->push_next_effect(title);
836 //printf("PluginServer::read_frame %p\n", buffer);
837 //buffer->dump_stacks();
839 if(nodes->total > channel)
841 //printf("PluginServer::read_frame %d\n", __LINE__);
842 result = ((VirtualVNode*)nodes->values[channel])->read_data(buffer,
848 if(modules->total > channel)
850 //printf("PluginServer::read_frame %d\n", __LINE__);
851 result = ((VModule*)modules->values[channel])->render(buffer,
862 printf("PluginServer::read_frame no object available for channel=%d\n",
866 // Pop our name from the next effect stack
867 buffer->pop_next_effect();
892 int PluginServer::get_gui_status()
895 return plugin->show ? GUI_ON : GUI_OFF;
900 void PluginServer::raise_window()
902 if(!plugin_open) return;
903 client->raise_window();
906 void PluginServer::show_gui()
908 if(!plugin_open) return;
909 if(plugin) client->total_len = plugin->length;
910 if(plugin) client->source_start = plugin->startproject;
913 client->source_position = Units::to_int64(
914 mwindow->edl->local_session->get_selectionstart(1) *
915 mwindow->edl->session->frame_rate);
920 client->source_position = Units::to_int64(
921 mwindow->edl->local_session->get_selectionstart(1) *
922 mwindow->edl->session->sample_rate);
925 client->update_display_title();
929 void PluginServer::hide_gui()
931 if(!plugin_open) return;
932 if(client->defaults) client->save_defaults();
936 void PluginServer::update_gui()
938 if(!plugin_open || !plugin) return;
940 client->total_len = plugin->length;
941 client->source_start = plugin->startproject;
945 client->source_position = Units::to_int64(
946 mwindow->edl->local_session->get_selectionstart(1) *
947 mwindow->edl->session->frame_rate);
952 client->source_position = Units::to_int64(
953 mwindow->edl->local_session->get_selectionstart(1) *
954 mwindow->edl->session->sample_rate);
957 client->plugin_update_gui();
960 void PluginServer::update_title()
962 if(!plugin_open) return;
964 client->update_display_title();
968 int PluginServer::set_string(char *string)
970 if(!plugin_open) return 0;
972 client->set_string_client(string);
976 int PluginServer::gui_open()
978 if(attachmentpoint) return attachmentpoint->gui_open();
982 void PluginServer::set_use_opengl(int value, VideoDevice *vdevice)
984 this->use_opengl = value;
985 this->vdevice = vdevice;
988 int PluginServer::get_use_opengl()
994 void PluginServer::run_opengl(PluginClient *plugin_client)
997 ((VDeviceX11*)vdevice->get_output_base())->run_plugin(plugin_client);
1000 // ============================= queries
1002 void PluginServer::get_defaults_path(char *path)
1004 // Get plugin name from path
1005 char *ptr1 = strrchr(get_path(), '/');
1006 char *ptr2 = strrchr(get_path(), '.');
1007 if(!ptr1) ptr1 = get_path();
1008 if(!ptr2) ptr2 = get_path() + strlen(get_path());
1009 char string2[BCTEXTLEN], *ptr3 = string2;
1010 while( ptr1 < ptr2 ) *ptr3++ = *ptr1++;
1012 sprintf(path, "%s/%s.xml", File::get_config_path(), string2);
1015 void PluginServer::save_defaults()
1017 if(client) client->save_defaults();
1020 int PluginServer::get_samplerate()
1022 if(!plugin_open) return 0;
1025 return client->get_samplerate();
1029 return mwindow->edl->session->sample_rate;
1032 printf("PluginServer::get_samplerate audio and mwindow == NULL\n");
1038 double PluginServer::get_framerate()
1040 if(!plugin_open) return 0;
1043 return client->get_framerate();
1047 return mwindow->edl->session->frame_rate;
1050 printf("PluginServer::get_framerate video and mwindow == NULL\n");
1055 int PluginServer::get_project_samplerate()
1058 return mwindow->edl->session->sample_rate;
1061 return edl->session->sample_rate;
1064 printf("PluginServer::get_project_samplerate mwindow and edl are NULL.\n");
1069 double PluginServer::get_project_framerate()
1072 return mwindow->edl->session->frame_rate;
1075 return edl->session->frame_rate;
1078 printf("PluginServer::get_project_framerate mwindow and edl are NULL.\n");
1085 int PluginServer::detach_buffers()
1087 ring_buffers_out.remove_all();
1088 offset_out_render.remove_all();
1089 double_buffer_out_render.remove_all();
1090 realtime_out_size.remove_all();
1092 ring_buffers_in.remove_all();
1093 offset_in_render.remove_all();
1094 double_buffer_in_render.remove_all();
1095 realtime_in_size.remove_all();
1097 out_buffer_size = 0;
1099 total_out_buffers = 0;
1101 total_in_buffers = 0;
1105 int PluginServer::arm_buffer(int buffer_number,
1108 int double_buffer_in,
1109 int double_buffer_out)
1111 offset_in_render.values[buffer_number] = offset_in;
1112 offset_out_render.values[buffer_number] = offset_out;
1113 double_buffer_in_render.values[buffer_number] = double_buffer_in;
1114 double_buffer_out_render.values[buffer_number] = double_buffer_out;
1119 int PluginServer::set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse)
1121 this->autos = autos;
1122 this->start_auto = start_auto;
1123 this->end_auto = end_auto;
1124 this->reverse = reverse;
1130 void PluginServer::save_data(KeyFrame *keyframe)
1132 if(!plugin_open) return;
1133 client->save_data(keyframe);
1136 KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
1138 KeyFrame *result = 0;
1140 result = plugin->get_prev_keyframe(position, client->direction);
1146 KeyFrame* PluginServer::get_next_keyframe(int64_t position)
1148 KeyFrame *result = 0;
1150 result = plugin->get_next_keyframe(position, client->direction);
1157 KeyFrame* PluginServer::get_keyframe()
1160 // Realtime plugin case
1161 return plugin->get_keyframe();
1163 // Rendered plugin case
1168 void PluginServer::apply_keyframe(KeyFrame *src)
1172 keyframe->copy_data(src);
1177 plugin->keyframes->update_parameter(src);
1185 void PluginServer::get_camera(float *x, float *y, float *z,
1186 int64_t position, int direction)
1188 plugin->track->automation->get_camera(x, y, z, position, direction);
1191 void PluginServer::get_projector(float *x, float *y, float *z,
1192 int64_t position, int direction)
1194 plugin->track->automation->get_projector(x, y, z, position, direction);
1198 int PluginServer::get_interpolation_type()
1200 return plugin->edl->session->interpolation_type;
1203 Theme* PluginServer::new_theme()
1207 return client->new_theme();
1213 Theme* PluginServer::get_theme()
1215 if(mwindow) return mwindow->theme;
1216 printf("PluginServer::get_theme mwindow not set\n");
1221 int PluginServer::get_theme_png_path(char *png_path, const char *theme_dir)
1223 char *bp = strrchr(path, '/');
1224 if( !bp ) bp = path; else ++bp;
1225 char *sp = strrchr(bp,'.');
1226 if( !sp ) sp = bp + strlen(bp);
1227 char *cp = png_path, *dp = bp;
1228 cp += sprintf(cp,"%s/%s/", mwindow->preferences->plugin_dir, theme_dir);
1229 while( dp < sp ) *cp++ = *dp++;
1232 if( stat(png_path, &st) ) return 0;
1233 if( !S_ISREG(st.st_mode) ) return 0;
1234 if( st.st_size == 0 ) return 0;
1238 int PluginServer::get_theme_png_path(char *png_path, Theme *theme)
1240 char *bp = strrchr(theme->path, '/');
1241 if( !bp ) bp = theme->path; else ++bp;
1242 char *sp = strrchr(bp,'.');
1243 if( !sp || ( strcmp(sp, ".plugin") && strcmp(sp,".so") ) ) return 0;
1244 char theme_dir[BCTEXTLEN], *cp = theme_dir;
1245 while( bp < sp ) *cp++ = *bp++;
1247 return get_theme_png_path(png_path, theme_dir);
1250 int PluginServer::get_plugin_png_path(char *png_path)
1252 int len = get_theme_png_path(png_path, mwindow->theme);
1254 len = get_theme_png_path(png_path, "picon");
1258 VFrame *PluginServer::get_plugin_images()
1260 char png_path[BCTEXTLEN];
1261 if( !get_plugin_png_path(png_path) ) return 0;
1262 return VFramePng::vframe_png(png_path,0,0);
1265 VFrame *PluginServer::get_picon()
1268 picon = get_plugin_images();
1272 // Called when plugin interface is tweeked
1273 void PluginServer::sync_parameters()
1275 if(video) mwindow->restart_brender();
1276 mwindow->sync_parameters();
1277 mwindow->update_keyframe_guis();
1278 if(mwindow->edl->session->auto_conf->plugins)
1280 mwindow->gui->lock_window("PluginServer::sync_parameters");
1281 mwindow->gui->draw_overlays(1);
1282 mwindow->gui->unlock_window();
1288 void PluginServer::dump(FILE *fp)
1290 fprintf(fp," PluginServer %d %p %s %s %d\n",
1291 __LINE__, this, path, title, realtime);