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
24 #include "edlsession.h"
27 #include "pluginserver.h"
28 #include "preferences.h"
29 #include "recordablevtracks.h"
30 #include "mainsession.h"
33 #include "vpluginarray.h"
37 #define RING_BUFFERS 2
41 VPluginArray::VPluginArray()
42 : PluginArray(TRACK_VIDEO)
47 VPluginArray::~VPluginArray()
49 file->stop_video_thread();
50 for(int i = 0; i < total_tracks(); i++)
57 void VPluginArray::get_recordable_tracks()
59 tracks = new RecordableVTracks(edl->tracks);
62 int64_t VPluginArray::get_bufsize()
67 void VPluginArray::create_buffers()
69 file->start_video_thread(buffer_size,
70 edl->session->color_model,
73 // if(!plugin_server->realtime) realtime_buffers = file->get_video_buffer();
76 void VPluginArray::get_buffers()
78 if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
81 void VPluginArray::create_modules()
83 modules = new Module*[total_tracks()];
84 for(int i = 0; i < total_tracks(); i++)
86 modules[i] = new VModule(0, 0, this, tracks->values[i]);
87 modules[i]->cache = cache;
88 modules[i]->edl = edl;
89 modules[i]->create_objects();
90 modules[i]->render_init();
95 void VPluginArray::process_realtime(int module,
96 int64_t input_position,
99 values[module]->process_buffer(realtime_buffers[module],
101 edl->session->frame_rate,
106 int VPluginArray::process_loop(int module, int64_t &write_length)
108 if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
110 // Convert from array of frames to array of tracks
111 VFrame **temp_buffer;
112 temp_buffer = new VFrame*[total_tracks()];
113 for(int i = 0; i < total_tracks(); i++)
115 temp_buffer[i] = realtime_buffers[i][0];
118 int result = values[module]->process_loop(realtime_buffers[module], write_length);
119 delete [] temp_buffer;
123 int VPluginArray::write_buffers(int64_t len)
125 int result = file->write_video_buffer(len);
126 realtime_buffers = 0;
128 // if(!plugin_server->realtime && !done && !result) realtime_buffers = file->get_video_buffer();
133 int VPluginArray::total_tracks()
135 return tracks->total;
138 Track* VPluginArray::track_number(int number)
140 return (Track*)tracks->values[number];