Mercurial > hg > piper-cpp
comparison 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 |
comparison
equal
deleted
inserted
replaced
50:12e3b396544c | 51:f4244a2d55ac |
---|---|
992 return json11::Json(jo); | 992 return json11::Json(jo); |
993 } | 993 } |
994 | 994 |
995 static json11::Json | 995 static json11::Json |
996 fromVampResponse_Process(const Vamp::HostExt::ProcessResponse &resp, | 996 fromVampResponse_Process(const Vamp::HostExt::ProcessResponse &resp, |
997 const PluginOutputIdMapper &omapper, | 997 const PluginHandleMapper &pmapper, |
998 BufferSerialisation serialisation) { | 998 BufferSerialisation serialisation) { |
999 | 999 |
1000 json11::Json::object jo; | 1000 json11::Json::object jo; |
1001 jo["type"] = "process"; | 1001 jo["type"] = "process"; |
1002 jo["success"] = true; | 1002 jo["success"] = true; |
1003 jo["errorText"] = ""; | 1003 jo["errorText"] = ""; |
1004 jo["content"] = fromFeatureSet(resp.features, omapper, serialisation); | 1004 jo["content"] = fromFeatureSet(resp.features, |
1005 pmapper.pluginToOutputIdMapper(resp.plugin), | |
1006 serialisation); | |
1005 return json11::Json(jo); | 1007 return json11::Json(jo); |
1006 } | 1008 } |
1007 | 1009 |
1008 static json11::Json | 1010 static json11::Json |
1009 fromVampRequest_Finish(Vamp::Plugin *p, | 1011 fromVampRequest_Finish(Vamp::Plugin *p, |
1017 return json11::Json(jo); | 1019 return json11::Json(jo); |
1018 } | 1020 } |
1019 | 1021 |
1020 static json11::Json | 1022 static json11::Json |
1021 fromVampResponse_Finish(const Vamp::HostExt::ProcessResponse &resp, | 1023 fromVampResponse_Finish(const Vamp::HostExt::ProcessResponse &resp, |
1022 const PluginOutputIdMapper &omapper, | 1024 const PluginHandleMapper &pmapper, |
1023 BufferSerialisation serialisation) { | 1025 BufferSerialisation serialisation) { |
1024 | 1026 |
1025 json11::Json::object jo; | 1027 json11::Json::object jo; |
1026 jo["type"] = "finish"; | 1028 jo["type"] = "finish"; |
1027 jo["success"] = true; | 1029 jo["success"] = true; |
1028 jo["errorText"] = ""; | 1030 jo["errorText"] = ""; |
1029 jo["content"] = fromFeatureSet(resp.features, omapper, serialisation); | 1031 jo["content"] = fromFeatureSet(resp.features, |
1032 pmapper.pluginToOutputIdMapper(resp.plugin), | |
1033 serialisation); | |
1030 return json11::Json(jo); | 1034 return json11::Json(jo); |
1031 } | 1035 } |
1032 | 1036 |
1033 static json11::Json | 1037 static json11::Json |
1034 fromException(const std::exception &e, RRType responseType) { | 1038 fromException(const std::exception &e, RRType responseType) { |
1151 return toProcessRequest(j["content"], pmapper, serialisation); | 1155 return toProcessRequest(j["content"], pmapper, serialisation); |
1152 } | 1156 } |
1153 | 1157 |
1154 static Vamp::HostExt::ProcessResponse | 1158 static Vamp::HostExt::ProcessResponse |
1155 toVampResponse_Process(json11::Json j, | 1159 toVampResponse_Process(json11::Json j, |
1156 const PluginOutputIdMapper &omapper, | 1160 const PluginHandleMapper &pmapper, |
1157 BufferSerialisation &serialisation) { | 1161 BufferSerialisation &serialisation) { |
1158 | 1162 |
1159 Vamp::HostExt::ProcessResponse resp; | 1163 Vamp::HostExt::ProcessResponse resp; |
1160 if (successful(j)) { | 1164 if (successful(j)) { |
1161 resp.features = toFeatureSet(j["content"], omapper, serialisation); | 1165 auto jc = j["content"]; |
1166 resp.features = toFeatureSet | |
1167 (jc["features"], | |
1168 pmapper.handleToOutputIdMapper(jc["pluginHandle"].int_value()), | |
1169 serialisation); | |
1162 } | 1170 } |
1163 return resp; | 1171 return resp; |
1164 } | 1172 } |
1165 | 1173 |
1166 static Vamp::Plugin * | 1174 static Vamp::Plugin * |
1170 return pmapper.handleToPlugin(j["content"]["pluginHandle"].int_value()); | 1178 return pmapper.handleToPlugin(j["content"]["pluginHandle"].int_value()); |
1171 } | 1179 } |
1172 | 1180 |
1173 static Vamp::HostExt::ProcessResponse | 1181 static Vamp::HostExt::ProcessResponse |
1174 toVampResponse_Finish(json11::Json j, | 1182 toVampResponse_Finish(json11::Json j, |
1175 const PluginOutputIdMapper &omapper, | 1183 const PluginHandleMapper &pmapper, |
1176 BufferSerialisation &serialisation) { | 1184 BufferSerialisation &serialisation) { |
1177 | 1185 |
1178 Vamp::HostExt::ProcessResponse resp; | 1186 Vamp::HostExt::ProcessResponse resp; |
1179 if (successful(j)) { | 1187 if (successful(j)) { |
1180 resp.features = toFeatureSet(j["content"], omapper, serialisation); | 1188 auto jc = j["content"]; |
1189 resp.features = toFeatureSet | |
1190 (jc["features"], | |
1191 pmapper.handleToOutputIdMapper(jc["pluginHandle"].int_value()), | |
1192 serialisation); | |
1181 } | 1193 } |
1182 return resp; | 1194 return resp; |
1183 } | 1195 } |
1184 }; | 1196 }; |
1185 | 1197 |