changeset 16:913fc1d3710a

Create process request in JSON version, plus a fix
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 18 May 2016 14:38:27 +0100
parents d907576aa299
children 3ef01276e15e
files json/VampJson.h utilities/json-cli.cpp
diffstat 2 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/json/VampJson.h	Wed May 18 13:54:33 2016 +0100
+++ b/json/VampJson.h	Wed May 18 14:38:27 2016 +0100
@@ -759,6 +759,29 @@
 
         return cr;
     }
+
+    static json11::Json
+    fromProcessRequest(const Vamp::HostExt::ProcessRequest &r,
+                       PluginHandleMapper &mapper) {
+
+        json11::Json::object jo;
+        jo["pluginHandle"] = mapper.pluginToHandle(r.plugin);
+
+        json11::Json::object io;
+        io["timestamp"] = fromRealTime(r.timestamp);
+
+        json11::Json::array chans;
+        for (size_t i = 0; i < r.inputBuffers.size(); ++i) {
+            json11::Json::object c;
+            c["b64values"] = fromFloatBuffer(r.inputBuffers[i].data(),
+                                             r.inputBuffers[i].size());
+            chans.push_back(c);
+        }
+        io["inputBuffers"] = chans;
+        
+        jo["processInput"] = io;
+        return json11::Json(jo);
+    }
 };
 
 }
--- a/utilities/json-cli.cpp	Wed May 18 13:54:33 2016 +0100
+++ b/utilities/json-cli.cpp	Wed May 18 14:38:27 2016 +0100
@@ -77,15 +77,15 @@
 configurePlugin(Vamp::Plugin *plugin, json11::Json j) {
     
     auto config = VampJson::toPluginConfiguration(j);
+    Vamp::HostExt::ConfigurationRequest req;
+    req.plugin = plugin;
+    req.configuration = config;
     auto loader = Vamp::HostExt::PluginLoader::getInstance();
-    auto outputs = loader->configurePlugin(plugin, config);
 
-    if (outputs.empty()) {
+    auto response = loader->configurePlugin(req);
+    if (response.outputs.empty()) {
 	throw VampJson::Failure("plugin initialisation failed (invalid channelCount, stepSize, blockSize?)");
     }
-
-    Vamp::HostExt::ConfigurationResponse response;
-    response.outputs = outputs;
     return response;
 }