Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / vpluginarray.C
blobba642a6fd677b3f4bb9b970dfbcc7980ece80d60
1 #include "cache.h"
2 #include "edl.h"
3 #include "edlsession.h"
4 #include "file.h"
5 #include "mwindow.h"
6 #include "pluginserver.h"
7 #include "preferences.h"
8 #include "recordablevtracks.h"
9 #include "mainsession.h"
10 #include "vframe.h"
11 #include "vmodule.h"
12 #include "vpluginarray.h"
13 #include "vtrack.h"
16 #define RING_BUFFERS 2
20 VPluginArray::VPluginArray()
21  : PluginArray(TRACK_VIDEO)
23         realtime_buffers = 0;
26 VPluginArray::~VPluginArray()
28         file->stop_video_thread();
29         for(int i = 0; i < total_tracks(); i++)
30         {
31                 delete modules[i];
32         }
33         delete tracks;
36 void VPluginArray::get_recordable_tracks()
38         tracks = new RecordableVTracks(edl->tracks);
41 int64_t VPluginArray::get_bufsize()
43         return 1;
46 void VPluginArray::create_buffers()
48         file->start_video_thread(buffer_size,
49                 edl->session->color_model,
50                 RING_BUFFERS,
51                 0);
52 //      if(!plugin_server->realtime) realtime_buffers = file->get_video_buffer();
55 void VPluginArray::get_buffers()
57         if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
60 void VPluginArray::create_modules()
62         modules = new Module*[total_tracks()];
63         for(int i = 0; i < total_tracks(); i++)
64         {
65                 modules[i] = new VModule(0, 0, this, tracks->values[i]);
66                 modules[i]->cache = cache;
67                 modules[i]->edl = edl;
68                 modules[i]->create_objects();
69                 modules[i]->render_init();
70         }
74 void VPluginArray::process_realtime(int module, 
75         int64_t input_position, 
76         int64_t len)
78         values[module]->process_buffer(realtime_buffers[module], 
79                         input_position, 
80                         edl->session->frame_rate,
81                         0,
82                         PLAY_FORWARD);
85 int VPluginArray::process_loop(int module, int64_t &write_length)
87         if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
89 // Convert from array of frames to array of tracks
90         VFrame **temp_buffer;
91         temp_buffer = new VFrame*[total_tracks()];
92         for(int i = 0; i < total_tracks(); i++)
93         {
94                 temp_buffer[i] = realtime_buffers[i][0];
95         }
97         int result = values[module]->process_loop(realtime_buffers[module], write_length);
98         delete [] temp_buffer;
99         return result;
102 int VPluginArray::write_buffers(int64_t len)
104         int result = file->write_video_buffer(len);
105         realtime_buffers = 0;
107 //      if(!plugin_server->realtime && !done && !result) realtime_buffers = file->get_video_buffer();
108         return result;
112 int VPluginArray::total_tracks()
114         return tracks->total;
117 Track* VPluginArray::track_number(int number)
119         return (Track*)tracks->values[number];
124 //      Local Variables:
125 //      mode: C++
126 //      c-file-style: "linux"
127 //      End: