changeset 70:302a8e35248c

Begin capnp RPC test
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 07 Oct 2016 12:07:17 +0100
parents 91fda9470ee2
children 6c908ee3ad3b
files Makefile capnproto/VampnProto.h capnproto/vamp.capnp capnproto/vamp.rpc.capnp
diffstat 4 files changed, 53 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Oct 06 14:33:12 2016 +0100
+++ b/Makefile	Fri Oct 07 12:07:17 2016 +0100
@@ -38,3 +38,5 @@
 distclean:	clean
 	rm -f bin/*
 
+# cancel implicit rule which otherwise could try to link %.capnp
+%:	%.o
--- a/capnproto/VampnProto.h	Thu Oct 06 14:33:12 2016 +0100
+++ b/capnproto/VampnProto.h	Fri Oct 07 12:07:17 2016 +0100
@@ -415,7 +415,7 @@
 
     static void
     readExtractorStaticData(Vamp::HostExt::PluginStaticData &d,
-                         const ExtractorStaticData::Reader &r) {
+                            const ExtractorStaticData::Reader &r) {
         
         d.pluginKey = r.getKey();
 
@@ -690,6 +690,28 @@
     }
 
     static void
+    buildFinishResponse(FinishResponse::Builder &b,
+                        const Vamp::HostExt::ProcessResponse &pr,
+                        const PluginHandleMapper &pmapper) {
+
+        b.setHandle(pmapper.pluginToHandle(pr.plugin));
+        auto f = b.initFeatures();
+        buildFeatureSet(f, pr.features,
+                        *pmapper.pluginToOutputIdMapper(pr.plugin));
+    }
+    
+    static void
+    readFinishResponse(Vamp::HostExt::ProcessResponse &pr,
+                       const FinishResponse::Reader &r,
+                       const PluginHandleMapper &pmapper) {
+
+        auto h = r.getHandle();
+        pr.plugin = pmapper.handleToPlugin(h);
+        readFeatureSet(pr.features, r.getFeatures(),
+                       *pmapper.handleToOutputIdMapper(r.getHandle()));
+    }
+
+    static void
     buildRpcRequest_List(RpcRequest::Builder &b) {
         b.getRequest().initList();
     }
@@ -780,7 +802,7 @@
                              const PluginHandleMapper &pmapper) {
 
         auto u = b.getResponse().initFinish();
-        buildProcessResponse(u, pr, pmapper);
+        buildFinishResponse(u, pr, pmapper);
     }
 
     static void
@@ -971,7 +993,7 @@
             throw std::logic_error("not a finish response");
         }
         resp = {};
-        readProcessResponse(resp, r.getResponse().getFinish(), pmapper);
+        readFinishResponse(resp, r.getResponse().getFinish(), pmapper);
     }
 };
 
--- a/capnproto/vamp.capnp	Thu Oct 06 14:33:12 2016 +0100
+++ b/capnproto/vamp.capnp	Fri Oct 07 12:07:17 2016 +0100
@@ -161,12 +161,19 @@
     handle             @0  :Int32;
 }
 
+struct FinishResponse {
+    handle             @0  :Int32;
+    features           @1  :FeatureSet;
+}
+
 struct Error {
     code               @0  :Int32;
     message            @1  :Text;
 }
 
 struct RpcRequest {
+    # Request bundle for use when using Cap'n Proto serialisation without
+    # Cap'n Proto RPC layer.
     request :union {
 	list           @0  :ListRequest;
 	load           @1  :LoadRequest;
@@ -177,13 +184,15 @@
 }
 
 struct RpcResponse {
+    # Response bundle for use when using Cap'n Proto serialisation without
+    # Cap'n Proto RPC layer.
     response :union {
         error          @0  :Error;
 	list           @1  :ListResponse;
 	load           @2  :LoadResponse;
 	configure      @3  :ConfigurationResponse;
 	process        @4  :ProcessResponse;
-	finish         @5  :ProcessResponse;
+	finish         @5  :FinishResponse;
     }
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/capnproto/vamp.rpc.capnp	Fri Oct 07 12:07:17 2016 +0100
@@ -0,0 +1,16 @@
+@0xbe97303b9e5b3429;
+
+using Cxx = import "/capnp/c++.capnp";
+$Cxx.namespace("vampipe::rpc");
+
+using Vamp = import "vamp.capnp";
+
+interface Piper {
+    # RPC interface for use when using Cap'n Proto RPC layer.
+    list               @0 (req :Vamp.ListRequest) -> (resp :Vamp.ListResponse);
+    load               @1 (req :Vamp.LoadRequest) -> (resp :Vamp.LoadResponse);
+    configure          @2 (req :Vamp.ConfigurationRequest) -> (resp :Vamp.ConfigurationResponse);
+    process            @3 (req :Vamp.ProcessRequest) -> (resp :Vamp.ProcessResponse);
+    finish             @4 (req :Vamp.FinishRequest) -> (resp :Vamp.FinishResponse);
+}
+