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 modules = new ArrayList<Module*>;
78 nodes = new ArrayList<VirtualNode*>;
81 PluginServer::PluginServer()
86 PluginServer::PluginServer(MWindow *mwindow, char *path, int type)
88 char fpath[BCTEXTLEN];
90 this->plugin_type = type;
91 this->mwindow = mwindow;
92 if( type == PLUGIN_TYPE_FFMPEG ) {
93 ff_name = cstrdup(path);
94 sprintf(fpath, "ff_%s", path);
100 PluginServer::PluginServer(PluginServer &that)
103 plugin_type = that.plugin_type;
104 title = !that.title ? 0 : cstrdup(that.title);
105 path = !that.path ? 0 : cstrdup(that.path);
106 ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name);
107 modules = new ArrayList<Module*>;
108 nodes = new ArrayList<VirtualNode*>;
110 attachment = that.attachment;
111 realtime = that.realtime;
112 multichannel = that.multichannel;
113 preferences = that.preferences;
114 synthesis = that.synthesis;
118 fileio = that.fileio;
119 uses_gui = that.uses_gui;
120 mwindow = that.mwindow;
121 keyframe = that.keyframe;
122 new_plugin = that.new_plugin;
124 lad_descriptor = that.lad_descriptor;
125 lad_descriptor_function = that.lad_descriptor_function;
126 lad_index = that.lad_index;
129 PluginServer::~PluginServer()
140 // Done only once at creation
141 int PluginServer::reset_parameters()
154 audio = video = theme = 0;
157 realtime = multichannel = fileio = 0;
159 start_auto = end_auto = 0;
170 lad_descriptor_function = 0;
175 // Done every time the plugin is opened or closed
176 int PluginServer::cleanup_plugin()
178 in_buffer_size = out_buffer_size = 0;
179 total_in_buffers = total_out_buffers = 0;
184 written_samples = written_frames = 0;
191 void PluginServer::set_mwindow(MWindow *mwindow)
193 this->mwindow = mwindow;
196 void PluginServer::set_attachmentpoint(AttachmentPoint *attachmentpoint)
198 this->attachmentpoint = attachmentpoint;
201 void PluginServer::set_keyframe(KeyFrame *keyframe)
203 this->keyframe = keyframe;
206 void PluginServer::set_prompt(MenuEffectPrompt *prompt)
208 this->prompt = prompt;
211 void PluginServer::set_lad_index(int i)
216 int PluginServer::get_lad_index()
218 return this->lad_index;
221 int PluginServer::is_ladspa()
223 return plugin_type == PLUGIN_TYPE_LADSPA ? 1 : 0;
226 int PluginServer::is_ffmpeg()
228 return plugin_type == PLUGIN_TYPE_FFMPEG ? 1 : 0;
231 void PluginServer::set_path(const char *path)
233 delete [] this->path;
234 this->path = cstrdup(path);
237 char* PluginServer::get_path()
242 int PluginServer::get_synthesis()
248 void PluginServer::set_title(const char *string)
250 if(title) delete [] title;
251 title = cstrdup(string);
254 void PluginServer::generate_display_title(char *string)
256 char ltitle[BCTEXTLEN];
257 if(BC_Resources::locale_utf8)
258 strcpy(ltitle, _(title));
260 BC_Resources::encode(BC_Resources::encoding, 0,
261 _(title),strlen(title)+1, ltitle,BCTEXTLEN);
262 if(plugin && plugin->track)
263 sprintf(string, "%s: %s", plugin->track->title, ltitle);
265 strcpy(string, ltitle);
268 void *PluginServer::load_obj()
271 char dlpath[BCTEXTLEN], *dp = dlpath;
274 char *bp = preferences->plugin_dir;
275 while( *bp ) *dp++ = *bp++;
278 while( *cp ) *dp++ = *cp++;
280 dlobj = load(dlpath);
285 void PluginServer::unload_obj()
288 unload(dlobj); dlobj = 0;
291 void PluginServer::delete_this()
295 if( obj ) unload(obj);
298 // Open plugin for signal processing
299 int PluginServer::open_plugin(int master,
300 Preferences *preferences,
304 if(plugin_open) return 0;
306 this->preferences = preferences;
307 this->plugin = plugin;
309 if( plugin_type != PLUGIN_TYPE_FFMPEG && plugin_type != PLUGIN_TYPE_EXECUTABLE && !load_obj() ) {
310 // If the load failed it may still be an executable tool for a specific
311 // file format, in which case we just store the path.
313 char string[BCTEXTLEN];
314 strcpy(string, load_error());
315 if( !strstr(string, "executable") ) {
316 eprintf("PluginServer::open_plugin: load_obj failure = %s\n", string);
317 return PLUGINSERVER_NOT_RECOGNIZED;
319 plugin_type = PLUGIN_TYPE_EXECUTABLE;
321 if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_BUILTIN ) {
323 (PluginClient* (*)(PluginServer*)) load_sym("new_plugin");
325 plugin_type = PLUGIN_TYPE_BUILTIN;
327 if( plugin_type == PLUGIN_TYPE_UNKNOWN || plugin_type == PLUGIN_TYPE_LADSPA ) {
328 lad_descriptor_function =
329 (LADSPA_Descriptor_Function) load_sym("ladspa_descriptor");
330 if( lad_descriptor_function ) {
331 if( lad_index < 0 ) {
333 return PLUGINSERVER_IS_LAD;
335 lad_descriptor = lad_descriptor_function(lad_index);
336 if( !lad_descriptor )
337 return PLUGINSERVER_NOT_RECOGNIZED;
338 plugin_type = PLUGIN_TYPE_LADSPA;
341 if( plugin_type == PLUGIN_TYPE_UNKNOWN ) {
342 fprintf(stderr, "PluginServer::open_plugin "
343 " %d: plugin undefined in %s\n", __LINE__, path);
345 return PLUGINSERVER_NOT_RECOGNIZED;
347 switch( plugin_type ) {
348 case PLUGIN_TYPE_BUILTIN:
349 client = new_plugin(this);
351 case PLUGIN_TYPE_LADSPA:
352 client = new PluginAClientLAD(this);
354 case PLUGIN_TYPE_FFMPEG:
355 client = new_ffmpeg_plugin();
362 return PLUGINSERVER_NOT_RECOGNIZED;
364 // Run initialization functions
365 realtime = client->is_realtime();
366 // Don't load defaults when probing the directory.
369 client->load_defaults_xml();
371 client->load_defaults();
373 audio = client->is_audio();
374 video = client->is_video();
375 theme = client->is_theme();
376 fileio = client->is_fileio();
377 uses_gui = client->uses_gui();
378 multichannel = client->is_multichannel();
379 synthesis = client->is_synthesis();
380 transition = client->is_transition();
381 set_title(client->plugin_title());
383 //printf("PluginServer::open_plugin 2\n");
385 return PLUGINSERVER_OK;
388 int PluginServer::close_plugin()
390 if(!plugin_open) return 0;
394 // Defaults are saved in the thread.
395 // if(client->defaults) client->save_defaults();
399 // shared object is persistent since plugin deletion would unlink its own object
405 void PluginServer::client_side_close()
407 // Last command executed in client thread
409 mwindow->hide_plugin(plugin, 1);
413 prompt->lock_window();
415 prompt->unlock_window();
419 void PluginServer::render_stop()
422 client->render_stop();
425 void PluginServer::write_table(FILE *fp, int idx)
428 fprintf(fp, "%d \"%s\" \"%s\" %d %d %d %d %d %d %d %d %d %d %d\n",
429 plugin_type, path, title, idx, audio, video, theme, realtime,
430 fileio, uses_gui, multichannel, synthesis, transition, lad_index);
433 int PluginServer::scan_table(char *text, int &type, char *path, char *title)
435 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\"", &type, path, title);
436 return n < 3 ? 1 : 0;
439 int PluginServer::read_table(char *text)
441 char path[BCTEXTLEN], title[BCTEXTLEN];
442 int n = sscanf(text, "%d \"%[^\"]\" \"%[^\"]\" %d %d %d %d %d %d %d %d %d %d %d",
443 &plugin_type, path, title, &dir_idx, &audio, &video, &theme, &realtime,
444 &fileio, &uses_gui, &multichannel, &synthesis, &transition, &lad_index);
445 if( n != 14 ) return 1;
446 this->path = cstrdup(path);
447 this->title = cstrdup(title);
451 int PluginServer::init_realtime(int realtime_sched,
452 int total_in_buffers,
456 if(!plugin_open) return 0;
458 // set for realtime priority
460 // Call start_realtime
461 this->total_in_buffers = this->total_out_buffers = total_in_buffers;
462 client->plugin_init_realtime(realtime_sched,
470 // Replaced by pull method but still needed for transitions
471 void PluginServer::process_transition(VFrame *input,
473 int64_t current_position,
476 if(!plugin_open) return;
477 PluginVClient *vclient = (PluginVClient*)client;
479 vclient->source_position = current_position;
480 vclient->source_start = 0;
481 vclient->total_len = total_len;
483 vclient->input = new VFrame*[1];
484 vclient->output = new VFrame*[1];
486 vclient->input[0] = input;
487 vclient->output[0] = output;
489 vclient->process_realtime(input, output);
491 delete [] vclient->input;
492 delete [] vclient->output;
496 void PluginServer::process_transition(Samples *input,
498 int64_t current_position,
499 int64_t fragment_size,
502 if(!plugin_open) return;
503 PluginAClient *aclient = (PluginAClient*)client;
505 aclient->source_position = current_position;
506 aclient->total_len = total_len;
507 aclient->source_start = 0;
508 aclient->process_realtime(fragment_size,
514 void PluginServer::process_buffer(VFrame **frame,
515 int64_t current_position,
520 if(!plugin_open) return;
521 PluginVClient *vclient = (PluginVClient*)client;
523 vclient->source_position = current_position;
524 vclient->total_len = total_len;
525 vclient->frame_rate = frame_rate;
526 vclient->input = new VFrame*[total_in_buffers];
527 vclient->output = new VFrame*[total_in_buffers];
528 for(int i = 0; i < total_in_buffers; i++)
530 vclient->input[i] = frame[i];
531 vclient->output[i] = frame[i];
536 vclient->source_start = (int64_t)plugin->startproject *
538 vclient->project_frame_rate;
540 vclient->direction = direction;
544 //printf("plugin=%p source_start=%ld\n", plugin, vclient->source_start);
546 vclient->begin_process_buffer();
549 vclient->process_buffer(frame, current_position, frame_rate);
553 vclient->process_buffer(frame[0], current_position, frame_rate);
555 vclient->end_process_buffer();
557 for(int i = 0; i < total_in_buffers; i++)
558 frame[i]->push_prev_effect(title);
560 delete [] vclient->input;
561 delete [] vclient->output;
567 void PluginServer::process_buffer(Samples **buffer,
568 int64_t current_position,
569 int64_t fragment_size,
574 if(!plugin_open) return;
575 PluginAClient *aclient = (PluginAClient*)client;
577 aclient->source_position = current_position;
578 aclient->total_len = total_len;
579 aclient->sample_rate = sample_rate;
582 aclient->source_start = plugin->startproject *
584 aclient->project_sample_rate;
586 aclient->direction = direction;
587 aclient->begin_process_buffer();
590 aclient->process_buffer(fragment_size,
597 aclient->process_buffer(fragment_size,
602 aclient->end_process_buffer();
606 void PluginServer::send_render_gui(void *data)
608 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
609 if(attachmentpoint) attachmentpoint->render_gui(data, this);
612 void PluginServer::send_render_gui(void *data, int size)
614 //printf("PluginServer::send_render_gui 1 %p\n", attachmentpoint);
615 if(attachmentpoint) attachmentpoint->render_gui(data, size, this);
618 void PluginServer::render_gui(void *data)
620 if(client) client->plugin_render_gui(data);
623 void PluginServer::render_gui(void *data, int size)
625 if(client) client->plugin_render_gui(data, size);
628 MainProgressBar* PluginServer::start_progress(char *string, int64_t length)
630 mwindow->gui->lock_window();
631 MainProgressBar *result = mwindow->mainprogress->start_progress(string, length);
632 mwindow->gui->unlock_window();
636 int64_t PluginServer::get_written_samples()
638 if(!plugin_open) return 0;
639 return written_samples;
642 int64_t PluginServer::get_written_frames()
644 if(!plugin_open) return 0;
645 return written_frames;
657 // ======================= Non-realtime plugin
659 int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
661 if(!plugin_open) return 0;
663 client->start = start;
665 client->source_start = start;
666 client->total_len = end - start;
667 client->total_in_buffers = channels;
670 //printf(" source_start=%ld total_len=%ld\n", client->source_start, client->total_len);
672 return client->plugin_get_parameters();
675 int PluginServer::set_interactive()
677 if(!plugin_open) return 0;
678 client->set_interactive();
682 void PluginServer::append_module(Module *module)
684 modules->append(module);
687 void PluginServer::append_node(VirtualNode *node)
692 void PluginServer::reset_nodes()
697 int PluginServer::set_error()
703 int PluginServer::set_realtime_sched()
705 //struct sched_param params;
706 //params.sched_priority = 1;
707 //sched_setscheduler(0, SCHED_RR, ¶m);
712 int PluginServer::process_loop(VFrame **buffers, int64_t &write_length)
714 if(!plugin_open) return 1;
715 return client->plugin_process_loop(buffers, write_length);
718 int PluginServer::process_loop(Samples **buffers, int64_t &write_length)
720 if(!plugin_open) return 1;
721 return client->plugin_process_loop(buffers, write_length);
725 int PluginServer::start_loop(int64_t start,
730 if(!plugin_open) return 0;
731 client->plugin_start_loop(start, end, buffer_size, total_buffers);
735 int PluginServer::stop_loop()
737 if(!plugin_open) return 0;
738 return client->plugin_stop_loop();
741 int PluginServer::read_frame(VFrame *buffer,
743 int64_t start_position)
745 ((VModule*)modules->values[channel])->render(buffer,
748 mwindow->edl->session->frame_rate,
754 int PluginServer::read_samples(Samples *buffer,
757 int64_t start_position,
760 // len is now in buffer
761 if(!multichannel) channel = 0;
763 if(nodes->total > channel)
764 return ((VirtualANode*)nodes->values[channel])->read_data(buffer,
769 if(modules->total > channel)
770 return ((AModule*)modules->values[channel])->render(buffer,
778 printf("PluginServer::read_samples no object available for channel=%d\n",
786 int PluginServer::read_samples(Samples *buffer,
788 int64_t start_position,
791 // total_samples is now set in buffer
792 ((AModule*)modules->values[channel])->render(buffer,
796 mwindow->edl->session->sample_rate,
801 int PluginServer::read_frame(VFrame *buffer,
803 int64_t start_position,
807 // Data source depends on whether we're part of a virtual console or a
811 // If we're a VirtualNode, read_data in the virtual plugin node handles
812 // backward propogation and produces the data.
813 // If we're a Module, render in the module produces the data.
817 if(!multichannel) channel = 0;
819 // Push our name on the next effect stack
820 buffer->push_next_effect(title);
821 //printf("PluginServer::read_frame %p\n", buffer);
822 //buffer->dump_stacks();
824 if(nodes->total > channel)
826 //printf("PluginServer::read_frame %d\n", __LINE__);
827 result = ((VirtualVNode*)nodes->values[channel])->read_data(buffer,
833 if(modules->total > channel)
835 //printf("PluginServer::read_frame %d\n", __LINE__);
836 result = ((VModule*)modules->values[channel])->render(buffer,
847 printf("PluginServer::read_frame no object available for channel=%d\n",
851 // Pop our name from the next effect stack
852 buffer->pop_next_effect();
877 int PluginServer::get_gui_status()
880 return plugin->show ? GUI_ON : GUI_OFF;
885 void PluginServer::raise_window()
887 if(!plugin_open) return;
888 client->raise_window();
891 void PluginServer::show_gui()
893 if(!plugin_open) return;
894 if(plugin) client->total_len = plugin->length;
895 if(plugin) client->source_start = plugin->startproject;
898 client->source_position = Units::to_int64(
899 mwindow->edl->local_session->get_selectionstart(1) *
900 mwindow->edl->session->frame_rate);
905 client->source_position = Units::to_int64(
906 mwindow->edl->local_session->get_selectionstart(1) *
907 mwindow->edl->session->sample_rate);
910 client->update_display_title();
914 void PluginServer::hide_gui()
916 if(!plugin_open) return;
917 if(client->defaults) client->save_defaults();
921 void PluginServer::update_gui()
923 if(!plugin_open || !plugin) return;
925 client->total_len = plugin->length;
926 client->source_start = plugin->startproject;
930 client->source_position = Units::to_int64(
931 mwindow->edl->local_session->get_selectionstart(1) *
932 mwindow->edl->session->frame_rate);
937 client->source_position = Units::to_int64(
938 mwindow->edl->local_session->get_selectionstart(1) *
939 mwindow->edl->session->sample_rate);
942 client->plugin_update_gui();
945 void PluginServer::update_title()
947 if(!plugin_open) return;
949 client->update_display_title();
953 int PluginServer::set_string(char *string)
955 if(!plugin_open) return 0;
957 client->set_string_client(string);
961 int PluginServer::gui_open()
963 if(attachmentpoint) return attachmentpoint->gui_open();
967 void PluginServer::set_use_opengl(int value, VideoDevice *vdevice)
969 this->use_opengl = value;
970 this->vdevice = vdevice;
973 int PluginServer::get_use_opengl()
979 void PluginServer::run_opengl(PluginClient *plugin_client)
982 ((VDeviceX11*)vdevice->get_output_base())->run_plugin(plugin_client);
985 // ============================= queries
987 void PluginServer::get_defaults_path(char *path)
989 // Get plugin name from path
990 char *ptr1 = strrchr(get_path(), '/');
991 char *ptr2 = strrchr(get_path(), '.');
992 if(!ptr1) ptr1 = get_path();
993 if(!ptr2) ptr2 = get_path() + strlen(get_path());
994 char string2[BCTEXTLEN];
995 char *ptr3 = string2;
1001 sprintf(path, "%s%s.xml", BCASTDIR, string2);
1004 void PluginServer::save_defaults()
1006 if(client) client->save_defaults();
1009 int PluginServer::get_samplerate()
1011 if(!plugin_open) return 0;
1014 return client->get_samplerate();
1018 return mwindow->edl->session->sample_rate;
1021 printf("PluginServer::get_samplerate audio and mwindow == NULL\n");
1027 double PluginServer::get_framerate()
1029 if(!plugin_open) return 0;
1032 return client->get_framerate();
1036 return mwindow->edl->session->frame_rate;
1039 printf("PluginServer::get_framerate video and mwindow == NULL\n");
1044 int PluginServer::get_project_samplerate()
1047 return mwindow->edl->session->sample_rate;
1050 return edl->session->sample_rate;
1053 printf("PluginServer::get_project_samplerate mwindow and edl are NULL.\n");
1058 double PluginServer::get_project_framerate()
1061 return mwindow->edl->session->frame_rate;
1064 return edl->session->frame_rate;
1067 printf("PluginServer::get_project_framerate mwindow and edl are NULL.\n");
1074 int PluginServer::detach_buffers()
1076 ring_buffers_out.remove_all();
1077 offset_out_render.remove_all();
1078 double_buffer_out_render.remove_all();
1079 realtime_out_size.remove_all();
1081 ring_buffers_in.remove_all();
1082 offset_in_render.remove_all();
1083 double_buffer_in_render.remove_all();
1084 realtime_in_size.remove_all();
1086 out_buffer_size = 0;
1088 total_out_buffers = 0;
1090 total_in_buffers = 0;
1094 int PluginServer::arm_buffer(int buffer_number,
1097 int double_buffer_in,
1098 int double_buffer_out)
1100 offset_in_render.values[buffer_number] = offset_in;
1101 offset_out_render.values[buffer_number] = offset_out;
1102 double_buffer_in_render.values[buffer_number] = double_buffer_in;
1103 double_buffer_out_render.values[buffer_number] = double_buffer_out;
1108 int PluginServer::set_automation(FloatAutos *autos, FloatAuto **start_auto, FloatAuto **end_auto, int reverse)
1110 this->autos = autos;
1111 this->start_auto = start_auto;
1112 this->end_auto = end_auto;
1113 this->reverse = reverse;
1119 void PluginServer::save_data(KeyFrame *keyframe)
1121 if(!plugin_open) return;
1122 client->save_data(keyframe);
1125 KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
1127 KeyFrame *result = 0;
1129 result = plugin->get_prev_keyframe(position, client->direction);
1135 KeyFrame* PluginServer::get_next_keyframe(int64_t position)
1137 KeyFrame *result = 0;
1139 result = plugin->get_next_keyframe(position, client->direction);
1146 KeyFrame* PluginServer::get_keyframe()
1149 // Realtime plugin case
1150 return plugin->get_keyframe();
1152 // Rendered plugin case
1157 void PluginServer::apply_keyframe(KeyFrame *src)
1161 keyframe->copy_data(src);
1166 plugin->keyframes->update_parameter(src);
1174 void PluginServer::get_camera(float *x, float *y, float *z,
1175 int64_t position, int direction)
1177 plugin->track->automation->get_camera(x, y, z, position, direction);
1180 void PluginServer::get_projector(float *x, float *y, float *z,
1181 int64_t position, int direction)
1183 plugin->track->automation->get_projector(x, y, z, position, direction);
1187 int PluginServer::get_interpolation_type()
1189 return plugin->edl->session->interpolation_type;
1192 Theme* PluginServer::new_theme()
1196 return client->new_theme();
1202 Theme* PluginServer::get_theme()
1204 if(mwindow) return mwindow->theme;
1205 printf("PluginServer::get_theme mwindow not set\n");
1210 char *PluginServer::get_plugin_png_path(char *png_path)
1212 char *bp = strrchr(path, '/'), *cp = png_path;
1213 if( !bp ) bp = path; else ++bp;
1214 char *sp = strrchr(bp,'.');
1215 if( !sp || ( strcmp(sp, ".plugin") && strcmp(sp,".so") ) ) return 0;
1216 cp += sprintf(cp,"%s/picons/", mwindow->preferences->plugin_dir);
1217 while( bp < sp ) *cp++ = *bp++;
1222 VFrame *PluginServer::get_plugin_images()
1224 char png_path[BCTEXTLEN];
1225 if( !get_plugin_png_path(png_path) ) return 0;
1227 if( stat(png_path, &st) ) return 0;
1228 if( !S_ISREG(st.st_mode) ) return 0;
1229 if( st.st_size == 0 ) return 0;
1230 unsigned len = st.st_size;
1231 int ret = 0, w = 0, h = 0;
1232 unsigned char *bfr = 0;
1233 int fd = ::open(png_path, O_RDONLY);
1234 if( fd < 0 ) ret = 1;
1236 bfr = (unsigned char *) ::mmap (NULL, len, PROT_READ, MAP_SHARED, fd, 0);
1237 if( bfr == MAP_FAILED ) ret = 1;
1241 double scale = BC_WindowBase::get_resources()->icon_scale;
1242 vframe = new VFramePng(bfr, st.st_size, scale, scale);
1243 if( (w=vframe->get_w()) <= 0 || (h=vframe->get_h()) <= 0 ||
1244 vframe->get_data() == 0 ) ret = 1;
1246 if( bfr && bfr != MAP_FAILED ) ::munmap(bfr, len);
1247 if( fd >= 0 ) ::close(fd);
1248 if( ret ) { delete vframe; vframe = 0; }
1252 VFrame *PluginServer::get_picon()
1255 picon = get_plugin_images();
1259 // Called when plugin interface is tweeked
1260 void PluginServer::sync_parameters()
1262 if(video) mwindow->restart_brender();
1263 mwindow->sync_parameters();
1264 mwindow->update_keyframe_guis();
1265 if(mwindow->edl->session->auto_conf->plugins)
1267 mwindow->gui->lock_window("PluginServer::sync_parameters");
1268 mwindow->gui->draw_overlays(1);
1269 mwindow->gui->unlock_window();
1275 void PluginServer::dump(FILE *fp)
1277 fprintf(fp," PluginServer %d %p %s %s %d\n",
1278 __LINE__, this, path, title, realtime);