Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

virtualconsole.C

Go to the documentation of this file.
00001 #include "auto.h"
00002 #include "automation.h"
00003 #include "autos.h"
00004 #include "commonrender.h"
00005 #include "condition.h"
00006 #include "edl.h"
00007 #include "edlsession.h"
00008 #include "virtualconsole.h"
00009 #include "module.h"
00010 #include "mutex.h"
00011 #include "playabletracks.h"
00012 #include "renderengine.h"
00013 #include "intautos.h"
00014 #include "tracks.h"
00015 #include "transportque.h"
00016 #include "virtualnode.h"
00017 
00018 
00019 VirtualConsole::VirtualConsole(RenderEngine *renderengine, 
00020         CommonRender *commonrender,
00021         int data_type)
00022 {
00023         this->renderengine = renderengine;
00024         this->commonrender = commonrender;
00025         this->data_type = data_type;
00026         total_entry_nodes = 0;
00027         playable_tracks = 0;
00028         entry_nodes = 0;
00029         debug_tree = 0;
00030 }
00031 
00032 
00033 VirtualConsole::~VirtualConsole()
00034 {
00035         delete_virtual_console();
00036 
00037         delete playable_tracks;
00038 }
00039 
00040 
00041 void VirtualConsole::create_objects()
00042 {
00043         interrupt = 0;
00044         done = 0;
00045 
00046         get_playable_tracks();
00047         total_entry_nodes = playable_tracks->total;
00048         build_virtual_console(1);
00049 //dump();
00050 }
00051 
00052 void VirtualConsole::start_playback()
00053 {
00054         interrupt = 0;
00055         done = 0;
00056 }
00057 
00058 void VirtualConsole::get_playable_tracks()
00059 {
00060 }
00061 
00062 Module* VirtualConsole::module_of(Track *track)
00063 {
00064         for(int i = 0; i < commonrender->total_modules; i++)
00065         {
00066                 if(commonrender->modules[i]->track == track) 
00067                         return commonrender->modules[i];
00068         }
00069         return 0;
00070 }
00071 
00072 Module* VirtualConsole::module_number(int track_number)
00073 {
00074 // The track number is an absolute number of the track independant of
00075 // the tracks with matching data type but virtual modules only exist for
00076 // the matching data type.
00077 // Convert from absolute track number to data type track number.
00078         Track *current = renderengine->edl->tracks->first;
00079         int data_type_number = 0, number = 0;
00080 
00081         for( ; current; current = NEXT, number++)
00082         {
00083                 if(current->data_type == data_type)
00084                 {
00085                         if(number == track_number)
00086                                 return commonrender->modules[data_type_number];
00087                         else
00088                                 data_type_number++;
00089                 }
00090         }
00091 
00092 
00093         return 0;
00094 }
00095 
00096 void VirtualConsole::build_virtual_console(int persistent_plugins)
00097 {
00098 // allocate the entry nodes
00099         if(!entry_nodes)
00100         {
00101                 entry_nodes = new VirtualNode*[total_entry_nodes];
00102 
00103                 for(int i = 0; i < total_entry_nodes; i++)
00104                 {
00105                         entry_nodes[i] = new_entry_node(playable_tracks->values[i], 
00106                                 module_of(playable_tracks->values[i]), 
00107                                 i);
00108 
00109 // Expand the trees
00110                         entry_nodes[i]->expand(persistent_plugins, 
00111                                 commonrender->current_position);
00112                 }
00113                 commonrender->restart_plugins = 1;
00114         }
00115 //dump();
00116 }
00117 
00118 VirtualNode* VirtualConsole::new_entry_node(Track *track, 
00119         Module *module, 
00120         int track_number)
00121 {
00122         printf("VirtualConsole::new_entry_node should not be called\n");
00123         return 0;
00124 }
00125 
00126 void VirtualConsole::append_exit_node(VirtualNode *node)
00127 {
00128         node->is_exit = 1;
00129         exit_nodes.append(node);
00130 }
00131 
00132 void VirtualConsole::reset_attachments()
00133 {
00134         for(int i = 0; i < commonrender->total_modules; i++)
00135         {
00136                 commonrender->modules[i]->reset_attachments();
00137         }
00138 }
00139 
00140 void VirtualConsole::dump()
00141 {
00142         printf("VirtualConsole\n");
00143         printf(" Modules\n");
00144         for(int i = 0; i < commonrender->total_modules; i++)
00145                 commonrender->modules[i]->dump();
00146         printf(" Nodes\n");
00147         for(int i = 0; i < total_entry_nodes; i++)
00148                 entry_nodes[i]->dump(0);
00149 }
00150 
00151 
00152 int VirtualConsole::test_reconfigure(int64_t position, 
00153         int64_t &length, 
00154         int &last_playback)
00155 {
00156         int result = 0;
00157         Track *current_track;
00158         Module *module;
00159 
00160 // Test playback status against virtual console for current position.
00161         for(current_track = renderengine->edl->tracks->first;
00162                 current_track && !result;
00163                 current_track = current_track->next)
00164         {
00165                 if(current_track->data_type == data_type)
00166                 {
00167 // Playable status changed
00168                         if(playable_tracks->is_playable(current_track, 
00169                                 commonrender->current_position,
00170                                 1))
00171                         {
00172                                 if(!playable_tracks->is_listed(current_track))
00173                                         result = 1;
00174                         }
00175                         else
00176                         if(playable_tracks->is_listed(current_track))
00177                         {
00178                                 result = 1;
00179                         }
00180                 }
00181         }
00182 
00183 // Test plugins against virtual console at current position
00184         for(int i = 0; i < commonrender->total_modules && !result; i++)
00185                 result = commonrender->modules[i]->test_plugins();
00186 
00187 
00188 
00189 
00190 
00191 // Now get the length of time until next reconfiguration.
00192 // This part is not concerned with result.
00193 // Don't clip input length if only rendering 1 frame.
00194         if(length == 1) return result;
00195 
00196 
00197 
00198 
00199 
00200         int direction = renderengine->command->get_direction();
00201 // GCC 3.2 requires this or optimization error results.
00202         int64_t longest_duration1;
00203         int64_t longest_duration2;
00204         int64_t longest_duration3;
00205 
00206 // Length of time until next transition, edit, or effect change.
00207 // Why do we need the edit change?  Probably for changing to and from silence.
00208         for(current_track = renderengine->edl->tracks->first;
00209                 current_track;
00210                 current_track = current_track->next)
00211         {
00212                 if(current_track->data_type == data_type)
00213                 {
00214 // Test the transitions
00215                         longest_duration1 = current_track->edit_change_duration(
00216                                 commonrender->current_position, 
00217                                 length, 
00218                                 direction == PLAY_REVERSE, 
00219                                 1,
00220                                 1);
00221 
00222 
00223 // Test the edits
00224                         longest_duration2 = current_track->edit_change_duration(
00225                                 commonrender->current_position, 
00226                                 length, 
00227                                 direction, 
00228                                 0,
00229                                 1);
00230 
00231 
00232 // Test the plugins
00233                         longest_duration3 = current_track->plugin_change_duration(
00234                                 commonrender->current_position,
00235                                 length,
00236                                 direction == PLAY_REVERSE,
00237                                 1);
00238 
00239                         if(longest_duration1 < length)
00240                         {
00241                                 length = longest_duration1;
00242                                 last_playback = 0;
00243                         }
00244                         if(longest_duration2 < length)
00245                         {
00246                                 length = longest_duration2;
00247                                 last_playback = 0;
00248                         }
00249                         if(longest_duration3 < length)
00250                         {
00251                                 length = longest_duration3;
00252                                 last_playback = 0;
00253                         }
00254 
00255                 }
00256         }
00257 
00258         return result;
00259 }
00260 
00261 
00262 
00263 
00264 
00265 int VirtualConsole::delete_virtual_console()
00266 {
00267 // delete the virtual node tree
00268         for(int i = 0; i < total_entry_nodes; i++)
00269         {
00270                 delete entry_nodes[i];
00271         }
00272 // Seems to get allocated even if new[0].
00273         if(entry_nodes) delete [] entry_nodes;
00274         entry_nodes = 0;
00275         exit_nodes.remove_all();
00276 }
00277 
00278 

Generated on Sun Jan 8 13:39:02 2006 for Cinelerra-svn by  doxygen 1.4.4