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 void AttachmentPoint::render_stop()
127 if(plugin_server && plugin->on)
129 for(int i = 0; i < plugin_servers.total; i++)
131 plugin_servers.values[i]->render_stop();
136 int AttachmentPoint::attach_virtual_plugin(VirtualNode *virtual_plugin)
138 if(!this) printf("AttachmentPoint::attach_virtual_plugin NULL\n");
139 int buffer_number = 0;
141 if(plugin_server && plugin->on)
143 // add virtual plugin to list of new virtual plugins
144 new_virtual_plugins.append(virtual_plugin);
145 //printf("AttachmentPoint::attach_virtual_plugin 1 %d\n", new_virtual_plugins.total);
146 // Always increment buffer number since this also corresponds to what
147 // plugin server to access if single channel.
148 buffer_number = new_virtual_plugins.total - 1;
153 printf("AttachmentPoint::attach_virtual_plugin attempt to attach plugin when off.\n");
158 printf("AttachmentPoint::attach_virtual_plugin attempt to attach when no plugin_server.\n");
161 return buffer_number;
164 int AttachmentPoint::multichannel_shared(int search_new)
166 if(!this) printf("AttachmentPoint::multichannel_shared NULL\n");
169 if(new_virtual_plugins.total &&
171 plugin_server->multichannel) return 1;
175 if(virtual_plugins.total &&
177 plugin_server->multichannel) return 1;
182 int AttachmentPoint::singlechannel()
184 if(!this) printf("AttachmentPoint::singlechannel NULL\n");
185 if(plugin_server && !plugin_server->multichannel) return 1;
190 void AttachmentPoint::render_gui(void *data)
192 if(!this) printf("AttachmentPoint::render_gui 1 NULL\n");
193 if(renderengine && renderengine->mwindow)
194 renderengine->mwindow->render_plugin_gui(data, plugin);
197 void AttachmentPoint::render_gui(void *data, int size)
199 if(!this) printf("AttachmentPoint::render_gui 2 NULL\n");
200 if(renderengine && renderengine->mwindow)
201 renderengine->mwindow->render_plugin_gui(data, size, plugin);
204 int AttachmentPoint::gui_open()
206 if(renderengine && renderengine->mwindow)
207 return renderengine->mwindow->plugin_gui_open(plugin);
221 int AttachmentPoint::dump()
225 printf(" Attachmentpoint %x virtual_plugins=%d\n", this, new_virtual_plugins.total);
226 if(plugin_server) plugin_server->dump();
230 printf(" No Plugin\n");