diff json/VampJson.h @ 64:85ec33975434

Support split OutputDescriptor, and plugins rather than pluginData in listResponse from SDK
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 23 Sep 2016 14:20:29 +0100
parents 77833938f0f8
children 2d866edd79d5
line wrap: on
line diff
--- a/json/VampJson.h	Fri Sep 23 14:20:06 2016 +0100
+++ b/json/VampJson.h	Fri Sep 23 14:20:29 2016 +0100
@@ -190,9 +190,8 @@
     }
 
     static json11::Json
-    fromOutputDescriptor(const Vamp::Plugin::OutputDescriptor &desc) {
+    fromConfiguredOutputDescriptor(const Vamp::Plugin::OutputDescriptor &desc) {
         json11::Json::object jo {
-            { "basic", fromBasicDescriptor(desc) },
             { "unit", desc.unit },
             { "sampleType", fromSampleType(desc.sampleType) },
             { "sampleRate", desc.sampleRate },
@@ -212,16 +211,23 @@
         return json11::Json(jo);
     }
     
+    static json11::Json
+    fromOutputDescriptor(const Vamp::Plugin::OutputDescriptor &desc) {
+        json11::Json::object jo {
+            { "basic", fromBasicDescriptor(desc) },
+            { "configured", fromConfiguredOutputDescriptor(desc) }
+        };
+        return json11::Json(jo);
+    }
+    
     static Vamp::Plugin::OutputDescriptor
-    toOutputDescriptor(json11::Json j) {
+    toConfiguredOutputDescriptor(json11::Json j) {
 
         Vamp::Plugin::OutputDescriptor od;
         if (!j.is_object()) {
             throw Failure("object expected for output descriptor");
         }
     
-        toBasicDescriptor(j["basic"], od);
-
         od.unit = j["unit"].string_value();
 
         od.sampleType = toSampleType(j["sampleType"].string_value());
@@ -257,6 +263,21 @@
 
         return od;
     }
+    
+    static Vamp::Plugin::OutputDescriptor
+    toOutputDescriptor(json11::Json j) {
+
+        Vamp::Plugin::OutputDescriptor od;
+        if (!j.is_object()) {
+            throw Failure("object expected for output descriptor");
+        }
+
+        od = toConfiguredOutputDescriptor(j);
+    
+        toBasicDescriptor(j["basic"], od);
+
+        return od;
+    }
 
     static json11::Json
     fromParameterDescriptor(const Vamp::PluginBase::ParameterDescriptor &desc) {
@@ -933,7 +954,7 @@
         jo["success"] = true;
 
         json11::Json::array arr;
-        for (const auto &a: resp.pluginData) {
+        for (const auto &a: resp.plugins) {
             arr.push_back(fromPluginStaticData(a));
         }
         json11::Json::object po;
@@ -1123,7 +1144,7 @@
         Vamp::HostExt::ListResponse resp;
         if (successful(j)) {
             for (const auto &a: j["content"]["plugins"].array_items()) {
-                resp.pluginData.push_back(toPluginStaticData(a));
+                resp.plugins.push_back(toPluginStaticData(a));
             }
         }
         return resp;