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"
32 #include "floatautos.h"
33 #include "keyframes.h"
34 #include "localsession.h"
35 #include "mainerror.h"
36 #include "mainprogress.h"
37 #include "menueffects.h"
39 #include "mwindowgui.h"
40 #include "playbackengine.h"
42 #include "pluginaclient.h"
43 #include "pluginaclientlad.h"
44 #include "pluginfclient.h"
45 #include "pluginclient.h"
46 #include "plugincommands.h"
47 #include "pluginserver.h"
48 #include "pluginvclient.h"
49 #include "preferences.h"
52 #include "mainsession.h"
53 #include "trackcanvas.h"
54 #include "transportque.h"
55 #include "vdevicex11.h"
57 #include "videodevice.h"
58 #include "virtualanode.h"
59 #include "virtualvnode.h"
67 #include <sys/types.h>
73 void PluginServer::init()
76 this->plugin_type = PLUGIN_TYPE_UNKNOWN;
77 plugin_obj = new PluginObj();
78 modules = new ArrayList<Module*>;
79 nodes = new ArrayList<VirtualNode*>;
82 PluginServer::PluginServer()
87 PluginServer::PluginServer(MWindow *mwindow, char *path, int type)
89 char fpath[BCTEXTLEN];
91 this->plugin_type = type;
92 this->mwindow = mwindow;
93 if( type == PLUGIN_TYPE_FFMPEG ) {
94 ff_name = cstrdup(path);
95 sprintf(fpath, "ff_%s", path);
101 PluginServer::PluginServer(PluginServer &that)
104 plugin_type = that.plugin_type;
105 plugin_obj = that.plugin_obj;
106 plugin_obj->add_user();
107 title = !that.title ? 0 : cstrdup(that.title);
108 path = !that.path ? 0 : cstrdup(that.path);
109 ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name);
110 modules = new ArrayList<Module*>;
111 nodes = new ArrayList<VirtualNode*>;
113 attachment = that.attachment;
114 realtime = that.realtime;
115 multichannel = that.multichannel;
116 preferences = that.preferences;
117 synthesis = that.synthesis;
121 fileio = that.fileio;
122 uses_gui = that.uses_gui;
123 mwindow = that.mwindow;
124 keyframe = that.keyframe;
125 new_plugin = that.new_plugin;
127 lad_descriptor = that.lad_descriptor;
128 lad_descriptor_function = that.lad_descriptor_function;
129 lad_index = that.lad_index;
132 PluginServer::~PluginServer()
141 plugin_obj->remove_user();
144 // Done only once at creation
145 int PluginServer::reset_parameters()
157 audio = video = theme = 0;
160 realtime = multichannel = fileio = 0;
162 start_auto = end_auto = 0;
173 lad_descriptor_function = 0;
178 // Done every time the plugin is opened or closed
179 int PluginServer::cleanup_plugin()
181 in_buffer_size = out_buffer_size = 0;
182 total_in_buffers = total_out_buffers = 0;
187 written_samples = written_frames = 0;
194 void PluginServer::set_mwindow(MWindow *mwindow)
196 this->mwindow = mwindow;
199 void PluginServer::set_attachmentpoint(AttachmentPoint *attachmentpoint)
201 this->attachmentpoint = attachmentpoint;
204 void PluginServer::set_keyframe(KeyFrame *keyframe)
206 this->keyframe = keyframe;
209 void PluginServer::set_prompt(MenuEffectPrompt *prompt)
211 this->prompt = prompt;
214 void PluginServer::set_lad_index(int i)
219 int PluginServer::get_lad_index()
221 return this->lad_index;
224 int PluginServer::is_ladspa()
226 return plugin_type == PLUGIN_TYPE_LADSPA ? 1 : 0;
229 int PluginServer::is_ffmpeg()
231 return plugin_type == PLUGIN_TYPE_FFMPEG ? 1 : 0;
234 void PluginServer::set_path(const char *path)
236 delete [] this->path;
237 this->path = cstrdup(path);
240 char* PluginServer::get_path()
245 int PluginServer::get_synthesis()
251 void PluginServer::set_title(const char *string)
253 if(title) delete [] title;
254 title = cstrdup(string);
257 void PluginServer::generate_display_title(char *string)
259 char ltitle[BCTEXTLEN];
260 if(BC_Resources::locale_utf8)
261 strcpy(ltitle, _(title));
263 BC_Resources::encode(BC_Resources::encoding, 0,
264 _(title),strlen(title)+1, ltitle,BCTEXTLEN);
265 if(plugin && plugin->track)
266 sprintf(string, "%s: %s", plugin->track->title, ltitle);
268 strcpy(string, ltitle);
271 void *PluginObj::load(const char *plugin_dir, const char *path)
273 char dlpath[BCTEXTLEN], *dp = dlpath;
274 const char *cp = path;
276 const char *bp = plugin_dir;
277 while( *bp ) *dp++ = *bp++;
280 while( *cp ) *dp++ = *cp++;
282 return dlobj = load(dlpath);
285 int PluginServer::load_obj()
287 void *obj = plugin_obj->obj();
288 if( !obj ) obj =plugin_obj->load(preferences->plugin_dir, path);
292 const char *PluginServer::load_error()
294 return plugin_obj->load_error();
297 void *PluginServer::get_sym(const char *sym)
299 if( !plugin_obj->obj() ) return 0;
300 return plugin_obj->load_sym(sym);
303 // Open plugin for signal processing
304 int PluginServer::open_plugin(int master,
305 Preferences *preferences,
309 if(plugin_open) return 0;
311 this->preferences = preferences;
312 this->plugin = plugin;
314 if( plugin_type != PLUGIN_TYPE_FFMPEG && plugin_type != PLUGIN_TYPE_EXECUTABLE && !load_obj() ) {
315 // If the load failed it may still be an executable tool for a specific
316 // file format, in which case we just store the path.
318 char string[BCTEXTLEN];
319 strcpy(string, load_error());
320 if( !strstr(string, "executable") ) {
321 eprintf("PluginServer::open_plugin: load_obj %s = %s\n", path, string);
322 return PLUGINSERVER_NOT_RECOGNIZED;
324 plugin_type = PLUGIN_TYPE_EXECUTABLE;
326 if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_BUILTIN ) {
328 (PluginClient* (*)(PluginServer*)) get_sym("new_plugin");
330 plugin_type = PLUGIN_TYPE_BUILTIN;
332 if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_LADSPA ) {
333 lad_descriptor_function =
334 (LADSPA_Descriptor_Function) get_sym("ladspa_descriptor");
335 if( lad_descriptor_function ) {
336 if( lad_index < 0 ) return PLUGINSERVER_IS_LAD;
337 lad_descriptor = lad_descriptor_function(lad_index);
338 if( !lad_descriptor )
339 return PLUGINSERVER_NOT_RECOGNIZED;
340 plugin_type = PLUGIN_TYPE_LADSPA;
343 if( plugin_type == PLUGIN_TYPE_UNKNOWN ) {
344 fprintf(stderr, "PluginServer::open_plugin "
345 " %d: plugin undefined in %s\n", __LINE__, path);
346 return PLUGINSERVER_NOT_RECOGNIZED;
348 switch( plugin_type ) {
349 case PLUGIN_TYPE_BUILTIN:
350 client = new_plugin(this);
352 case PLUGIN_TYPE_LADSPA:
353 client = new PluginAClientLAD(this);
355 case PLUGIN_TYPE_FFMPEG:
356 client = new_ffmpeg_plugin();
363 return PLUGINSERVER_NOT_RECOGNIZED;
365 // Run initialization functions
366 realtime = client->is_realtime();
367 // Don't load defaults when probing the directory.
370 client->load_defaults_xml();
372 client->load_defaults();
374 audio = client->is_audio();
375 video = client->is_video();
376 theme = client->is_theme();
377 fileio = client->is_fileio();
378 uses_gui = client->uses_gui();
379 multichannel = client->is_multichannel();
380 synthesis = client->is_synthesis();
381 transition = client->is_transition();
382 set_title(client->plugin_title());
384 //printf("PluginServer::open_plugin 2\n");
386 return PLUGINSERVER_OK;
389 int PluginServer::close_plugin()
391 if(!plugin_open) return 0;
395 // Defaults are saved in the thread.
396 // if(client->defaults) client->save_defaults();
400 // shared object is persistent since plugin deletion would unlink its own object
406 void PluginServer::client_side_close()
408 // Last command executed in client thread
410 mwindow->hide_plugin(plugin, 1);
414 prompt->lock_window();
416 prompt->unlock_window();
420 void PluginServer::render_stop()
423 client->render_stop();
426 void PluginServer::write_table(FILE *fp, int idx)
429 fprintf(fp, "%d \"%s\" \"%s\" %d %d %d %d %d %d %d %d %d %d %d\n",
430 plugin_type, path, title, idx, audio, video, theme, realtime,
431 fileio, uses_gui, multichannel, synthesis, transition, lad_index);
434 int PluginServer::scan_table(char *text, int &type, char *path, char *title)
436 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\"", &type, path, title);
437 return n < 3 ? 1 : 0;
440 int PluginServer::read_table(char *text)
442 char path[BCTEXTLEN], title[BCTEXTLEN];
443 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %d %d %d %d %d %d %d %d %d %d %d",
444 &plugin_type, path, title, &dir_idx, &audio, &video, &theme, &realtime,
445 &fileio, &uses_gui, &multichannel, &synthesis, &transition, &lad_index);
446 if( n != 14 ) return 1;
452 int PluginServer::init_realtime(int realtime_sched,
453 int total_in_buffers,
457 if(!plugin_open) return 0;
459 // set for realtime priority
461 // Call start_realtime
462 this->total_in_buffers = this->total_out_buffers = total_in_buffers;
463 client->plugin_init_realtime(realtime_sched,
471 // Replaced by pull method but still needed for transitions
472 void PluginServer::process_transition(VFrame *input,
474 int64_t current_position,
477 if(!plugin_open) return;
478 PluginVClient *vclient = (PluginVClient*)client;
480 vclient->source_position = current_position;
481 vclient->source_start = 0;
482 vclient->total_len = total_len;
484 vclient->input = new VFrame*[1];
485 vclient->output = new VFrame*[1];
487 vclient->input[0] = input;
488 vclient->output[0] = output;
490 vclient->process_realtime(input, output);
492 delete [] vclient->input;
493 delete [] vclient->output;
497 void PluginServer::process_transition(Samples *input,
499 int64_t current_position,
500 int64_t fragment_size,
503 if(!plugin_open) return;
504 PluginAClient *aclient = (PluginAClient*)client;
506 aclient->source_position = current_position;
507 aclient->total_len = total_len;
508 aclient->source_start = 0;
509 aclient->process_realtime(fragment_size,
515 void PluginServer::process_buffer(VFrame **frame,
516 int64_t current_position,
521 if(!plugin_open) return;
522 PluginVClient *vclient = (PluginVClient*)client;
524 vclient->source_position = current_position;
525 vclient->total_len = total_len;
526 vclient->frame_rate = frame_rate;
527 vclient->input = new VFrame*[total_in_buffers];
528 vclient->output = new VFrame*[total_in_buffers];
529 for(int i = 0; i < total_in_buffers; i++)
531 vclient->input[i] = frame[i];
532 vclient->output[i] = frame[i];
537 vclient->source_start = (int64_t)plugin->startproject *
539 vclient->project_frame_rate;
541 vclient->direction = direction;
545 //printf("plugin=%p source_start=%ld\n", plugin, vclient->source_start);
547 vclient->begin_process_buffer();
550 vclient->process_buffer(frame, current_position, frame_rate);
554 vclient->process_buffer(frame[0], current_position, frame_rate);
556 vclient->end_process_buffer();
558 for(int i = 0; i < total_in_buffers; i++)
559 frame[i]->push_prev_effect(title);
561 delete [] vclient->input;
562 delete [] vclient->output;
568 void PluginServer::process_buffer(Samples **buffer,
569 int64_t current_position,
570 int64_t fragment_size,
575 if(!plugin_open) return;
576 PluginAClient *aclient = (PluginAClient*)client;
578 aclient->source_position = current_position;
579 aclient->total_len = total_len;
580 aclient->sample_rate = sample_rate;
583 aclient->source_start = plugin->startproject *
585 aclient->project_sample_rate;
587 aclient->direction = direction;
588 aclient->begin_process_buffer();
591 aclient->process_buffer(fragment_size,
598 aclient->process_buffer(fragment_size,
603 aclient->end_process_buffer();
607 void PluginServer::send_render_gui(void *data)
609 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
610 if(attachmentpoint) attachmentpoint->render_gui(data, this);
613 void PluginServer::send_render_gui(void *data, int size)
615 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
616 if(attachmentpoint) attachmentpoint->render_gui(data, size, this);
619 void PluginServer::render_gui(void *data)
621 if(client) client->plugin_render_gui(data);
624 void PluginServer::render_gui(void *data, int size)
626 if(client) client->plugin_render_gui(data, size);
629 MainProgressBar* PluginServer::start_progress(char *string, int64_t length)
631 mwindow->gui->lock_window();
632 MainProgressBar *result = mwindow->mainprogress->start_progress(string, length);
633 mwindow->gui->unlock_window();
637 int64_t PluginServer::get_written_samples()
639 if(!plugin_open) return 0;
640 return written_samples;
643 int64_t PluginServer::get_written_frames()
645 if(!plugin_open) return 0;
646 return written_frames;
658 // ======================= Non-realtime plugin
660 int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
662 if(!plugin_open) return 0;
664 client->start = start;
666 client->source_start = start;
667 client->total_len = end - start;
668 client->total_in_buffers = channels;
671 //printf(" source_start=%ld total_len=%ld\n", client->source_start, client->total_len);
673 return client->plugin_get_parameters();
676 int PluginServer::set_interactive()
678 if(!plugin_open) return 0;
679 client->set_interactive();
683 void PluginServer::append_module(Module *module)
685 modules->append(module);
688 void PluginServer::append_node(VirtualNode *node)
693 void PluginServer::reset_nodes()
698 int PluginServer::set_error()
704 int PluginServer::set_realtime_sched()
706 //struct sched_param params;
707 //params.sched_priority = 1;
708 //sched_setscheduler(0, SCHED_RR, ¶m);
713 int PluginServer::process_loop(VFrame **buffers, int64_t &write_length)
715 if(!plugin_open) return 1;
716 return client->plugin_process_loop(buffers, write_length);
719 int PluginServer::process_loop(Samples **buffers, int64_t &write_length)
721 if(!plugin_open) return 1;
722 return client->plugin_process_loop(buffers, write_length);
726 int PluginServer::start_loop(int64_t start,
731 if(!plugin_open) return 0;
732 client->plugin_start_loop(start, end, buffer_size, total_buffers);
736 int PluginServer::stop_loop()
738 if(!plugin_open) return 0;
739 return client->plugin_stop_loop();
742 int PluginServer::read_frame(VFrame *buffer,
744 int64_t start_position)
746 ((VModule*)modules->values[channel])->render(buffer,
749 mwindow->edl->session->frame_rate,
755 int PluginServer::read_samples(Samples *buffer,
758 int64_t start_position,
761 // len is now in buffer
762 if(!multichannel) channel = 0;
764 if(nodes->total > channel)
765 return ((VirtualANode*)nodes->values[channel])->read_data(buffer,
770 if(modules->total > channel)
771 return ((AModule*)modules->values[channel])->render(buffer,
779 printf("PluginServer::read_samples no object available for channel=%d\n",
787 int PluginServer::read_samples(Samples *buffer,
789 int64_t start_position,
792 // total_samples is now set in buffer
793 ((AModule*)modules->values[channel])->render(buffer,
797 mwindow->edl->session->sample_rate,
802 int PluginServer::read_frame(VFrame *buffer,
804 int64_t start_position,
808 // Data source depends on whether we're part of a virtual console or a
812 // If we're a VirtualNode, read_data in the virtual plugin node handles
813 // backward propogation and produces the data.
814 // If we're a Module, render in the module produces the data.
818 if(!multichannel) channel = 0;
820 // Push our name on the next effect stack
821 buffer->push_next_effect(title);
822 //printf("PluginServer::read_frame %p\n", buffer);
823 //buffer->dump_stacks();
825 if(nodes->total > channel)
827 //printf("PluginServer::read_frame %d\n", __LINE__);
828 result = ((VirtualVNode*)nodes->values[channel])->read_data(buffer,
834 if(modules->total > channel)
836 //printf("PluginServer::read_frame %d\n", __LINE__);
837 result = ((VModule*)modules->values[channel])->render(buffer,
848 printf("PluginServer::read_frame no object available for channel=%d\n",
852 // Pop our name from the next effect stack
853 buffer->pop_next_effect();
878 int PluginServer::get_gui_status()
881 return plugin->show ? GUI_ON : GUI_OFF;
886 void PluginServer::raise_window()
888 if(!plugin_open) return;
889 client->raise_window();
892 void PluginServer::show_gui()
894 if(!plugin_open) return;
895 if(plugin) client->total_len = plugin->length;
896 if(plugin) client->source_start = plugin->startproject;
899 client->source_position = Units::to_int64(
900 mwindow->edl->local_session->get_selectionstart(1) *
901 mwindow->edl->session->frame_rate);
906 client->source_position = Units::to_int64(
907 mwindow->edl->local_session->get_selectionstart(1) *
908 mwindow->edl->session->sample_rate);
911 client->update_display_title();
915 void PluginServer::hide_gui()
917 if(!plugin_open) return;
918 if(client->defaults) client->save_defaults();
922 void PluginServer::update_gui()
924 if(!plugin_open || !plugin) return;
926 client->total_len = plugin->length;
927 client->source_start = plugin->startproject;
931 client->source_position = Units::to_int64(
932 mwindow->edl->local_session->get_selectionstart(1) *
933 mwindow->edl->session->frame_rate);
938 client->source_position = Units::to_int64(
939 mwindow->edl->local_session->get_selectionstart(1) *
940 mwindow->edl->session->sample_rate);
943 client->plugin_update_gui();
946 void PluginServer::update_title()
948 if(!plugin_open) return;
950 client->update_display_title();
954 int PluginServer::set_string(char *string)
956 if(!plugin_open) return 0;
958 client->set_string_client(string);
962 int PluginServer::gui_open()
964 if(attachmentpoint) return attachmentpoint->gui_open();
968 void PluginServer::set_use_opengl(int value, VideoDevice *vdevice)
970 this->use_opengl = value;
971 this->vdevice = vdevice;
974 int PluginServer::get_use_opengl()
980 void PluginServer::run_opengl(PluginClient *plugin_client)
983 ((VDeviceX11*)vdevice->get_output_base())->run_plugin(plugin_client);
986 // ============================= queries
988 void PluginServer::get_defaults_path(char *path)
990 // Get plugin name from path
991 char *ptr1 = strrchr(get_path(), '/');
992 char *ptr2 = strrchr(get_path(), '.');
993 if(!ptr1) ptr1 = get_path();
994 if(!ptr2) ptr2 = get_path() + strlen(get_path());
995 char string2[BCTEXTLEN];
996 char *ptr3 = string2;
1002 sprintf(path, "%s%s.xml", BCASTDIR, string2);
1005 void PluginServer::save_defaults()
1007 if(client) client->save_defaults();
1010 int PluginServer::get_samplerate()
1012 if(!plugin_open) return 0;
1015 return client->get_samplerate();
1019 return mwindow->edl->session->sample_rate;
1022 printf("PluginServer::get_samplerate audio and mwindow == NULL\n");
1028 double PluginServer::get_framerate()
1030 if(!plugin_open) return 0;
1033 return client->get_framerate();
1037 return mwindow->edl->session->frame_rate;
1040 printf("PluginServer::get_framerate video and mwindow == NULL\n");
1045 int PluginServer::get_project_samplerate()
1048 return mwindow->edl->session->sample_rate;
1051 return edl->session->sample_rate;
1054 printf("PluginServer::get_project_samplerate mwindow and edl are NULL.\n");
1059 double PluginServer::get_project_framerate()
1062 return mwindow->edl->session->frame_rate;
1065 return edl->session->frame_rate;
1068 printf("PluginServer::get_project_framerate mwindow and edl are NULL.\n");
1075 int PluginServer::detach_buffers()
1077 ring_buffers_out.remove_all();
1078 offset_out_render.remove_all();
1079 double_buffer_out_render.remove_all();
1080 realtime_out_size.remove_all();
1082 ring_buffers_in.remove_all();
1083 offset_in_render.remove_all();
1084 double_buffer_in_render.remove_all();
1085 realtime_in_size.remove_all();
1087 out_buffer_size = 0;
1089 total_out_buffers = 0;
1091 total_in_buffers = 0;
1095 int PluginServer::arm_buffer(int buffer_number,
1098 int double_buffer_in,
1099 int double_buffer_out)
1101 offset_in_render.values[buffer_number] = offset_in;
1102 offset_out_render.values[buffer_number] = offset_out;
1103 double_buffer_in_render.values[buffer_number] = double_buffer_in;
1104 double_buffer_out_render.values[buffer_number] = double_buffer_out;
1109 int PluginServer::set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse)
1111 this->autos = autos;
1112 this->start_auto = start_auto;
1113 this->end_auto = end_auto;
1114 this->reverse = reverse;
1120 void PluginServer::save_data(KeyFrame *keyframe)
1122 if(!plugin_open) return;
1123 client->save_data(keyframe);
1126 KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
1128 KeyFrame *result = 0;
1130 result = plugin->get_prev_keyframe(position, client->direction);
1136 KeyFrame* PluginServer::get_next_keyframe(int64_t position)
1138 KeyFrame *result = 0;
1140 result = plugin->get_next_keyframe(position, client->direction);
1147 KeyFrame* PluginServer::get_keyframe()
1150 // Realtime plugin case
1151 return plugin->get_keyframe();
1153 // Rendered plugin case
1158 void PluginServer::apply_keyframe(KeyFrame *src)
1162 keyframe->copy_data(src);
1167 plugin->keyframes->update_parameter(src);
1175 void PluginServer::get_camera(float *x, float *y, float *z,
1176 int64_t position, int direction)
1178 plugin->track->automation->get_camera(x, y, z, position, direction);
1181 void PluginServer::get_projector(float *x, float *y, float *z,
1182 int64_t position, int direction)
1184 plugin->track->automation->get_projector(x, y, z, position, direction);
1188 int PluginServer::get_interpolation_type()
1190 return plugin->edl->session->interpolation_type;
1193 Theme* PluginServer::new_theme()
1197 return client->new_theme();
1203 Theme* PluginServer::get_theme()
1205 if(mwindow) return mwindow->theme;
1206 printf("PluginServer::get_theme mwindow not set\n");
1211 char *PluginServer::get_plugin_png_path(char *png_path)
1213 char *bp = strrchr(path, '/'), *cp = png_path;
1214 if( !bp ) bp = path; else ++bp;
1215 char *sp = strrchr(bp,'.');
1216 if( !sp || ( strcmp(sp, ".plugin") && strcmp(sp,".so") ) ) return 0;
1217 cp += sprintf(cp,"%s/picons/", mwindow->preferences->plugin_dir);
1218 while( bp < sp ) *cp++ = *bp++;
1223 VFrame *PluginServer::get_plugin_images()
1225 char png_path[BCTEXTLEN];
1226 if( !get_plugin_png_path(png_path) ) return 0;
1228 if( stat(png_path, &st) ) return 0;
1229 if( !S_ISREG(st.st_mode) ) return 0;
1230 if( st.st_size == 0 ) return 0;
1231 unsigned len = st.st_size;
1232 int ret = 0, w = 0, h = 0;
1233 unsigned char *bfr = 0;
1234 int fd = ::open(png_path, O_RDONLY);
1235 if( fd < 0 ) ret = 1;
1237 bfr = (unsigned char *) ::mmap (NULL, len, PROT_READ, MAP_SHARED, fd, 0);
1238 if( bfr == MAP_FAILED ) ret = 1;
1242 double scale = BC_WindowBase::get_resources()->icon_scale;
1243 vframe = new VFramePng(bfr, st.st_size, scale, scale);
1244 if( (w=vframe->get_w()) <= 0 || (h=vframe->get_h()) <= 0 ||
1245 vframe->get_data() == 0 ) ret = 1;
1247 if( bfr && bfr != MAP_FAILED ) ::munmap(bfr, len);
1248 if( fd >= 0 ) ::close(fd);
1249 if( ret ) { delete vframe; vframe = 0; }
1253 VFrame *PluginServer::get_picon()
1256 picon = get_plugin_images();
1260 // Called when plugin interface is tweeked
1261 void PluginServer::sync_parameters()
1263 if(video) mwindow->restart_brender();
1264 mwindow->sync_parameters();
1265 mwindow->update_keyframe_guis();
1266 if(mwindow->edl->session->auto_conf->plugins)
1268 mwindow->gui->lock_window("PluginServer::sync_parameters");
1269 mwindow->gui->draw_overlays(1);
1270 mwindow->gui->unlock_window();
1276 void PluginServer::dump(FILE *fp)
1278 fprintf(fp," PluginServer %d %p %s %s %d\n",
1279 __LINE__, this, path, title, realtime);