#include "mainsession.h"
#include "theme.h"
#include "trackcanvas.h"
+#include "tracks.h"
#include "transportque.h"
#include "vdevicex11.h"
#include "vframe.h"
nodes = new ArrayList<VirtualNode*>;
tip = 0;
gui_id = -1;
+ plugin_id = -1;
}
PluginServer::PluginServer()
new_buffers = 0;
written_samples = written_frames = 0;
gui_on = 0;
- plugin = 0;
+ plugin_id = -1;
plugin_open = 0;
return 0;
}
else
BC_Resources::encode(BC_Resources::encoding, 0,
_(title),strlen(title)+1, ltitle,BCTEXTLEN);
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin && plugin->track )
sprintf(string, "%s: %s", plugin->track->title, ltitle);
else
if( plugin_open ) return 0;
this->preferences = preferences;
- this->plugin = plugin;
+ this->plugin_id = plugin ? plugin->orig_id : -1;
this->edl = edl;
if( !is_ffmpeg() && !is_lv2() && !is_executable() && !load_obj() ) {
// If the load failed, can't use error string to detect executable
int PluginServer::close_plugin()
{
if( !plugin_open ) return 0;
-
- if( client ) {
-// Defaults are saved in the thread.
-// if( client->defaults ) client->save_defaults();
- delete client;
- }
-
-// shared object is persistent since plugin deletion would unlink its own object
+ delete client;
plugin_open = 0;
cleanup_plugin();
return 0;
void PluginServer::client_side_close()
{
// Last command executed in client thread
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin )
mwindow->hide_plugin(plugin, 1);
- else
- if( prompt ) {
+ else if( prompt ) {
prompt->lock_window();
prompt->set_done(1);
prompt->unlock_window();
int64_t total_len)
{
if( !plugin_open ) return;
+ if (total_len == 0) return;
PluginVClient *vclient = (PluginVClient*)client;
+ to_ram(input);
+ to_ram(output);
vclient->source_position = current_position;
vclient->source_start = 0;
vclient->output[i] = frame[i];
}
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin ) {
vclient->source_start = (int64_t)plugin->startproject *
frame_rate / vclient->project_frame_rate;
aclient->in_buffer_size = aclient->out_buffer_size = fragment_size;
aclient->output_buffers = buffer;
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin )
aclient->source_start = plugin->startproject *
sample_rate /
PluginGUIs::PluginGUIs(MWindow *mwindow)
{
this->mwindow = mwindow;
- this->next_id = 0;
}
PluginGUIs::~PluginGUIs()
{
void PluginGUIs::append(PluginServer *server)
{
- server->gui_id = next_id++;
+ server->gui_id = EDL::next_id();
ArrayList<PluginServer*>::append(server);
}
void PluginServer::reset_gui_frames()
{
- mwindow->reset_plugin_gui_frames(plugin);
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
+ if( plugin )
+ mwindow->reset_plugin_gui_frames(plugin);
}
void PluginServer::reset_plugin_gui_frames()
void PluginServer::render_gui_frames(PluginClientFrames *frames)
{
- mwindow->render_plugin_gui_frames(frames, plugin);
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
+ if( plugin )
+ mwindow->render_plugin_gui_frames(frames, plugin);
}
void PluginServer::render_plugin_gui_frames(PluginClientFrames *frames)
// Called by client
int PluginServer::get_gui_status()
{
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin )
return plugin->show ? GUI_ON : GUI_OFF;
else
void PluginServer::show_gui()
{
if( !plugin_open ) return;
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin ) {
plugin->gui_id = gui_id;
client->total_len = plugin->length;
void PluginServer::hide_gui()
{
if( !plugin_open ) return;
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin ) plugin->gui_id = -1;
if( client->defaults ) client->save_defaults();
client->hide_gui();
void PluginServer::update_gui()
{
- if( !plugin_open || !plugin ) return;
+ if( !plugin_open ) return;
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
+ if( !plugin ) return;
client->total_len = plugin->length;
client->source_start = plugin->startproject;
return use_opengl;
}
+int PluginServer::to_ram(VFrame *vframe)
+{
+ if( vframe->get_opengl_state() == VFrame::RAM ) return 0;
+ if( !vdevice ) return -1;
+ VDeviceX11 *vdevice_x11 = (VDeviceX11*) vdevice->get_output_base();
+ int vw = vframe->get_w(), vh = vframe->get_h();
+ vdevice_x11->do_camera(vframe, vframe, 0,0,vw,vh, 0,0,vw,vh); // copy to ram
+ return 1;
+}
void PluginServer::run_opengl(PluginClient *plugin_client)
{
void PluginServer::get_defaults_path(char *path)
{
-// Get plugin name from path
- char *ptr1 = strrchr(get_path(), '/');
- char *ptr2 = strrchr(get_path(), '.');
- if( !ptr1 ) ptr1 = get_path();
- if( !ptr2 ) ptr2 = get_path() + strlen(get_path());
- char string2[BCTEXTLEN], *ptr3 = string2;
- while( ptr1 < ptr2 ) *ptr3++ = *ptr1++;
- *ptr3 = 0;
+ char string2[BCTEXTLEN];
+ switch( plugin_type ) {
+ case PLUGIN_TYPE_FFMPEG:
+ case PLUGIN_TYPE_LV2:
+ strcpy(string2, title);
+ break;
+ case PLUGIN_TYPE_BUILTIN:
+ case PLUGIN_TYPE_LADSPA:
+ default: { // Get plugin name from path
+ char *ptr1 = strrchr(get_path(), '/');
+ char *ptr2 = strrchr(get_path(), '.');
+ if( !ptr1 ) ptr1 = get_path();
+ if( !ptr2 ) ptr2 = get_path() + strlen(get_path());
+ char *ptr3 = string2;
+ while( ptr1 < ptr2 ) *ptr3++ = *ptr1++;
+ *ptr3 = 0;
+ break; }
+ }
sprintf(path, "%s/%s.xml", File::get_config_path(), string2);
}
KeyFrame* PluginServer::get_prev_keyframe(int64_t position)
{
KeyFrame *result = 0;
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin )
result = plugin->get_prev_keyframe(position, client->direction);
else
KeyFrame* PluginServer::get_next_keyframe(int64_t position)
{
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
KeyFrame *result = !plugin ? 0 :
plugin->get_next_keyframe(position, client->direction);
return result;
// Called for
KeyFrame* PluginServer::get_keyframe()
{
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
if( plugin )
// Realtime plugin case
return plugin->get_keyframe();
}
-void PluginServer::apply_keyframe(KeyFrame *src)
-{
- if( !plugin )
- keyframe->copy_data(src);
- else
-// Span keyframes
- plugin->keyframes->update_parameter(src);
+void PluginServer::apply_keyframe(Plugin *plugin, KeyFrame *src)
+{
+ KeyFrame* dst = !plugin ? keyframe :
+ plugin->is_transition() ? plugin->get_keyframe() : 0;
+ if( !dst ) {
+ if( edl->session->span_keyframes ) {
+ double selection_start = edl->local_session->get_selectionstart(0);
+ double selection_end = edl->local_session->get_selectionend(0);
+ selection_start = edl->align_to_frame(selection_start, 0);
+ selection_end = edl->align_to_frame(selection_end, 0);
+ Track *track = plugin->track;
+ int64_t start = track->to_units(selection_start, 1);
+ int64_t end = track->to_units(selection_end, 1);
+ if( start != end ) {
+ client->span_keyframes(src, start, end);
+ return;
+ }
+ }
+ dst = get_keyframe();
+ }
+ if( dst )
+ dst->copy_data(src);
}
void PluginServer::get_camera(float *x, float *y, float *z,
int64_t position, int direction)
{
- plugin->track->automation->get_camera(x, y, z, position, direction);
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
+ if( plugin )
+ plugin->track->automation->get_camera(x, y, z, position, direction);
}
void PluginServer::get_projector(float *x, float *y, float *z,
int64_t position, int direction)
{
- plugin->track->automation->get_projector(x, y, z, position, direction);
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
+ if( plugin )
+ plugin->track->automation->get_projector(x, y, z, position, direction);
}
int PluginServer::get_interpolation_type()
{
- return plugin->edl->session->interpolation_type;
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
+ if( plugin )
+ return plugin->edl->session->interpolation_type;
+ return NEAREST_NEIGHBOR;
}
Theme* PluginServer::new_theme()
int64_t PluginServer::get_startproject()
{
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
return !plugin ? -1 : plugin->startproject;
}
int64_t PluginServer::get_endproject()
{
+ Plugin *plugin = edl->tracks->plugin_exists(plugin_id);
return !plugin ? -1 : plugin->startproject + plugin->length;
}