/*
* CINELERRA
* Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ *
*/
#include "amodule.h"
plugin_obj = new PluginObj();
modules = new ArrayList<Module*>;
nodes = new ArrayList<VirtualNode*>;
+ tip = 0;
}
PluginServer::PluginServer()
plugin_obj = that.plugin_obj;
plugin_obj->add_user();
title = !that.title ? 0 : cstrdup(that.title);
+ tip = !that.tip ? 0 : cstrdup(that.tip);
path = !that.path ? 0 : cstrdup(that.path);
ff_name = !that.ff_name ? 0 : cstrdup(that.ff_name);
modules = new ArrayList<Module*>;
nodes = new ArrayList<VirtualNode*>;
- attachment = that.attachment;
+ attachment = that.attachment;
realtime = that.realtime;
multichannel = that.multichannel;
preferences = that.preferences;
delete [] path;
delete [] ff_name;
delete [] title;
+ delete [] tip;
delete modules;
delete nodes;
delete picon;
keyframe = 0;
prompt = 0;
cleanup_plugin();
- autos = 0;
- edl = 0;
- preferences = 0;
- title = 0;
- path = 0;
+
+ lad_index = -1;
+ lad_descriptor_function = 0;
+ lad_descriptor = 0;
+
+ plugin_obj = 0;
+ client = 0;
+ new_plugin = 0;
+ lad_index = -1;
+ lad_descriptor_function = 0;
+ lad_descriptor = 0;
+ use_opengl = 0;
ff_name = 0;
- audio = video = theme = 0;
- fileio = 0;
- uses_gui = 0;
+ vdevice = 0;
+ plugin_type = 0;
+ start_auto = end_auto = 0;
+ autos = 0;
+ reverse = 0;
+ plugin_open = 0;
realtime = multichannel = fileio = 0;
synthesis = 0;
- start_auto = end_auto = 0;
+ audio = video = theme = 0;
+ uses_gui = 0;
transition = 0;
- new_plugin = 0;
- client = 0;
- use_opengl = 0;
- vdevice = 0;
+ title = 0;
+ tip = 0;
+ path = 0;
+ data_text = 0;
+ for( int i=sizeof(args)/sizeof(args[0]); --i>=0; ) args[i] = 0;
+ total_args = 0;
+ dir_idx = 0;
modules = 0;
nodes = 0;
+ attachmentpoint = 0;
+ edl = 0;
+ preferences = 0;
+ prompt = 0;
+ temp_frame = 0;
picon = 0;
- lad_index = -1;
- lad_descriptor_function = 0;
- lad_descriptor = 0;
return 0;
}
else
BC_Resources::encode(BC_Resources::encoding, 0,
_(title),strlen(title)+1, ltitle,BCTEXTLEN);
- if(plugin && plugin->track)
+ if(plugin && plugin->track)
sprintf(string, "%s: %s", plugin->track->title, ltitle);
else
strcpy(string, ltitle);
}
// Open plugin for signal processing
-int PluginServer::open_plugin(int master,
+int PluginServer::open_plugin(int master,
Preferences *preferences,
- EDL *edl,
+ EDL *edl,
Plugin *plugin)
{
if(plugin_open) return 0;
}
if( !client )
return PLUGINSERVER_NOT_RECOGNIZED;
-
+
// Run initialization functions
realtime = client->is_realtime();
// Don't load defaults when probing the directory.
}
int PluginServer::init_realtime(int realtime_sched,
- int total_in_buffers,
+ int total_in_buffers,
int buffer_size)
{
// initialize plugin
// Call start_realtime
this->total_in_buffers = this->total_out_buffers = total_in_buffers;
- client->plugin_init_realtime(realtime_sched,
- total_in_buffers,
+ client->plugin_init_realtime(realtime_sched,
+ total_in_buffers,
buffer_size);
return 0;
// Replaced by pull method but still needed for transitions
-void PluginServer::process_transition(VFrame *input,
- VFrame *output,
+void PluginServer::process_transition(VFrame *input,
+ VFrame *output,
int64_t current_position,
int64_t total_len)
{
use_opengl = 0;
}
-void PluginServer::process_transition(Samples *input,
+void PluginServer::process_transition(Samples *input,
Samples *output,
- int64_t current_position,
+ int64_t current_position,
int64_t fragment_size,
int64_t total_len)
{
aclient->total_len = total_len;
aclient->source_start = 0;
aclient->process_realtime(fragment_size,
- input,
+ input,
output);
}
-void PluginServer::process_buffer(VFrame **frame,
+void PluginServer::process_buffer(VFrame **frame,
int64_t current_position,
double frame_rate,
int64_t total_len,
vclient->input[i] = frame[i];
vclient->output[i] = frame[i];
}
-
+
if(plugin)
{
- vclient->source_start = (int64_t)plugin->startproject *
+ vclient->source_start = (int64_t)plugin->startproject *
frame_rate /
vclient->project_frame_rate;
}
aclient->sample_rate = sample_rate;
if(plugin)
- aclient->source_start = plugin->startproject *
+ aclient->source_start = plugin->startproject *
sample_rate /
aclient->project_sample_rate;
aclient->begin_process_buffer();
if(multichannel)
{
- aclient->process_buffer(fragment_size,
- buffer,
- current_position,
+ aclient->process_buffer(fragment_size,
+ buffer,
+ current_position,
sample_rate);
}
else
{
- aclient->process_buffer(fragment_size,
- buffer[0],
- current_position,
+ aclient->process_buffer(fragment_size,
+ buffer[0],
+ current_position,
sample_rate);
}
aclient->end_process_buffer();
// ======================= Non-realtime plugin
-int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
+int PluginServer::get_parameters(int64_t start, int64_t end, int channels)
{
if(!plugin_open) return 0;
}
-int PluginServer::start_loop(int64_t start,
- int64_t end,
- int64_t buffer_size,
+int PluginServer::start_loop(int64_t start,
+ int64_t end,
+ int64_t buffer_size,
int total_buffers)
{
if(!plugin_open) return 0;
return client->plugin_stop_loop();
}
-int PluginServer::read_frame(VFrame *buffer,
- int channel,
+int PluginServer::read_frame(VFrame *buffer,
+ int channel,
int64_t start_position)
{
((VModule*)modules->values[channel])->render(buffer,
}
-int PluginServer::read_samples(Samples *buffer,
- int channel,
+int PluginServer::read_samples(Samples *buffer,
+ int channel,
int64_t start_position,
int64_t size)
{
// total_samples is now set in buffer
- ((AModule*)modules->values[channel])->render(buffer,
+ ((AModule*)modules->values[channel])->render(buffer,
size,
start_position,
PLAY_FORWARD,
return 0;
}
-int PluginServer::read_frame(VFrame *buffer,
- int channel,
- int64_t start_position,
+int PluginServer::read_frame(VFrame *buffer,
+ int channel,
+ int64_t start_position,
double frame_rate,
int use_opengl)
{
if(video)
{
client->source_position = Units::to_int64(
- mwindow->edl->local_session->get_selectionstart(1) *
+ mwindow->edl->local_session->get_selectionstart(1) *
mwindow->edl->session->frame_rate);
}
else
if(audio)
{
client->source_position = Units::to_int64(
- mwindow->edl->local_session->get_selectionstart(1) *
+ mwindow->edl->local_session->get_selectionstart(1) *
mwindow->edl->session->sample_rate);
}
if(video)
{
client->source_position = Units::to_int64(
- mwindow->edl->local_session->get_selectionstart(1) *
+ mwindow->edl->local_session->get_selectionstart(1) *
mwindow->edl->session->frame_rate);
}
else
if(audio)
{
client->source_position = Units::to_int64(
- mwindow->edl->local_session->get_selectionstart(1) *
+ mwindow->edl->local_session->get_selectionstart(1) *
mwindow->edl->session->sample_rate);
}
void PluginServer::update_title()
{
if(!plugin_open) return;
-
+
client->update_display_title();
}
else
if(mwindow)
return mwindow->edl->session->frame_rate;
- else
+ else
{
printf("PluginServer::get_framerate video and mwindow == NULL\n");
return 1;
offset_in_render.remove_all();
double_buffer_in_render.remove_all();
realtime_in_size.remove_all();
-
+
out_buffer_size = 0;
shared_buffers = 0;
total_out_buffers = 0;
return 0;
}
-int PluginServer::arm_buffer(int buffer_number,
- int64_t offset_in,
+int PluginServer::arm_buffer(int buffer_number,
+ int64_t offset_in,
int64_t offset_out,
int double_buffer_in,
int double_buffer_out)
}
-int PluginServer::get_theme_png_path(char *png_path, const char *theme_dir)
-{
- char *bp = strrchr(path, '/');
- if( !bp ) bp = path; else ++bp;
- char *sp = strrchr(bp,'.');
- if( !sp || ( strcmp(sp, ".plugin") && strcmp(sp,".so") ) ) return 0;
- char *cp = png_path, *dp = bp;
- cp += sprintf(cp,"%s/%s/", mwindow->preferences->plugin_dir, theme_dir);
- while( dp < sp ) *cp++ = *dp++;
- strcpy(cp, ".png");
- struct stat st;
- if( stat(png_path, &st) ) return 0;
- if( !S_ISREG(st.st_mode) ) return 0;
- if( st.st_size == 0 ) return 0;
- return st.st_size;
-}
-
-int PluginServer::get_theme_png_path(char *png_path, Theme *theme)
+int PluginServer::get_plugin_png_path(char *png_path, const char *plugin_icons)
{
- char *bp = strrchr(theme->path, '/');
- if( !bp ) bp = theme->path; else ++bp;
- char *sp = strrchr(bp,'.');
- if( !sp || ( strcmp(sp, ".plugin") && strcmp(sp,".so") ) ) return 0;
- char theme_dir[BCTEXTLEN], *cp = theme_dir;
- while( bp < sp ) *cp++ = *bp++;
- *cp = 0;
- return get_theme_png_path(png_path, theme_dir);
+ char *pp = png_path, *ep = pp + BCTEXTLEN-1;
+ pp += snprintf(pp, ep-pp, "%s/picon_%s/",
+ File::get_plugin_path(), plugin_icons);
+ char *cp = strrchr(path, '/');
+ cp = !cp ? path : cp+1;
+ char *sp = strrchr(cp, '.');
+ if( !sp ) sp = cp+strlen(cp);
+ while( pp < ep && cp < sp ) *pp++ = *cp++;
+ snprintf(pp, ep-pp, ".png");
+ return access(png_path,R_OK) ? 1 : 0;
}
int PluginServer::get_plugin_png_path(char *png_path)
{
- int len = get_theme_png_path(png_path, mwindow->theme);
- if( !len )
- len = get_theme_png_path(png_path, "picon");
- return len;
+ int ret = get_plugin_png_path(png_path, mwindow->preferences->plugin_icons);
+ if( ret ) ret = get_plugin_png_path(png_path, DEFAULT_PICON);
+ return ret;
}
VFrame *PluginServer::get_plugin_images()
{
char png_path[BCTEXTLEN];
- int len = get_plugin_png_path(png_path);
- if( !len ) return 0;
- int ret = 0, w = 0, h = 0;
- unsigned char *bfr = 0;
- int fd = ::open(png_path, O_RDONLY);
- if( fd < 0 ) ret = 1;
- if( !ret ) {
- bfr = (unsigned char *) ::mmap (NULL, len, PROT_READ, MAP_SHARED, fd, 0);
- if( bfr == MAP_FAILED ) ret = 1;
- }
- VFrame *vframe = 0;
- if( !ret ) {
- double scale = BC_WindowBase::get_resources()->icon_scale;
- vframe = new VFramePng(bfr, len, scale, scale);
- if( (w=vframe->get_w()) <= 0 || (h=vframe->get_h()) <= 0 ||
- vframe->get_data() == 0 ) ret = 1;
- }
- if( bfr && bfr != MAP_FAILED ) ::munmap(bfr, len);
- if( fd >= 0 ) ::close(fd);
- if( ret ) { delete vframe; vframe = 0; }
- return vframe;
+ if( get_plugin_png_path(png_path) ) return 0;
+ return VFramePng::vframe_png(png_path,0,0);
}
VFrame *PluginServer::get_picon()
void PluginServer::dump(FILE *fp)
{
- fprintf(fp," PluginServer %d %p %s %s %d\n",
+ fprintf(fp," PluginServer %d %p %s %s %d\n",
__LINE__, this, path, title, realtime);
}