1 #include "attachmentpoint.h"
4 #include "edlsession.h"
7 #include "pluginserver.h"
8 #include "renderengine.h"
9 #include "transportque.h"
10 #include "virtualnode.h"
14 AttachmentPoint::AttachmentPoint(RenderEngine *renderengine,
19 this->plugin = plugin;
20 this->plugin_id = plugin->id;
21 this->renderengine = renderengine;
22 this->data_type = data_type;
23 plugin_server = renderengine->scan_plugindb(plugin->title,
27 AttachmentPoint::~AttachmentPoint()
29 delete_buffer_vector();
30 plugin_servers.remove_all_objects();
34 int AttachmentPoint::reset_parameters()
42 void AttachmentPoint::reset_status()
44 if(!this) printf("AttachmentPoint::reset_status NULL\n");
53 int AttachmentPoint::identical(AttachmentPoint *old)
55 return plugin_id == old->plugin_id;
59 int AttachmentPoint::render_init()
61 if(!this) printf("AttachmentPoint::render_init NULL\n");
62 if(plugin_server && plugin->on)
64 // Start new plugin servers if the number of nodes changed.
65 // The number of nodes can change independantly of the module's
67 if(virtual_plugins.total != new_virtual_plugins.total)
69 plugin_servers.remove_all_objects();
70 for(int i = 0; i < new_virtual_plugins.total; i++)
72 if(i == 0 || !plugin_server->multichannel)
74 PluginServer *new_server;
75 plugin_servers.append(new_server = new PluginServer(*plugin_server));
76 new_server->set_attachmentpoint(this);
77 plugin_servers.values[i]->open_plugin(0,
78 renderengine->preferences,
82 plugin_servers.values[i]->init_realtime(
83 renderengine->edl->session->real_time_playback &&
84 renderengine->command->realtime,
85 plugin_server->multichannel ? new_virtual_plugins.total : 1,
91 // Set new back pointers in the plugin servers
92 if(plugin_server->multichannel && plugin_servers.total)
94 PluginServer *new_server = plugin_servers.values[0];
95 new_server->reset_nodes();
96 for(int i = 0; i < new_virtual_plugins.total; i++)
98 new_server->append_node(new_virtual_plugins.values[i]);
103 for(int i = 0; i < new_virtual_plugins.total; i++)
105 PluginServer *new_server = plugin_servers.values[i];
106 new_server->reset_nodes();
107 new_server->append_node(new_virtual_plugins.values[i]);
112 // Delete old plugin servers
113 delete_buffer_vector();
114 virtual_plugins.remove_all();
116 // Set new plugin servers
117 for(int i = 0; i < new_virtual_plugins.total; i++)
118 virtual_plugins.append(new_virtual_plugins.values[i]);
119 new_virtual_plugins.remove_all();
125 int AttachmentPoint::render_stop(int duplicate)
127 if(!this) printf("AttachmentPoint::render_stop NULL\n");
129 // Can't use the on value here because it may have changed.
130 if(plugin_server && plugin->on && virtual_plugins.total && !duplicate)
132 // close the plugins if not shared
133 for(int i = 0; i < virtual_plugins.total; i++)
135 if(i == 0 || !plugin_server->multichannel)
137 plugin_servers.values[i]->close_plugin();
140 plugin_servers.remove_all_objects();
145 int AttachmentPoint::attach_virtual_plugin(VirtualNode *virtual_plugin)
147 if(!this) printf("AttachmentPoint::attach_virtual_plugin NULL\n");
148 int buffer_number = 0;
150 if(plugin_server && plugin->on)
152 // add virtual plugin to list of new virtual plugins
153 new_virtual_plugins.append(virtual_plugin);
154 //printf("AttachmentPoint::attach_virtual_plugin 1 %d\n", new_virtual_plugins.total);
155 // Always increment buffer number since this also corresponds to what
156 // plugin server to access if single channel.
157 buffer_number = new_virtual_plugins.total - 1;
162 printf("AttachmentPoint::attach_virtual_plugin attempt to attach plugin when off.\n");
167 printf("AttachmentPoint::attach_virtual_plugin attempt to attach when no plugin_server.\n");
170 return buffer_number;
173 int AttachmentPoint::multichannel_shared(int search_new)
175 if(!this) printf("AttachmentPoint::multichannel_shared NULL\n");
178 if(new_virtual_plugins.total &&
180 plugin_server->multichannel) return 1;
184 if(virtual_plugins.total &&
186 plugin_server->multichannel) return 1;
191 int AttachmentPoint::singlechannel()
193 if(!this) printf("AttachmentPoint::singlechannel NULL\n");
194 if(plugin_server && !plugin_server->multichannel) return 1;
199 void AttachmentPoint::render_gui(void *data)
201 if(!this) printf("AttachmentPoint::render_gui 1 NULL\n");
202 if(renderengine && renderengine->mwindow)
203 renderengine->mwindow->render_plugin_gui(data, plugin);
206 void AttachmentPoint::render_gui(void *data, int size)
208 if(!this) printf("AttachmentPoint::render_gui 2 NULL\n");
209 if(renderengine && renderengine->mwindow)
210 renderengine->mwindow->render_plugin_gui(data, size, plugin);
225 int AttachmentPoint::dump()
229 printf(" Attachmentpoint %x virtual_plugins=%d\n", this, new_virtual_plugins.total);
230 if(plugin_server) plugin_server->dump();
234 printf(" No Plugin\n");