4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcsignals.h"
25 #include "edlsession.h"
28 #include "pluginserver.h"
29 #include "preferences.h"
30 #include "recordablevtracks.h"
31 #include "mainsession.h"
34 #include "vpluginarray.h"
38 #define RING_BUFFERS 2
42 VPluginArray::VPluginArray()
43 : PluginArray(TRACK_VIDEO)
48 VPluginArray::~VPluginArray()
50 file->stop_video_thread();
51 for(int i = 0; i < total_tracks(); i++)
58 void VPluginArray::get_recordable_tracks()
60 tracks = new RecordableVTracks(edl->tracks);
63 int64_t VPluginArray::get_bufsize()
68 void VPluginArray::create_buffers()
70 file->start_video_thread(buffer_size,
71 edl->session->color_model,
74 // if(!plugin_server->realtime) realtime_buffers = file->get_video_buffer();
77 void VPluginArray::get_buffers()
79 if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
82 void VPluginArray::create_modules()
84 modules = new Module*[total_tracks()];
85 for(int i = 0; i < total_tracks(); i++)
87 modules[i] = new VModule(0, 0, this, tracks->values[i]);
88 modules[i]->cache = cache;
89 modules[i]->edl = edl;
90 modules[i]->create_objects();
91 modules[i]->render_init();
96 void VPluginArray::process_realtime(int module,
97 int64_t input_position,
100 values[module]->process_buffer(realtime_buffers[module],
102 edl->session->frame_rate,
107 int VPluginArray::process_loop(int module, int64_t &write_length)
109 if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
111 // Convert from array of frames to array of tracks
112 VFrame **temp_buffer;
113 temp_buffer = new VFrame*[total_tracks()];
114 for(int i = 0; i < total_tracks(); i++)
116 temp_buffer[i] = realtime_buffers[i][0];
119 int result = values[module]->process_loop(realtime_buffers[module], write_length);
120 delete [] temp_buffer;
124 int VPluginArray::write_buffers(int64_t len)
126 int result = file->write_video_buffer(len);
127 realtime_buffers = 0;
129 // if(!plugin_server->realtime && !done && !result) realtime_buffers = file->get_video_buffer();
134 int VPluginArray::total_tracks()
136 return tracks->total;
139 Track* VPluginArray::track_number(int number)
141 return (Track*)tracks->values[number];