diff json/VampJson.h @ 51:f4244a2d55ac

Introduce and use output id mappers
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 16 Sep 2016 15:10:57 +0100
parents f3f7561233d6
children e90fd30990eb
line wrap: on
line diff
--- a/json/VampJson.h	Fri Sep 16 14:15:41 2016 +0100
+++ b/json/VampJson.h	Fri Sep 16 15:10:57 2016 +0100
@@ -994,14 +994,16 @@
 
     static json11::Json
     fromVampResponse_Process(const Vamp::HostExt::ProcessResponse &resp,
-                             const PluginOutputIdMapper &omapper,
+                             const PluginHandleMapper &pmapper,
                              BufferSerialisation serialisation) {
         
         json11::Json::object jo;
         jo["type"] = "process";
         jo["success"] = true;
         jo["errorText"] = "";
-        jo["content"] = fromFeatureSet(resp.features, omapper, serialisation);
+        jo["content"] = fromFeatureSet(resp.features,
+                                       pmapper.pluginToOutputIdMapper(resp.plugin),
+                                       serialisation);
         return json11::Json(jo);
     }
     
@@ -1019,14 +1021,16 @@
     
     static json11::Json
     fromVampResponse_Finish(const Vamp::HostExt::ProcessResponse &resp,
-                            const PluginOutputIdMapper &omapper,
+                            const PluginHandleMapper &pmapper,
                             BufferSerialisation serialisation) {
 
         json11::Json::object jo;
         jo["type"] = "finish";
         jo["success"] = true;
         jo["errorText"] = "";
-        jo["content"] = fromFeatureSet(resp.features, omapper, serialisation);
+        jo["content"] = fromFeatureSet(resp.features,
+                                       pmapper.pluginToOutputIdMapper(resp.plugin),
+                                       serialisation);
         return json11::Json(jo);
     }
 
@@ -1153,12 +1157,16 @@
     
     static Vamp::HostExt::ProcessResponse
     toVampResponse_Process(json11::Json j,
-                           const PluginOutputIdMapper &omapper,
+                           const PluginHandleMapper &pmapper,
                            BufferSerialisation &serialisation) {
         
         Vamp::HostExt::ProcessResponse resp;
         if (successful(j)) {
-            resp.features = toFeatureSet(j["content"], omapper, serialisation);
+            auto jc = j["content"];
+            resp.features = toFeatureSet
+                (jc["features"],
+                 pmapper.handleToOutputIdMapper(jc["pluginHandle"].int_value()),
+                 serialisation);
         }
         return resp;
     }
@@ -1172,12 +1180,16 @@
     
     static Vamp::HostExt::ProcessResponse
     toVampResponse_Finish(json11::Json j,
-                          const PluginOutputIdMapper &omapper,
+                          const PluginHandleMapper &pmapper,
                           BufferSerialisation &serialisation) {
         
         Vamp::HostExt::ProcessResponse resp;
         if (successful(j)) {
-            resp.features = toFeatureSet(j["content"], omapper, serialisation);
+            auto jc = j["content"];
+            resp.features = toFeatureSet
+                (jc["features"],
+                 pmapper.handleToOutputIdMapper(jc["pluginHandle"].int_value()),
+                 serialisation);
         }
         return resp;
     }