comparison VamPipePluginLibrary.cpp @ 85:1a9ba1c08f9e

Merge from branch process-noparse
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 14 Sep 2016 14:43:37 +0100
parents a6ab5fd80eb7
children 0e1909abe921
comparison
equal deleted inserted replaced
81:5e6ff69b4209 85:1a9ba1c08f9e
191 191
192 return response; 192 return response;
193 } 193 }
194 194
195 string 195 string
196 VamPipePluginLibrary::processRawImpl(int pluginHandle,
197 const float *const *inputBuffers,
198 int sec,
199 int nsec)
200 {
201 RequestOrResponse response;
202 response.direction = RequestOrResponse::Response;
203 response.type = RRType::Process;
204
205 try {
206 if (!m_mapper.isConfigured(pluginHandle)) {
207 throw runtime_error("plugin has not been configured");
208 }
209
210 Vamp::Plugin *plugin = m_mapper.handleToPlugin(pluginHandle);
211 Vamp::RealTime timestamp(sec, nsec);
212
213 response.processResponse.features = plugin->process(inputBuffers, timestamp);
214 response.success = true;
215
216 m_useBase64 = true;
217
218 return writeResponse(response);
219
220 } catch (const std::exception &e) {
221 return VampJson::fromException(e, RRType::Process).dump();
222 }
223 }
224
225 string
196 VamPipePluginLibrary::requestJsonImpl(string req) 226 VamPipePluginLibrary::requestJsonImpl(string req)
197 { 227 {
198 RequestOrResponse request; 228 RequestOrResponse request;
199 229
200 try { 230 try {
201 request = readRequest(req); 231 request = readRequest(req);
202 } catch (const std::exception &e) { 232 } catch (const std::exception &e) {
203 std::cerr << "FAILURE" << std::endl;
204 return VampJson::fromException(e, RRType::NotValid).dump(); 233 return VampJson::fromException(e, RRType::NotValid).dump();
205 } 234 }
206 235
207 RequestOrResponse response; 236 RequestOrResponse response;
208 response.direction = RequestOrResponse::Response; 237 response.direction = RequestOrResponse::Response;
252 281
253 int channels = int(preq.inputBuffers.size()); 282 int channels = int(preq.inputBuffers.size());
254 if (channels != m_mapper.getChannelCount(h)) { 283 if (channels != m_mapper.getChannelCount(h)) {
255 throw runtime_error("wrong number of channels supplied to process"); 284 throw runtime_error("wrong number of channels supplied to process");
256 } 285 }
257 286
258 const float **fbuffers = new const float *[channels]; 287 const float **fbuffers = new const float *[channels];
259 for (int i = 0; i < channels; ++i) { 288 for (int i = 0; i < channels; ++i) {
260 if (int(preq.inputBuffers[i].size()) != m_mapper.getBlockSize(h)) { 289 if (int(preq.inputBuffers[i].size()) != m_mapper.getBlockSize(h)) {
261 delete[] fbuffers; 290 delete[] fbuffers;
262 throw runtime_error("wrong block size supplied to process"); 291 throw runtime_error("wrong block size supplied to process");