comparison vamp-capnp/VampnProto.h @ 220:02de5df3a884

Add static output descriptor, pass through type URI Note that the server doesn't actually populate any type URIs yet, so this is only half-tested.
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 08 Jun 2017 16:17:03 +0100
parents 328ffacfc70e
children 292ec9b50280
comparison
equal deleted inserted replaced
219:db929669e7d3 220:02de5df3a884
2 2
3 /* 3 /*
4 Piper C++ 4 Piper C++
5 5
6 Centre for Digital Music, Queen Mary, University of London. 6 Centre for Digital Music, Queen Mary, University of London.
7 Copyright 2015-2016 QMUL. 7 Copyright 2015-2017 QMUL.
8 8
9 Permission is hereby granted, free of charge, to any person 9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation 10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without 11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use, copy, 12 restriction, including without limitation the rights to use, copy,
129 } 129 }
130 throw std::logic_error("unexpected Capnp SampleType enum value"); 130 throw std::logic_error("unexpected Capnp SampleType enum value");
131 } 131 }
132 132
133 static void 133 static void
134 buildStaticOutputDescriptor(piper::StaticOutputDescriptor::Builder &b,
135 const StaticOutputDescriptor &sd) {
136 b.setTypeURI(sd.typeURI);
137 }
138
139 static void
134 buildConfiguredOutputDescriptor(piper::ConfiguredOutputDescriptor::Builder &b, 140 buildConfiguredOutputDescriptor(piper::ConfiguredOutputDescriptor::Builder &b,
135 const Vamp::Plugin::OutputDescriptor &od) { 141 const Vamp::Plugin::OutputDescriptor &od) {
136 142
137 b.setUnit(od.unit); 143 b.setUnit(od.unit);
138 b.setSampleType(fromSampleType(od.sampleType)); 144 b.setSampleType(fromSampleType(od.sampleType));
161 } 167 }
162 } 168 }
163 169
164 static void 170 static void
165 buildOutputDescriptor(piper::OutputDescriptor::Builder &b, 171 buildOutputDescriptor(piper::OutputDescriptor::Builder &b,
166 const Vamp::Plugin::OutputDescriptor &od) { 172 const Vamp::Plugin::OutputDescriptor &od,
173 const StaticOutputDescriptor &sd) {
167 174
168 auto basic = b.initBasic(); 175 auto basic = b.initBasic();
169 buildBasicDescriptor(basic, od); 176 buildBasicDescriptor(basic, od);
170 177
171 auto configured = b.initConfigured(); 178 auto configured = b.initConfigured();
172 buildConfiguredOutputDescriptor(configured, od); 179 buildConfiguredOutputDescriptor(configured, od);
180
181 auto statc = b.initStatic();
182 buildStaticOutputDescriptor(statc, sd);
183 }
184
185 static void
186 readStaticOutputDescriptor(StaticOutputDescriptor &sd,
187 const piper::StaticOutputDescriptor::Reader &r) {
188 sd.typeURI = r.getTypeURI();
173 } 189 }
174 190
175 static void 191 static void
176 readConfiguredOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, 192 readConfiguredOutputDescriptor(Vamp::Plugin::OutputDescriptor &od,
177 const piper::ConfiguredOutputDescriptor::Reader &r) { 193 const piper::ConfiguredOutputDescriptor::Reader &r) {
203 } 219 }
204 } 220 }
205 221
206 static void 222 static void
207 readOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, 223 readOutputDescriptor(Vamp::Plugin::OutputDescriptor &od,
224 StaticOutputDescriptor &sd,
208 const piper::OutputDescriptor::Reader &r) { 225 const piper::OutputDescriptor::Reader &r) {
209 226
210 readBasicDescriptor(od, r.getBasic()); 227 readBasicDescriptor(od, r.getBasic());
228 readStaticOutputDescriptor(sd, r.getStatic());
211 readConfiguredOutputDescriptor(od, r.getConfigured()); 229 readConfiguredOutputDescriptor(od, r.getConfigured());
212 } 230 }
213 231
214 static void 232 static void
215 buildParameterDescriptor(piper::ParameterDescriptor::Builder &b, 233 buildParameterDescriptor(piper::ParameterDescriptor::Builder &b,
412 auto olist = b.initBasicOutputInfo(unsigned(vouts.size())); 430 auto olist = b.initBasicOutputInfo(unsigned(vouts.size()));
413 for (int i = 0; i < int(vouts.size()); ++i) { 431 for (int i = 0; i < int(vouts.size()); ++i) {
414 auto od = olist[i]; 432 auto od = olist[i];
415 buildBasicDescriptor(od, vouts[i]); 433 buildBasicDescriptor(od, vouts[i]);
416 } 434 }
435
436 const auto &vstatic = d.staticOutputInfo;
437 auto slist = b.initStaticOutputInfo(unsigned(vstatic.size()));
438 int i = 0;
439 for (const auto &vi: vstatic) {
440 auto spair = slist[i];
441 spair.setOutput(vi.first);
442 auto sdata = spair.initStatic();
443 sdata.setTypeURI(vi.second.typeURI);
444 ++i;
445 }
417 } 446 }
418 447
419 static void 448 static void
420 readExtractorStaticData(PluginStaticData &d, 449 readExtractorStaticData(PluginStaticData &d,
421 const piper::ExtractorStaticData::Reader &r) { 450 const piper::ExtractorStaticData::Reader &r) {
457 auto oo = r.getBasicOutputInfo(); 486 auto oo = r.getBasicOutputInfo();
458 for (auto o: oo) { 487 for (auto o: oo) {
459 PluginStaticData::Basic b; 488 PluginStaticData::Basic b;
460 readBasicDescriptor(b, o); 489 readBasicDescriptor(b, o);
461 d.basicOutputInfo.push_back(b); 490 d.basicOutputInfo.push_back(b);
491 }
492
493 d.staticOutputInfo.clear();
494 auto sp = r.getStaticOutputInfo();
495 for (auto s: sp) {
496 std::string id = s.getOutput();
497 std::string typeURI = s.getStatic().getTypeURI();
498 d.staticOutputInfo[id] = { typeURI };
462 } 499 }
463 } 500 }
464 501
465 static void 502 static void
466 buildConfiguration(piper::Configuration::Builder &b, 503 buildConfiguration(piper::Configuration::Builder &b,
638 const ConfigurationResponse &cr, 675 const ConfigurationResponse &cr,
639 const PluginHandleMapper &pmapper) { 676 const PluginHandleMapper &pmapper) {
640 677
641 b.setHandle(pmapper.pluginToHandle(cr.plugin)); 678 b.setHandle(pmapper.pluginToHandle(cr.plugin));
642 auto olist = b.initOutputs(unsigned(cr.outputs.size())); 679 auto olist = b.initOutputs(unsigned(cr.outputs.size()));
680
643 for (int i = 0; i < int(cr.outputs.size()); ++i) { 681 for (int i = 0; i < int(cr.outputs.size()); ++i) {
682
683 auto id = cr.outputs[i].identifier;
684 StaticOutputDescriptor sd;
685 if (cr.staticOutputInfo.find(id) != cr.staticOutputInfo.end()) {
686 sd = cr.staticOutputInfo.at(id);
687 }
688
644 auto od = olist[i]; 689 auto od = olist[i];
645 buildOutputDescriptor(od, cr.outputs[i]); 690 buildOutputDescriptor(od, cr.outputs[i], sd);
646 } 691 }
692
647 auto framing = b.initFraming(); 693 auto framing = b.initFraming();
648 framing.setStepSize(cr.framing.stepSize); 694 framing.setStepSize(cr.framing.stepSize);
649 framing.setBlockSize(cr.framing.blockSize); 695 framing.setBlockSize(cr.framing.blockSize);
650 } 696 }
651 697
654 const piper::ConfigurationResponse::Reader &r, 700 const piper::ConfigurationResponse::Reader &r,
655 const PluginHandleMapper &pmapper) { 701 const PluginHandleMapper &pmapper) {
656 702
657 cr.plugin = pmapper.handleToPlugin(r.getHandle()); 703 cr.plugin = pmapper.handleToPlugin(r.getHandle());
658 cr.outputs.clear(); 704 cr.outputs.clear();
705 cr.staticOutputInfo.clear();
659 auto oo = r.getOutputs(); 706 auto oo = r.getOutputs();
660 for (const auto &o: oo) { 707 for (const auto &o: oo) {
661 Vamp::Plugin::OutputDescriptor desc; 708 Vamp::Plugin::OutputDescriptor desc;
662 readOutputDescriptor(desc, o); 709 StaticOutputDescriptor sd;
710 readOutputDescriptor(desc, sd, o);
663 cr.outputs.push_back(desc); 711 cr.outputs.push_back(desc);
712 if (sd.typeURI != "") {
713 cr.staticOutputInfo[desc.identifier] = { sd.typeURI };
714 }
664 } 715 }
665 cr.framing.stepSize = r.getFraming().getStepSize(); 716 cr.framing.stepSize = r.getFraming().getStepSize();
666 cr.framing.blockSize = r.getFraming().getBlockSize(); 717 cr.framing.blockSize = r.getFraming().getBlockSize();
667 } 718 }
668 719