1 #include "attachmentpoint.h"
2 #include "commonrender.h"
4 #include "edlsession.h"
10 #include "pluginarray.h"
11 #include "pluginserver.h"
12 #include "renderengine.h"
13 #include "sharedlocation.h"
16 #include "transportque.h"
19 Module::Module(RenderEngine *renderengine,
20 CommonRender *commonrender,
21 PluginArray *plugin_array,
24 this->renderengine = renderengine;
25 this->commonrender = commonrender;
26 this->plugin_array = plugin_array;
29 transition_server = 0;
31 total_attachments = 0;
32 new_total_attachments = 0;
40 for(int i = 0; i < track->plugin_set.total; i++)
44 // For some reason it isn't used here.
45 // attachments[i]->render_stop(0);
46 delete attachments[i];
49 delete [] attachments;
53 transition_server->close_plugin();
54 delete transition_server;
58 void Module::create_objects()
60 create_new_attachments();
64 EDL* Module::get_edl()
67 return renderengine->edl;
72 void Module::create_new_attachments()
74 // Not used in pluginarray
77 new_total_attachments = track->plugin_set.total;
78 if(new_total_attachments)
80 new_attachments = new AttachmentPoint*[new_total_attachments];
81 for(int i = 0; i < new_total_attachments; i++)
84 track->get_current_plugin(commonrender->current_position,
86 renderengine->command->get_direction(),
89 if(plugin && plugin->plugin_type != PLUGIN_NONE && plugin->on)
90 new_attachments[i] = new_attachment(plugin);
92 new_attachments[i] = 0;
98 // Create plugin servers later when nodes attach
102 void Module::swap_attachments()
104 // None of this is used in a pluginarray
105 for(int new_attachment = 0, old_attachment = 0;
106 new_attachment < new_total_attachments &&
107 old_attachment < total_attachments;
108 new_attachment++, old_attachment++)
110 // Copy any old attachment which is identical to a new one
111 if(new_attachments[new_attachment] &&
112 attachments[old_attachment] &&
113 new_attachments[new_attachment]->plugin ==
114 attachments[old_attachment]->plugin)
116 delete new_attachments[new_attachment];
117 new_attachments[new_attachment] = attachments[old_attachment];
118 attachments[old_attachment] = 0;
122 // Delete old attachments which weren't identical to new ones
123 for(int i = 0; i < total_attachments; i++)
125 if(attachments[i]) delete attachments[i];
130 delete [] attachments;
133 attachments = new_attachments;
134 total_attachments = new_total_attachments;
137 int Module::render_init()
139 for(int i = 0; i < total_attachments; i++)
142 attachments[i]->render_init();
148 AttachmentPoint* Module::attachment_of(Plugin *plugin)
150 //printf("Module::attachment_of 1 %d\n", total_attachments);
151 for(int i = 0; i < total_attachments; i++)
153 //printf("Module::attachment_of 2 %p\n", attachments[i]);
155 attachments[i]->plugin == plugin) return attachments[i];
161 // Test plugins for reconfiguration.
163 int Module::test_plugins()
165 if(total_attachments != track->plugin_set.total) return 1;
167 for(int i = 0; i < total_attachments; i++)
169 AttachmentPoint *attachment = attachments[i];
170 Plugin *plugin = track->get_current_plugin(commonrender->current_position,
172 renderengine->command->get_direction(),
174 // One exists and one doesn't
175 int use_plugin = plugin &&
176 plugin->plugin_type != PLUGIN_NONE &&
179 if((attachment && !use_plugin) ||
180 (!attachment && use_plugin)) return 1;
182 // Plugin not the same
185 attachment->plugin &&
186 !plugin->identical(attachment->plugin)) return 1;
192 void Module::update_transition(int64_t current_position, int direction)
194 //printf("Module::update_transition 1\n");
195 Plugin *transition = track->get_current_transition(current_position,
198 //printf("Module::update_transition 2 %p\n", transition);
200 if((!transition && this->transition) ||
201 (transition && this->transition && strcmp(transition->title, this->transition->title)))
203 this->transition = 0;
205 transition_server->close_plugin();
206 delete transition_server;
207 transition_server = 0;
209 //printf("Module::update_transition 7\n");
211 if(transition && !this->transition)
213 this->transition = transition;
214 //printf("Module::update_transition 7\n");
217 PluginServer *plugin_server = renderengine->scan_plugindb(transition->title);
218 transition_server = new PluginServer(*plugin_server);
219 transition_server->open_plugin(0, get_edl(), transition);
220 transition_server->init_realtime(
221 get_edl()->session->real_time_playback &&
222 renderengine->command->realtime,
229 PluginServer *plugin_server = plugin_array->scan_plugindb(transition->title);
230 transition_server = new PluginServer(*plugin_server);
231 transition_server->open_plugin(0, get_edl(), transition);
232 transition_server->init_realtime(
237 //printf("Module::update_transition 7\n");
240 //printf("Module::update_transition 8\n");
243 // if((transition && !this->transition) || (!transition && this->transition)) return 1;
244 // if(transition && transition != this->transition->plugin) return 1;
250 printf(" Module title=%s\n", track->title);
251 printf(" Plugins total_attachments=%d\n", total_attachments);
252 for(int i = 0; i < total_attachments; i++)
255 attachments[i]->dump();
257 printf(" No Plugin\n");