comparison capnproto/VampnProto.h @ 68:a5ba837bca28

Update again to latest plugin-terminology-free schema
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 06 Oct 2016 14:32:58 +0100
parents db17657ac875
children 302a8e35248c
comparison
equal deleted inserted replaced
67:db17657ac875 68:a5ba837bca28
368 throw std::logic_error("unexpected Capnp InputDomain enum value"); 368 throw std::logic_error("unexpected Capnp InputDomain enum value");
369 } 369 }
370 } 370 }
371 371
372 static void 372 static void
373 buildPluginStaticData(PluginStaticData::Builder &b, 373 buildExtractorStaticData(ExtractorStaticData::Builder &b,
374 const Vamp::HostExt::PluginStaticData &d) { 374 const Vamp::HostExt::PluginStaticData &d) {
375 375
376 b.setPluginKey(d.pluginKey); 376 b.setKey(d.pluginKey);
377 377
378 auto basic = b.initBasic(); 378 auto basic = b.initBasic();
379 buildBasicDescriptor(basic, d.basic); 379 buildBasicDescriptor(basic, d.basic);
380 380
381 b.setMaker(d.maker); 381 b.setMaker(d.maker);
382 b.setCopyright(d.copyright); 382 b.setCopyright(d.copyright);
383 b.setPluginVersion(d.pluginVersion); 383 b.setVersion(d.pluginVersion);
384 384
385 auto clist = b.initCategory(d.category.size()); 385 auto clist = b.initCategory(d.category.size());
386 for (size_t i = 0; i < d.category.size(); ++i) { 386 for (size_t i = 0; i < d.category.size(); ++i) {
387 clist.set(i, d.category[i]); 387 clist.set(i, d.category[i]);
388 } 388 }
412 buildBasicDescriptor(od, vouts[i]); 412 buildBasicDescriptor(od, vouts[i]);
413 } 413 }
414 } 414 }
415 415
416 static void 416 static void
417 readPluginStaticData(Vamp::HostExt::PluginStaticData &d, 417 readExtractorStaticData(Vamp::HostExt::PluginStaticData &d,
418 const PluginStaticData::Reader &r) { 418 const ExtractorStaticData::Reader &r) {
419 419
420 d.pluginKey = r.getPluginKey(); 420 d.pluginKey = r.getKey();
421 421
422 readBasicDescriptor(d.basic, r.getBasic()); 422 readBasicDescriptor(d.basic, r.getBasic());
423 423
424 d.maker = r.getMaker(); 424 d.maker = r.getMaker();
425 d.copyright = r.getCopyright(); 425 d.copyright = r.getCopyright();
426 d.pluginVersion = r.getPluginVersion(); 426 d.pluginVersion = r.getVersion();
427 427
428 d.category.clear(); 428 d.category.clear();
429 auto cc = r.getCategory(); 429 auto cc = r.getCategory();
430 for (auto c: cc) { 430 for (auto c: cc) {
431 d.category.push_back(c); 431 d.category.push_back(c);
458 d.basicOutputInfo.push_back(b); 458 d.basicOutputInfo.push_back(b);
459 } 459 }
460 } 460 }
461 461
462 static void 462 static void
463 buildPluginConfiguration(PluginConfiguration::Builder &b, 463 buildConfiguration(Configuration::Builder &b,
464 const Vamp::HostExt::PluginConfiguration &c) { 464 const Vamp::HostExt::PluginConfiguration &c) {
465 465
466 const auto &vparams = c.parameterValues; 466 const auto &vparams = c.parameterValues;
467 auto params = b.initParameterValues(vparams.size()); 467 auto params = b.initParameterValues(vparams.size());
468 int i = 0; 468 int i = 0;
469 for (const auto &pp : vparams) { 469 for (const auto &pp : vparams) {
477 b.setStepSize(c.stepSize); 477 b.setStepSize(c.stepSize);
478 b.setBlockSize(c.blockSize); 478 b.setBlockSize(c.blockSize);
479 } 479 }
480 480
481 static void 481 static void
482 readPluginConfiguration(Vamp::HostExt::PluginConfiguration &c, 482 readConfiguration(Vamp::HostExt::PluginConfiguration &c,
483 const PluginConfiguration::Reader &r) { 483 const Configuration::Reader &r) {
484 484
485 auto pp = r.getParameterValues(); 485 auto pp = r.getParameterValues();
486 for (const auto &p: pp) { 486 for (const auto &p: pp) {
487 c.parameterValues[p.getParameter()] = p.getValue(); 487 c.parameterValues[p.getParameter()] = p.getValue();
488 } 488 }
495 495
496 static void 496 static void
497 buildLoadRequest(LoadRequest::Builder &r, 497 buildLoadRequest(LoadRequest::Builder &r,
498 const Vamp::HostExt::LoadRequest &req) { 498 const Vamp::HostExt::LoadRequest &req) {
499 499
500 r.setPluginKey(req.pluginKey); 500 r.setKey(req.pluginKey);
501 r.setInputSampleRate(req.inputSampleRate); 501 r.setInputSampleRate(req.inputSampleRate);
502 502
503 std::vector<AdapterFlag> flags; 503 std::vector<AdapterFlag> flags;
504 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN) { 504 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN) {
505 flags.push_back(AdapterFlag::ADAPT_INPUT_DOMAIN); 505 flags.push_back(AdapterFlag::ADAPT_INPUT_DOMAIN);
519 519
520 static void 520 static void
521 readLoadRequest(Vamp::HostExt::LoadRequest &req, 521 readLoadRequest(Vamp::HostExt::LoadRequest &req,
522 const LoadRequest::Reader &r) { 522 const LoadRequest::Reader &r) {
523 523
524 req.pluginKey = r.getPluginKey(); 524 req.pluginKey = r.getKey();
525 req.inputSampleRate = r.getInputSampleRate(); 525 req.inputSampleRate = r.getInputSampleRate();
526 526
527 int flags = 0; 527 int flags = 0;
528 auto aa = r.getAdapterFlags(); 528 auto aa = r.getAdapterFlags();
529 for (auto a: aa) { 529 for (auto a: aa) {
543 static void 543 static void
544 buildLoadResponse(LoadResponse::Builder &b, 544 buildLoadResponse(LoadResponse::Builder &b,
545 const Vamp::HostExt::LoadResponse &resp, 545 const Vamp::HostExt::LoadResponse &resp,
546 const PluginHandleMapper &pmapper) { 546 const PluginHandleMapper &pmapper) {
547 547
548 b.setPluginHandle(pmapper.pluginToHandle(resp.plugin)); 548 b.setHandle(pmapper.pluginToHandle(resp.plugin));
549 auto sd = b.initStaticData(); 549 auto sd = b.initStaticData();
550 buildPluginStaticData(sd, resp.staticData); 550 buildExtractorStaticData(sd, resp.staticData);
551 auto conf = b.initDefaultConfiguration(); 551 auto conf = b.initDefaultConfiguration();
552 buildPluginConfiguration(conf, resp.defaultConfiguration); 552 buildConfiguration(conf, resp.defaultConfiguration);
553 } 553 }
554 554
555 static void 555 static void
556 readLoadResponse(Vamp::HostExt::LoadResponse &resp, 556 readLoadResponse(Vamp::HostExt::LoadResponse &resp,
557 const LoadResponse::Reader &r, 557 const LoadResponse::Reader &r,
558 const PluginHandleMapper &pmapper) { 558 const PluginHandleMapper &pmapper) {
559 559
560 resp.plugin = pmapper.handleToPlugin(r.getPluginHandle()); 560 resp.plugin = pmapper.handleToPlugin(r.getHandle());
561 readPluginStaticData(resp.staticData, r.getStaticData()); 561 readExtractorStaticData(resp.staticData, r.getStaticData());
562 readPluginConfiguration(resp.defaultConfiguration, 562 readConfiguration(resp.defaultConfiguration,
563 r.getDefaultConfiguration()); 563 r.getDefaultConfiguration());
564 } 564 }
565 565
566 static void 566 static void
567 buildConfigurationRequest(ConfigurationRequest::Builder &b, 567 buildConfigurationRequest(ConfigurationRequest::Builder &b,
568 const Vamp::HostExt::ConfigurationRequest &cr, 568 const Vamp::HostExt::ConfigurationRequest &cr,
569 const PluginHandleMapper &pmapper) { 569 const PluginHandleMapper &pmapper) {
570 570
571 b.setPluginHandle(pmapper.pluginToHandle(cr.plugin)); 571 b.setHandle(pmapper.pluginToHandle(cr.plugin));
572 auto c = b.initConfiguration(); 572 auto c = b.initConfiguration();
573 buildPluginConfiguration(c, cr.configuration); 573 buildConfiguration(c, cr.configuration);
574 } 574 }
575 575
576 static void 576 static void
577 readConfigurationRequest(Vamp::HostExt::ConfigurationRequest &cr, 577 readConfigurationRequest(Vamp::HostExt::ConfigurationRequest &cr,
578 const ConfigurationRequest::Reader &r, 578 const ConfigurationRequest::Reader &r,
579 const PluginHandleMapper &pmapper) { 579 const PluginHandleMapper &pmapper) {
580 580
581 auto h = r.getPluginHandle(); 581 auto h = r.getHandle();
582 cr.plugin = pmapper.handleToPlugin(h); 582 cr.plugin = pmapper.handleToPlugin(h);
583 auto c = r.getConfiguration(); 583 auto c = r.getConfiguration();
584 readPluginConfiguration(cr.configuration, c); 584 readConfiguration(cr.configuration, c);
585 } 585 }
586 586
587 static void 587 static void
588 buildConfigurationResponse(ConfigurationResponse::Builder &b, 588 buildConfigurationResponse(ConfigurationResponse::Builder &b,
589 const Vamp::HostExt::ConfigurationResponse &cr, 589 const Vamp::HostExt::ConfigurationResponse &cr,
590 const PluginHandleMapper &pmapper) { 590 const PluginHandleMapper &pmapper) {
591 591
592 b.setPluginHandle(pmapper.pluginToHandle(cr.plugin)); 592 b.setHandle(pmapper.pluginToHandle(cr.plugin));
593 auto olist = b.initOutputs(cr.outputs.size()); 593 auto olist = b.initOutputs(cr.outputs.size());
594 for (size_t i = 0; i < cr.outputs.size(); ++i) { 594 for (size_t i = 0; i < cr.outputs.size(); ++i) {
595 auto od = olist[i]; 595 auto od = olist[i];
596 buildOutputDescriptor(od, cr.outputs[i]); 596 buildOutputDescriptor(od, cr.outputs[i]);
597 } 597 }
600 static void 600 static void
601 readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr, 601 readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr,
602 const ConfigurationResponse::Reader &r, 602 const ConfigurationResponse::Reader &r,
603 const PluginHandleMapper &pmapper) { 603 const PluginHandleMapper &pmapper) {
604 604
605 cr.plugin = pmapper.handleToPlugin(r.getPluginHandle()); 605 cr.plugin = pmapper.handleToPlugin(r.getHandle());
606 cr.outputs.clear(); 606 cr.outputs.clear();
607 auto oo = r.getOutputs(); 607 auto oo = r.getOutputs();
608 for (const auto &o: oo) { 608 for (const auto &o: oo) {
609 Vamp::Plugin::OutputDescriptor desc; 609 Vamp::Plugin::OutputDescriptor desc;
610 readOutputDescriptor(desc, o); 610 readOutputDescriptor(desc, o);
650 static void 650 static void
651 buildProcessRequest(ProcessRequest::Builder &b, 651 buildProcessRequest(ProcessRequest::Builder &b,
652 const Vamp::HostExt::ProcessRequest &pr, 652 const Vamp::HostExt::ProcessRequest &pr,
653 const PluginHandleMapper &pmapper) { 653 const PluginHandleMapper &pmapper) {
654 654
655 b.setPluginHandle(pmapper.pluginToHandle(pr.plugin)); 655 b.setHandle(pmapper.pluginToHandle(pr.plugin));
656 auto input = b.initProcessInput(); 656 auto input = b.initProcessInput();
657 buildProcessInput(input, pr.timestamp, pr.inputBuffers); 657 buildProcessInput(input, pr.timestamp, pr.inputBuffers);
658 } 658 }
659 659
660 static void 660 static void
661 readProcessRequest(Vamp::HostExt::ProcessRequest &pr, 661 readProcessRequest(Vamp::HostExt::ProcessRequest &pr,
662 const ProcessRequest::Reader &r, 662 const ProcessRequest::Reader &r,
663 const PluginHandleMapper &pmapper) { 663 const PluginHandleMapper &pmapper) {
664 664
665 auto h = r.getPluginHandle(); 665 auto h = r.getHandle();
666 pr.plugin = pmapper.handleToPlugin(h); 666 pr.plugin = pmapper.handleToPlugin(h);
667 readProcessInput(pr.timestamp, pr.inputBuffers, r.getProcessInput()); 667 readProcessInput(pr.timestamp, pr.inputBuffers, r.getProcessInput());
668 } 668 }
669 669
670 static void 670 static void
671 buildProcessResponse(ProcessResponse::Builder &b, 671 buildProcessResponse(ProcessResponse::Builder &b,
672 const Vamp::HostExt::ProcessResponse &pr, 672 const Vamp::HostExt::ProcessResponse &pr,
673 const PluginHandleMapper &pmapper) { 673 const PluginHandleMapper &pmapper) {
674 674
675 b.setPluginHandle(pmapper.pluginToHandle(pr.plugin)); 675 b.setHandle(pmapper.pluginToHandle(pr.plugin));
676 auto f = b.initFeatures(); 676 auto f = b.initFeatures();
677 buildFeatureSet(f, pr.features, 677 buildFeatureSet(f, pr.features,
678 *pmapper.pluginToOutputIdMapper(pr.plugin)); 678 *pmapper.pluginToOutputIdMapper(pr.plugin));
679 } 679 }
680 680
681 static void 681 static void
682 readProcessResponse(Vamp::HostExt::ProcessResponse &pr, 682 readProcessResponse(Vamp::HostExt::ProcessResponse &pr,
683 const ProcessResponse::Reader &r, 683 const ProcessResponse::Reader &r,
684 const PluginHandleMapper &pmapper) { 684 const PluginHandleMapper &pmapper) {
685 685
686 auto h = r.getPluginHandle(); 686 auto h = r.getHandle();
687 pr.plugin = pmapper.handleToPlugin(h); 687 pr.plugin = pmapper.handleToPlugin(h);
688 readFeatureSet(pr.features, r.getFeatures(), 688 readFeatureSet(pr.features, r.getFeatures(),
689 *pmapper.handleToOutputIdMapper(r.getPluginHandle())); 689 *pmapper.handleToOutputIdMapper(r.getHandle()));
690 } 690 }
691 691
692 static void 692 static void
693 buildVampRequest_List(VampRequest::Builder &b) { 693 buildRpcRequest_List(RpcRequest::Builder &b) {
694 b.getRequest().setList(); 694 b.getRequest().initList();
695 } 695 }
696 696
697 static void 697 static void
698 buildVampResponse_List(VampResponse::Builder &b, 698 buildRpcResponse_List(RpcResponse::Builder &b,
699 const Vamp::HostExt::ListResponse &resp) { 699 const Vamp::HostExt::ListResponse &resp) {
700 b.setSuccess(true); 700
701 auto r = b.getResponse().initList(); 701 auto r = b.getResponse().initList();
702 auto p = r.initPlugins(resp.plugins.size()); 702 auto p = r.initAvailable(resp.plugins.size());
703 for (size_t i = 0; i < resp.plugins.size(); ++i) { 703 for (size_t i = 0; i < resp.plugins.size(); ++i) {
704 auto pd = p[i]; 704 auto pd = p[i];
705 buildPluginStaticData(pd, resp.plugins[i]); 705 buildExtractorStaticData(pd, resp.plugins[i]);
706 } 706 }
707 } 707 }
708 708
709 static void 709 static void
710 buildVampRequest_Load(VampRequest::Builder &b, 710 buildRpcRequest_Load(RpcRequest::Builder &b,
711 const Vamp::HostExt::LoadRequest &req) { 711 const Vamp::HostExt::LoadRequest &req) {
712 auto u = b.getRequest().initLoad(); 712 auto u = b.getRequest().initLoad();
713 buildLoadRequest(u, req); 713 buildLoadRequest(u, req);
714 } 714 }
715 715
716 static void 716 static void
717 buildVampResponse_Load(VampResponse::Builder &b, 717 buildRpcResponse_Load(RpcResponse::Builder &b,
718 const Vamp::HostExt::LoadResponse &resp, 718 const Vamp::HostExt::LoadResponse &resp,
719 const PluginHandleMapper &pmapper) { 719 const PluginHandleMapper &pmapper) {
720 b.setSuccess(resp.plugin != 0); 720
721 auto u = b.getResponse().initLoad(); 721 if (resp.plugin) {
722 buildLoadResponse(u, resp, pmapper); 722 auto u = b.getResponse().initLoad();
723 } 723 buildLoadResponse(u, resp, pmapper);
724 724 } else {
725 static void 725 buildRpcResponse_Error(b, "Failed to load plugin", RRType::Load);
726 buildVampRequest_Configure(VampRequest::Builder &b, 726 }
727 }
728
729 static void
730 buildRpcRequest_Configure(RpcRequest::Builder &b,
727 const Vamp::HostExt::ConfigurationRequest &cr, 731 const Vamp::HostExt::ConfigurationRequest &cr,
728 const PluginHandleMapper &pmapper) { 732 const PluginHandleMapper &pmapper) {
729 auto u = b.getRequest().initConfigure(); 733 auto u = b.getRequest().initConfigure();
730 buildConfigurationRequest(u, cr, pmapper); 734 buildConfigurationRequest(u, cr, pmapper);
731 } 735 }
732 736
733 static void 737 static void
734 buildVampResponse_Configure(VampResponse::Builder &b, 738 buildRpcResponse_Configure(RpcResponse::Builder &b,
735 const Vamp::HostExt::ConfigurationResponse &cr, 739 const Vamp::HostExt::ConfigurationResponse &cr,
736 const PluginHandleMapper &pmapper) { 740 const PluginHandleMapper &pmapper) {
737 b.setSuccess(!cr.outputs.empty()); 741
738 auto u = b.getResponse().initConfigure(); 742 if (!cr.outputs.empty()) {
739 buildConfigurationResponse(u, cr, pmapper); 743 auto u = b.getResponse().initConfigure();
740 } 744 buildConfigurationResponse(u, cr, pmapper);
741 745 } else {
742 static void 746 buildRpcResponse_Error(b, "Failed to configure plugin",
743 buildVampRequest_Process(VampRequest::Builder &b, 747 RRType::Configure);
748 }
749 }
750
751 static void
752 buildRpcRequest_Process(RpcRequest::Builder &b,
744 const Vamp::HostExt::ProcessRequest &pr, 753 const Vamp::HostExt::ProcessRequest &pr,
745 const PluginHandleMapper &pmapper) { 754 const PluginHandleMapper &pmapper) {
746 auto u = b.getRequest().initProcess(); 755 auto u = b.getRequest().initProcess();
747 buildProcessRequest(u, pr, pmapper); 756 buildProcessRequest(u, pr, pmapper);
748 } 757 }
749 758
750 static void 759 static void
751 buildVampResponse_Process(VampResponse::Builder &b, 760 buildRpcResponse_Process(RpcResponse::Builder &b,
752 const Vamp::HostExt::ProcessResponse &pr, 761 const Vamp::HostExt::ProcessResponse &pr,
753 const PluginHandleMapper &pmapper) { 762 const PluginHandleMapper &pmapper) {
754 b.setSuccess(true); 763
755 auto u = b.getResponse().initProcess(); 764 auto u = b.getResponse().initProcess();
756 buildProcessResponse(u, pr, pmapper); 765 buildProcessResponse(u, pr, pmapper);
757 } 766 }
758 767
759 static void 768 static void
760 buildVampRequest_Finish(VampRequest::Builder &b, 769 buildRpcRequest_Finish(RpcRequest::Builder &b,
761 const Vamp::HostExt::FinishRequest &req, 770 const Vamp::HostExt::FinishRequest &req,
762 const PluginHandleMapper &pmapper) { 771 const PluginHandleMapper &pmapper) {
763 772
764 auto u = b.getRequest().initFinish(); 773 auto u = b.getRequest().initFinish();
765 u.setPluginHandle(pmapper.pluginToHandle(req.plugin)); 774 u.setHandle(pmapper.pluginToHandle(req.plugin));
766 } 775 }
767 776
768 static void 777 static void
769 buildVampResponse_Finish(VampResponse::Builder &b, 778 buildRpcResponse_Finish(RpcResponse::Builder &b,
770 const Vamp::HostExt::ProcessResponse &pr, 779 const Vamp::HostExt::ProcessResponse &pr,
771 const PluginHandleMapper &pmapper) { 780 const PluginHandleMapper &pmapper) {
772 b.setSuccess(true); 781
773 auto u = b.getResponse().initFinish(); 782 auto u = b.getResponse().initFinish();
774 buildProcessResponse(u, pr, pmapper); 783 buildProcessResponse(u, pr, pmapper);
775 } 784 }
776 785
777 static void 786 static void
778 buildVampResponse_Error(VampResponse::Builder &b, 787 buildRpcResponse_Error(RpcResponse::Builder &b,
779 const std::string &errorText, 788 const std::string &errorText,
780 RRType responseType) 789 RRType responseType)
781 { 790 {
782 std::string type; 791 std::string type;
783 792
793 auto e = b.getResponse().initError();
794
784 if (responseType == RRType::List) { 795 if (responseType == RRType::List) {
785 type = "list"; 796 type = "list";
786 b.getResponse().initList();
787 } else if (responseType == RRType::Load) { 797 } else if (responseType == RRType::Load) {
788 type = "load"; 798 type = "load";
789 b.getResponse().initLoad();
790 } else if (responseType == RRType::Configure) { 799 } else if (responseType == RRType::Configure) {
791 type = "configure"; 800 type = "configure";
792 b.getResponse().initConfigure();
793 } else if (responseType == RRType::Process) { 801 } else if (responseType == RRType::Process) {
794 type = "process"; 802 type = "process";
795 b.getResponse().initProcess();
796 } else if (responseType == RRType::Finish) { 803 } else if (responseType == RRType::Finish) {
797 type = "finish"; 804 type = "finish";
798 b.getResponse().initFinish();
799 } else { 805 } else {
800 type = "invalid"; 806 type = "invalid";
801 } 807 }
802 808
803 b.setSuccess(false); 809 //!!! + code
804 b.setErrorText(std::string("error in ") + type + " request: " + errorText); 810
805 } 811 e.setMessage(std::string("error in ") + type + " request: " + errorText);
806 812 }
807 static void 813
808 buildVampResponse_Exception(VampResponse::Builder &b, 814 static void
815 buildRpcResponse_Exception(RpcResponse::Builder &b,
809 const std::exception &e, 816 const std::exception &e,
810 RRType responseType) 817 RRType responseType)
811 { 818 {
812 return buildVampResponse_Error(b, e.what(), responseType); 819 return buildRpcResponse_Error(b, e.what(), responseType);
813 } 820 }
814 821
815 static RRType 822 static RRType
816 getRequestResponseType(const VampRequest::Reader &r) { 823 getRequestResponseType(const RpcRequest::Reader &r) {
817 switch (r.getRequest().which()) { 824 switch (r.getRequest().which()) {
818 case VampRequest::Request::Which::LIST: 825 case RpcRequest::Request::Which::LIST:
819 return RRType::List; 826 return RRType::List;
820 case VampRequest::Request::Which::LOAD: 827 case RpcRequest::Request::Which::LOAD:
821 return RRType::Load; 828 return RRType::Load;
822 case VampRequest::Request::Which::CONFIGURE: 829 case RpcRequest::Request::Which::CONFIGURE:
823 return RRType::Configure; 830 return RRType::Configure;
824 case VampRequest::Request::Which::PROCESS: 831 case RpcRequest::Request::Which::PROCESS:
825 return RRType::Process; 832 return RRType::Process;
826 case VampRequest::Request::Which::FINISH: 833 case RpcRequest::Request::Which::FINISH:
827 return RRType::Finish; 834 return RRType::Finish;
828 } 835 }
829 return RRType::NotValid; 836 return RRType::NotValid;
830 } 837 }
831 838
832 static RRType 839 static RRType
833 getRequestResponseType(const VampResponse::Reader &r) { 840 getRequestResponseType(const RpcResponse::Reader &r) {
834 switch (r.getResponse().which()) { 841 switch (r.getResponse().which()) {
835 case VampResponse::Response::Which::LIST: 842 case RpcResponse::Response::Which::ERROR:
843 return RRType::NotValid; //!!! or error type? test this
844 case RpcResponse::Response::Which::LIST:
836 return RRType::List; 845 return RRType::List;
837 case VampResponse::Response::Which::LOAD: 846 case RpcResponse::Response::Which::LOAD:
838 return RRType::Load; 847 return RRType::Load;
839 case VampResponse::Response::Which::CONFIGURE: 848 case RpcResponse::Response::Which::CONFIGURE:
840 return RRType::Configure; 849 return RRType::Configure;
841 case VampResponse::Response::Which::PROCESS: 850 case RpcResponse::Response::Which::PROCESS:
842 return RRType::Process; 851 return RRType::Process;
843 case VampResponse::Response::Which::FINISH: 852 case RpcResponse::Response::Which::FINISH:
844 return RRType::Finish; 853 return RRType::Finish;
845 } 854 }
846 return RRType::NotValid; 855 return RRType::NotValid;
847 } 856 }
848 857
849 static void 858 static void
850 readVampRequest_List(const VampRequest::Reader &r) { 859 readRpcResponse_Error(int &code,
860 std::string &message,
861 const RpcResponse::Reader &r) {
862 if (getRequestResponseType(r) != RRType::NotValid) {
863 throw std::logic_error("not an error response");
864 }
865 code = r.getResponse().getError().getCode();
866 message = r.getResponse().getError().getMessage();
867 }
868
869 static void
870 readRpcRequest_List(const RpcRequest::Reader &r) {
851 if (getRequestResponseType(r) != RRType::List) { 871 if (getRequestResponseType(r) != RRType::List) {
852 throw std::logic_error("not a list request"); 872 throw std::logic_error("not a list request");
853 } 873 }
854 } 874 }
855 875
856 static void 876 static void
857 readVampResponse_List(Vamp::HostExt::ListResponse &resp, 877 readRpcResponse_List(Vamp::HostExt::ListResponse &resp,
858 const VampResponse::Reader &r) { 878 const RpcResponse::Reader &r) {
859 if (getRequestResponseType(r) != RRType::List) { 879 if (getRequestResponseType(r) != RRType::List) {
860 throw std::logic_error("not a list response"); 880 throw std::logic_error("not a list response");
861 } 881 }
862 resp.plugins.clear(); 882 resp.plugins.clear();
863 if (r.getSuccess()) { 883 auto pp = r.getResponse().getList().getAvailable();
864 auto pp = r.getResponse().getList().getPlugins(); 884 for (const auto &p: pp) {
865 for (const auto &p: pp) { 885 Vamp::HostExt::PluginStaticData psd;
866 Vamp::HostExt::PluginStaticData psd; 886 readExtractorStaticData(psd, p);
867 readPluginStaticData(psd, p); 887 resp.plugins.push_back(psd);
868 resp.plugins.push_back(psd); 888 }
869 } 889 }
870 } 890
871 } 891 static void
872 892 readRpcRequest_Load(Vamp::HostExt::LoadRequest &req,
873 static void 893 const RpcRequest::Reader &r) {
874 readVampRequest_Load(Vamp::HostExt::LoadRequest &req,
875 const VampRequest::Reader &r) {
876 if (getRequestResponseType(r) != RRType::Load) { 894 if (getRequestResponseType(r) != RRType::Load) {
877 throw std::logic_error("not a load request"); 895 throw std::logic_error("not a load request");
878 } 896 }
879 readLoadRequest(req, r.getRequest().getLoad()); 897 readLoadRequest(req, r.getRequest().getLoad());
880 } 898 }
881 899
882 static void 900 static void
883 readVampResponse_Load(Vamp::HostExt::LoadResponse &resp, 901 readRpcResponse_Load(Vamp::HostExt::LoadResponse &resp,
884 const VampResponse::Reader &r, 902 const RpcResponse::Reader &r,
885 const PluginHandleMapper &pmapper) { 903 const PluginHandleMapper &pmapper) {
886 if (getRequestResponseType(r) != RRType::Load) { 904 if (getRequestResponseType(r) != RRType::Load) {
887 throw std::logic_error("not a load response"); 905 throw std::logic_error("not a load response");
888 } 906 }
889 resp = {}; 907 resp = {};
890 if (r.getSuccess()) { 908 readLoadResponse(resp, r.getResponse().getLoad(), pmapper);
891 readLoadResponse(resp, r.getResponse().getLoad(), pmapper); 909 }
892 } 910
893 } 911 static void
894 912 readRpcRequest_Configure(Vamp::HostExt::ConfigurationRequest &req,
895 static void 913 const RpcRequest::Reader &r,
896 readVampRequest_Configure(Vamp::HostExt::ConfigurationRequest &req,
897 const VampRequest::Reader &r,
898 const PluginHandleMapper &pmapper) { 914 const PluginHandleMapper &pmapper) {
899 if (getRequestResponseType(r) != RRType::Configure) { 915 if (getRequestResponseType(r) != RRType::Configure) {
900 throw std::logic_error("not a configuration request"); 916 throw std::logic_error("not a configuration request");
901 } 917 }
902 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper); 918 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper);
903 } 919 }
904 920
905 static void 921 static void
906 readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, 922 readRpcResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp,
907 const VampResponse::Reader &r, 923 const RpcResponse::Reader &r,
908 const PluginHandleMapper &pmapper) { 924 const PluginHandleMapper &pmapper) {
909 if (getRequestResponseType(r) != RRType::Configure) { 925 if (getRequestResponseType(r) != RRType::Configure) {
910 throw std::logic_error("not a configuration response"); 926 throw std::logic_error("not a configuration response");
911 } 927 }
912 resp = {}; 928 resp = {};
913 if (r.getSuccess()) { 929 readConfigurationResponse(resp,
914 readConfigurationResponse(resp, 930 r.getResponse().getConfigure(),
915 r.getResponse().getConfigure(), 931 pmapper);
916 pmapper); 932 }
917 } 933
918 } 934 static void
919 935 readRpcRequest_Process(Vamp::HostExt::ProcessRequest &req,
920 static void 936 const RpcRequest::Reader &r,
921 readVampRequest_Process(Vamp::HostExt::ProcessRequest &req,
922 const VampRequest::Reader &r,
923 const PluginHandleMapper &pmapper) { 937 const PluginHandleMapper &pmapper) {
924 if (getRequestResponseType(r) != RRType::Process) { 938 if (getRequestResponseType(r) != RRType::Process) {
925 throw std::logic_error("not a process request"); 939 throw std::logic_error("not a process request");
926 } 940 }
927 readProcessRequest(req, r.getRequest().getProcess(), pmapper); 941 readProcessRequest(req, r.getRequest().getProcess(), pmapper);
928 } 942 }
929 943
930 static void 944 static void
931 readVampResponse_Process(Vamp::HostExt::ProcessResponse &resp, 945 readRpcResponse_Process(Vamp::HostExt::ProcessResponse &resp,
932 const VampResponse::Reader &r, 946 const RpcResponse::Reader &r,
933 const PluginHandleMapper &pmapper) { 947 const PluginHandleMapper &pmapper) {
934 if (getRequestResponseType(r) != RRType::Process) { 948 if (getRequestResponseType(r) != RRType::Process) {
935 throw std::logic_error("not a process response"); 949 throw std::logic_error("not a process response");
936 } 950 }
937 resp = {}; 951 resp = {};
938 if (r.getSuccess()) { 952 readProcessResponse(resp, r.getResponse().getProcess(), pmapper);
939 readProcessResponse(resp, r.getResponse().getProcess(), pmapper); 953 }
940 } 954
941 } 955 static void
942 956 readRpcRequest_Finish(Vamp::HostExt::FinishRequest &req,
943 static void 957 const RpcRequest::Reader &r,
944 readVampRequest_Finish(Vamp::HostExt::FinishRequest &req,
945 const VampRequest::Reader &r,
946 const PluginHandleMapper &pmapper) { 958 const PluginHandleMapper &pmapper) {
947 if (getRequestResponseType(r) != RRType::Finish) { 959 if (getRequestResponseType(r) != RRType::Finish) {
948 throw std::logic_error("not a finish request"); 960 throw std::logic_error("not a finish request");
949 } 961 }
950 req.plugin = pmapper.handleToPlugin 962 req.plugin = pmapper.handleToPlugin
951 (r.getRequest().getFinish().getPluginHandle()); 963 (r.getRequest().getFinish().getHandle());
952 } 964 }
953 965
954 static void 966 static void
955 readVampResponse_Finish(Vamp::HostExt::ProcessResponse &resp, 967 readRpcResponse_Finish(Vamp::HostExt::ProcessResponse &resp,
956 const VampResponse::Reader &r, 968 const RpcResponse::Reader &r,
957 const PluginHandleMapper &pmapper) { 969 const PluginHandleMapper &pmapper) {
958 if (getRequestResponseType(r) != RRType::Finish) { 970 if (getRequestResponseType(r) != RRType::Finish) {
959 throw std::logic_error("not a finish response"); 971 throw std::logic_error("not a finish response");
960 } 972 }
961 resp = {}; 973 resp = {};
962 if (r.getSuccess()) { 974 readProcessResponse(resp, r.getResponse().getFinish(), pmapper);
963 readProcessResponse(resp, r.getResponse().getFinish(), pmapper);
964 }
965 } 975 }
966 }; 976 };
967 977
968 } 978 }
969 979