1 #include "attachmentpoint.h"
3 #include "automation.h"
6 #include "floatautos.h"
15 #include "pluginserver.h"
16 #include "renderengine.h"
18 #include "transition.h"
19 #include "transportque.h"
20 #include "virtualconsole.h"
21 #include "virtualnode.h"
23 VirtualNode::VirtualNode(RenderEngine *renderengine,
24 VirtualConsole *vconsole,
28 VirtualNode *parent_node)
30 this->renderengine = renderengine;
31 this->vconsole = vconsole;
32 this->real_module = real_module;
33 this->real_plugin = real_plugin;
35 this->parent_node = parent_node;
38 waiting_real_plugin = 0;
39 plugin_buffer_number = 0;
41 plugin_auto_before = plugin_auto_after = 0;
44 //printf("VirtualNode::VirtualNode 1\n");
47 VirtualNode::~VirtualNode()
49 subnodes.remove_all_objects();
50 //printf("VirtualNode::VirtualNode 2\n");
53 #define PRINT_INDENT for(int j = 0; j < indent; j++) printf(" ");
55 void VirtualNode::dump(int indent)
58 printf("VirtualNode %p title=%s %s\n",
65 printf(" Plugins total=%d\n", subnodes.total);
66 for(int i = 0; i < subnodes.total; i++)
68 subnodes.values[i]->dump(indent + 2);
74 printf(" Plugin %s\n", real_plugin->title);
78 int VirtualNode::expand(int persistent_plugins, int64_t current_position)
80 // module needs to know where the input data for the next process is
83 expand_as_module(persistent_plugins, current_position);
88 // attach to a real plugin for a plugin
89 // plugin always takes data from input to output
90 expand_as_plugin(persistent_plugins);
96 int VirtualNode::expand_as_module(int duplicate, int64_t current_position)
98 Transition *transition = 0;
100 // create the plugins for this module
101 for(int i = 0; i < track->plugin_set.total; i++)
103 Plugin *plugin = track->get_current_plugin(current_position,
105 renderengine->command->get_direction(),
109 // Switch off if circular reference. This happens if a plugin set or a track is deleted.
110 if(plugin == real_plugin) continue;
113 if(plugin && plugin->on)
115 int plugin_type = plugin->plugin_type;
116 if(plugin_type == PLUGIN_SHAREDMODULE)
118 // plugin is a module
119 attach_virtual_module(plugin,
125 if(plugin_type == PLUGIN_SHAREDPLUGIN ||
126 plugin_type == PLUGIN_STANDALONE)
128 // plugin is a plugin
129 attach_virtual_plugin(plugin,
138 if(!parent_node) vconsole->append_exit_node(this);
143 int VirtualNode::expand_as_plugin(int duplicate)
145 plugin_type = real_plugin->plugin_type;
147 if(plugin_type == PLUGIN_SHAREDPLUGIN)
149 // Attached to a shared plugin.
150 // Get the real real plugin it's attached to.
152 // Redirect the real_plugin to the shared plugin.
153 int real_module_number = real_plugin->shared_location.module;
154 int real_plugin_number = real_plugin->shared_location.plugin;
155 Module *real_module = vconsole->module_number(real_module_number);
157 // module references are absolute so may get the wrong data type track.
160 attachment = real_module->get_attachment(real_plugin_number);
161 // Attachment is NULL if off
164 real_plugin = attachment->plugin;
166 // Real plugin not on then null it.
167 if(!real_plugin || !real_plugin->on) real_plugin = 0;
177 if(plugin_type == PLUGIN_STANDALONE)
180 Module *module = vconsole->module_of(track);
182 attachment = module->attachment_of(real_plugin);
189 // Add to real plugin's list of virtual plugins for configuration updates
190 // and plugin_server initializations.
191 // Input and output are taken care of when the parent module creates this plugin.
192 // Get number for passing to render.
193 // real_plugin may become NULL after shared plugin test.
194 if(real_plugin && attachment)
197 plugin_buffer_number = attachment->attach_virtual_plugin(this);
206 int VirtualNode::attach_virtual_module(Plugin *plugin,
209 int64_t current_position)
213 int real_module_number = plugin->shared_location.module;
214 Module *real_module = vconsole->module_number(real_module_number);
215 // If a track is deleted real_module is not found
216 if(!real_module) return 1;
218 Track *track = real_module->track;
220 // Switch off if circular reference. This happens if a track is deleted.
221 if(track == this->real_module->track) return 1;
226 VirtualNode *virtual_module = create_module(plugin,
230 subnodes.append(virtual_module);
231 virtual_module->expand(duplicate, current_position);
237 int VirtualNode::attach_virtual_plugin(Plugin *plugin,
240 int64_t current_position)
242 // Get real plugin and test if it is on.
244 if(plugin->plugin_type == PLUGIN_SHAREDPLUGIN)
246 int real_module_number = plugin->shared_location.module;
247 int real_plugin_number = plugin->shared_location.plugin;
248 Module *real_module = vconsole->module_number(real_module_number);
251 AttachmentPoint *attachment = real_module->get_attachment(real_plugin_number);
254 Plugin *real_plugin = attachment->plugin;
255 if(!real_plugin || !real_plugin->on)
267 VirtualNode *virtual_plugin = create_plugin(plugin);
268 subnodes.append(virtual_plugin);
269 virtual_plugin->expand(duplicate, current_position);
274 VirtualNode* VirtualNode::get_previous_plugin(VirtualNode *current_node)
276 for(int i = 0; i < subnodes.total; i++)
278 // Assume plugin is on
279 if(subnodes.values[i] == current_node)
282 return subnodes.values[i - 1];
292 void VirtualNode::get_mute_fragment(int64_t input_position,
299 if(use_nudge) input_position += track->nudge;
301 IntAuto *prev_keyframe = 0;
302 IntAuto *next_keyframe = 0;
303 prev_keyframe = (IntAuto*)autos->get_prev_auto(input_position,
305 (Auto* &)prev_keyframe);
306 next_keyframe = (IntAuto*)autos->get_next_auto(input_position,
308 (Auto* &)next_keyframe);
310 if(direction == PLAY_FORWARD)
312 // Two distinct keyframes within range
313 if(next_keyframe->position > prev_keyframe->position)
315 mute_constant = prev_keyframe->value;
317 if(next_keyframe->position < input_position + fragment_len)
318 fragment_len = next_keyframe->position - input_position;
321 // One keyframe within range
323 mute_constant = prev_keyframe->value;
328 // Two distinct keyframes within range
329 if(next_keyframe->position < prev_keyframe->position)
331 mute_constant = next_keyframe->value;
333 if(next_keyframe->position > input_position - fragment_len)
334 fragment_len = input_position - next_keyframe->position;
337 // One keyframe within range
339 mute_constant = next_keyframe->value;