comparison VamPipePluginLibrary.cpp @ 109:9d20eb251fbc

Update again to latest plugin-terminology-free schema
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 06 Oct 2016 14:32:58 +0100
parents 19d4ac80cb5a
children 873ce3bfa776
comparison
equal deleted inserted replaced
108:19d4ac80cb5a 109:9d20eb251fbc
124 124
125 return response; 125 return response;
126 } 126 }
127 127
128 string 128 string
129 VamPipePluginLibrary::processRawImpl(int pluginHandle, 129 VamPipePluginLibrary::processRawImpl(int handle,
130 const float *const *inputBuffers, 130 const float *const *inputBuffers,
131 int sec, 131 int sec,
132 int nsec) 132 int nsec)
133 { 133 {
134 Vamp::Plugin *plugin = m_mapper.handleToPlugin(pluginHandle); 134 Vamp::Plugin *plugin = m_mapper.handleToPlugin(handle);
135 if (!plugin) { 135 if (!plugin) {
136 return VampJson::fromError("unknown plugin handle", RRType::Process) 136 return VampJson::fromError("unknown plugin handle", RRType::Process)
137 .dump(); 137 .dump();
138 } 138 }
139 139
140 if (!m_mapper.isConfigured(pluginHandle)) { 140 if (!m_mapper.isConfigured(handle)) {
141 return VampJson::fromError("plugin has not been configured", RRType::Process) 141 return VampJson::fromError("plugin has not been configured", RRType::Process)
142 .dump(); 142 .dump();
143 } 143 }
144 144
145 Vamp::RealTime timestamp(sec, nsec); 145 Vamp::RealTime timestamp(sec, nsec);
148 resp.plugin = plugin; 148 resp.plugin = plugin;
149 resp.features = plugin->process(inputBuffers, timestamp); 149 resp.features = plugin->process(inputBuffers, timestamp);
150 150
151 m_useBase64 = true; 151 m_useBase64 = true;
152 152
153 return VampJson::fromVampResponse_Process 153 return VampJson::fromRpcResponse_Process
154 (resp, m_mapper, 154 (resp, m_mapper,
155 VampJson::BufferSerialisation::Base64) 155 VampJson::BufferSerialisation::Base64)
156 .dump(); 156 .dump();
157 } 157 }
158 158
179 Json rj; 179 Json rj;
180 180
181 switch (type) { 181 switch (type) {
182 182
183 case RRType::List: 183 case RRType::List:
184 rj = VampJson::fromVampResponse_List(listPluginData()); 184 rj = VampJson::fromRpcResponse_List(listPluginData());
185 break; 185 break;
186 186
187 case RRType::Load: 187 case RRType::Load:
188 { 188 {
189 auto req = VampJson::toVampRequest_Load(j, err); 189 auto req = VampJson::toRpcRequest_Load(j, err);
190 if (err != "") { 190 if (err != "") {
191 rj = VampJson::fromError(err, type); 191 rj = VampJson::fromError(err, type);
192 } else { 192 } else {
193 auto resp = loadPlugin(req, err); 193 auto resp = loadPlugin(req, err);
194 if (err != "") { 194 if (err != "") {
195 rj = VampJson::fromError(err, type); 195 rj = VampJson::fromError(err, type);
196 } else { 196 } else {
197 m_mapper.addPlugin(resp.plugin); 197 m_mapper.addPlugin(resp.plugin);
198 rj = VampJson::fromVampResponse_Load(resp, m_mapper); 198 rj = VampJson::fromRpcResponse_Load(resp, m_mapper);
199 } 199 }
200 } 200 }
201 break; 201 break;
202 } 202 }
203 203
204 case RRType::Configure: 204 case RRType::Configure:
205 { 205 {
206 auto req = VampJson::toVampRequest_Configure(j, m_mapper, err); 206 auto req = VampJson::toRpcRequest_Configure(j, m_mapper, err);
207 if (err != "") { 207 if (err != "") {
208 rj = VampJson::fromError(err, type); 208 rj = VampJson::fromError(err, type);
209 } else { 209 } else {
210 auto h = m_mapper.pluginToHandle(req.plugin); 210 auto h = m_mapper.pluginToHandle(req.plugin);
211 if (h == m_mapper.INVALID_HANDLE) { 211 if (h == m_mapper.INVALID_HANDLE) {
218 rj = VampJson::fromError(err, type); 218 rj = VampJson::fromError(err, type);
219 } else { 219 } else {
220 m_mapper.markConfigured(h, 220 m_mapper.markConfigured(h,
221 req.configuration.channelCount, 221 req.configuration.channelCount,
222 req.configuration.blockSize); 222 req.configuration.blockSize);
223 rj = VampJson::fromVampResponse_Configure(resp, m_mapper); 223 rj = VampJson::fromRpcResponse_Configure(resp, m_mapper);
224 } 224 }
225 } 225 }
226 } 226 }
227 break; 227 break;
228 } 228 }
229 229
230 case RRType::Process: 230 case RRType::Process:
231 { 231 {
232 VampJson::BufferSerialisation serialisation; 232 VampJson::BufferSerialisation serialisation;
233 233
234 auto req = VampJson::toVampRequest_Process(j, m_mapper, 234 auto req = VampJson::toRpcRequest_Process(j, m_mapper,
235 serialisation, err); 235 serialisation, err);
236 if (err != "") { 236 if (err != "") {
237 rj = VampJson::fromError(err, type); 237 rj = VampJson::fromError(err, type);
238 } else { 238 } else {
239 auto h = m_mapper.pluginToHandle(req.plugin); 239 auto h = m_mapper.pluginToHandle(req.plugin);
266 if (fbuffers) { 266 if (fbuffers) {
267 Vamp::HostExt::ProcessResponse resp; 267 Vamp::HostExt::ProcessResponse resp;
268 resp.plugin = req.plugin; 268 resp.plugin = req.plugin;
269 resp.features = req.plugin->process(fbuffers, req.timestamp); 269 resp.features = req.plugin->process(fbuffers, req.timestamp);
270 delete[] fbuffers; 270 delete[] fbuffers;
271 rj = VampJson::fromVampResponse_Process 271 rj = VampJson::fromRpcResponse_Process
272 (resp, m_mapper, serialisation); 272 (resp, m_mapper, serialisation);
273 } 273 }
274 } 274 }
275 } 275 }
276 break; 276 break;
277 } 277 }
278 278
279 case RRType::Finish: 279 case RRType::Finish:
280 { 280 {
281 auto req = VampJson::toVampRequest_Finish(j, m_mapper, err); 281 auto req = VampJson::toRpcRequest_Finish(j, m_mapper, err);
282 if (err != "") { 282 if (err != "") {
283 rj = VampJson::fromError(err, type); 283 rj = VampJson::fromError(err, type);
284 } else { 284 } else {
285 auto h = m_mapper.pluginToHandle(req.plugin); 285 auto h = m_mapper.pluginToHandle(req.plugin);
286 if (h == m_mapper.INVALID_HANDLE) { 286 if (h == m_mapper.INVALID_HANDLE) {
291 291
292 Vamp::HostExt::ProcessResponse resp; 292 Vamp::HostExt::ProcessResponse resp;
293 resp.plugin = req.plugin; 293 resp.plugin = req.plugin;
294 resp.features = req.plugin->getRemainingFeatures(); 294 resp.features = req.plugin->getRemainingFeatures();
295 295
296 rj = VampJson::fromVampResponse_Finish 296 rj = VampJson::fromRpcResponse_Finish
297 (resp, m_mapper, serialisation); 297 (resp, m_mapper, serialisation);
298 298
299 m_mapper.removePlugin(h); 299 m_mapper.removePlugin(h);
300 delete req.plugin; 300 delete req.plugin;
301 } 301 }