comparison capnproto/VampnProto.h @ 69:91fda9470ee2

Merge from branch jsonrpc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 06 Oct 2016 14:33:12 +0100
parents a5ba837bca28
children 302a8e35248c
comparison
equal deleted inserted replaced
66:6f160dee1192 69:91fda9470ee2
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 781
773 buildVampResponse_Process(b, pr, pmapper); 782 auto u = b.getResponse().initFinish();
774 } 783 buildProcessResponse(u, pr, pmapper);
775 784 }
776 static void 785
777 buildVampResponse_Error(VampResponse::Builder &b, 786 static void
787 buildRpcResponse_Error(RpcResponse::Builder &b,
778 const std::string &errorText, 788 const std::string &errorText,
779 RRType responseType) 789 RRType responseType)
780 { 790 {
781 std::string type; 791 std::string type;
782 792
793 auto e = b.getResponse().initError();
794
783 if (responseType == RRType::List) { 795 if (responseType == RRType::List) {
784 type = "list"; 796 type = "list";
785 b.getResponse().initList();
786 } else if (responseType == RRType::Load) { 797 } else if (responseType == RRType::Load) {
787 type = "load"; 798 type = "load";
788 b.getResponse().initLoad();
789 } else if (responseType == RRType::Configure) { 799 } else if (responseType == RRType::Configure) {
790 type = "configure"; 800 type = "configure";
791 b.getResponse().initConfigure();
792 } else if (responseType == RRType::Process) { 801 } else if (responseType == RRType::Process) {
793 type = "process"; 802 type = "process";
794 b.getResponse().initProcess();
795 } else if (responseType == RRType::Finish) { 803 } else if (responseType == RRType::Finish) {
796 type = "finish"; 804 type = "finish";
797 b.getResponse().initFinish();
798 } else { 805 } else {
799 type = "invalid"; 806 type = "invalid";
800 } 807 }
801 808
802 b.setSuccess(false); 809 //!!! + code
803 b.setErrorText(std::string("error in ") + type + " request: " + errorText); 810
804 } 811 e.setMessage(std::string("error in ") + type + " request: " + errorText);
805 812 }
806 static void 813
807 buildVampResponse_Exception(VampResponse::Builder &b, 814 static void
815 buildRpcResponse_Exception(RpcResponse::Builder &b,
808 const std::exception &e, 816 const std::exception &e,
809 RRType responseType) 817 RRType responseType)
810 { 818 {
811 return buildVampResponse_Error(b, e.what(), responseType); 819 return buildRpcResponse_Error(b, e.what(), responseType);
812 } 820 }
813 821
814 static RRType 822 static RRType
815 getRequestResponseType(const VampRequest::Reader &r) { 823 getRequestResponseType(const RpcRequest::Reader &r) {
816 switch (r.getRequest().which()) { 824 switch (r.getRequest().which()) {
817 case VampRequest::Request::Which::LIST: 825 case RpcRequest::Request::Which::LIST:
818 return RRType::List; 826 return RRType::List;
819 case VampRequest::Request::Which::LOAD: 827 case RpcRequest::Request::Which::LOAD:
820 return RRType::Load; 828 return RRType::Load;
821 case VampRequest::Request::Which::CONFIGURE: 829 case RpcRequest::Request::Which::CONFIGURE:
822 return RRType::Configure; 830 return RRType::Configure;
823 case VampRequest::Request::Which::PROCESS: 831 case RpcRequest::Request::Which::PROCESS:
824 return RRType::Process; 832 return RRType::Process;
825 case VampRequest::Request::Which::FINISH: 833 case RpcRequest::Request::Which::FINISH:
826 return RRType::Finish; 834 return RRType::Finish;
827 } 835 }
828 return RRType::NotValid; 836 return RRType::NotValid;
829 } 837 }
830 838
831 static RRType 839 static RRType
832 getRequestResponseType(const VampResponse::Reader &r) { 840 getRequestResponseType(const RpcResponse::Reader &r) {
833 switch (r.getResponse().which()) { 841 switch (r.getResponse().which()) {
834 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:
835 return RRType::List; 845 return RRType::List;
836 case VampResponse::Response::Which::LOAD: 846 case RpcResponse::Response::Which::LOAD:
837 return RRType::Load; 847 return RRType::Load;
838 case VampResponse::Response::Which::CONFIGURE: 848 case RpcResponse::Response::Which::CONFIGURE:
839 return RRType::Configure; 849 return RRType::Configure;
840 case VampResponse::Response::Which::PROCESS: 850 case RpcResponse::Response::Which::PROCESS:
841 return RRType::Process; 851 return RRType::Process;
842 case VampResponse::Response::Which::FINISH: 852 case RpcResponse::Response::Which::FINISH:
843 return RRType::Finish; 853 return RRType::Finish;
844 } 854 }
845 return RRType::NotValid; 855 return RRType::NotValid;
846 } 856 }
847 857
848 static void 858 static void
849 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) {
850 if (getRequestResponseType(r) != RRType::List) { 871 if (getRequestResponseType(r) != RRType::List) {
851 throw std::logic_error("not a list request"); 872 throw std::logic_error("not a list request");
852 } 873 }
853 } 874 }
854 875
855 static void 876 static void
856 readVampResponse_List(Vamp::HostExt::ListResponse &resp, 877 readRpcResponse_List(Vamp::HostExt::ListResponse &resp,
857 const VampResponse::Reader &r) { 878 const RpcResponse::Reader &r) {
858 if (getRequestResponseType(r) != RRType::List) { 879 if (getRequestResponseType(r) != RRType::List) {
859 throw std::logic_error("not a list response"); 880 throw std::logic_error("not a list response");
860 } 881 }
861 resp.plugins.clear(); 882 resp.plugins.clear();
862 if (r.getSuccess()) { 883 auto pp = r.getResponse().getList().getAvailable();
863 auto pp = r.getResponse().getList().getPlugins(); 884 for (const auto &p: pp) {
864 for (const auto &p: pp) { 885 Vamp::HostExt::PluginStaticData psd;
865 Vamp::HostExt::PluginStaticData psd; 886 readExtractorStaticData(psd, p);
866 readPluginStaticData(psd, p); 887 resp.plugins.push_back(psd);
867 resp.plugins.push_back(psd); 888 }
868 } 889 }
869 } 890
870 } 891 static void
871 892 readRpcRequest_Load(Vamp::HostExt::LoadRequest &req,
872 static void 893 const RpcRequest::Reader &r) {
873 readVampRequest_Load(Vamp::HostExt::LoadRequest &req,
874 const VampRequest::Reader &r) {
875 if (getRequestResponseType(r) != RRType::Load) { 894 if (getRequestResponseType(r) != RRType::Load) {
876 throw std::logic_error("not a load request"); 895 throw std::logic_error("not a load request");
877 } 896 }
878 readLoadRequest(req, r.getRequest().getLoad()); 897 readLoadRequest(req, r.getRequest().getLoad());
879 } 898 }
880 899
881 static void 900 static void
882 readVampResponse_Load(Vamp::HostExt::LoadResponse &resp, 901 readRpcResponse_Load(Vamp::HostExt::LoadResponse &resp,
883 const VampResponse::Reader &r, 902 const RpcResponse::Reader &r,
884 const PluginHandleMapper &pmapper) { 903 const PluginHandleMapper &pmapper) {
885 if (getRequestResponseType(r) != RRType::Load) { 904 if (getRequestResponseType(r) != RRType::Load) {
886 throw std::logic_error("not a load response"); 905 throw std::logic_error("not a load response");
887 } 906 }
888 resp = {}; 907 resp = {};
889 if (r.getSuccess()) { 908 readLoadResponse(resp, r.getResponse().getLoad(), pmapper);
890 readLoadResponse(resp, r.getResponse().getLoad(), pmapper); 909 }
891 } 910
892 } 911 static void
893 912 readRpcRequest_Configure(Vamp::HostExt::ConfigurationRequest &req,
894 static void 913 const RpcRequest::Reader &r,
895 readVampRequest_Configure(Vamp::HostExt::ConfigurationRequest &req,
896 const VampRequest::Reader &r,
897 const PluginHandleMapper &pmapper) { 914 const PluginHandleMapper &pmapper) {
898 if (getRequestResponseType(r) != RRType::Configure) { 915 if (getRequestResponseType(r) != RRType::Configure) {
899 throw std::logic_error("not a configuration request"); 916 throw std::logic_error("not a configuration request");
900 } 917 }
901 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper); 918 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper);
902 } 919 }
903 920
904 static void 921 static void
905 readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, 922 readRpcResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp,
906 const VampResponse::Reader &r, 923 const RpcResponse::Reader &r,
907 const PluginHandleMapper &pmapper) { 924 const PluginHandleMapper &pmapper) {
908 if (getRequestResponseType(r) != RRType::Configure) { 925 if (getRequestResponseType(r) != RRType::Configure) {
909 throw std::logic_error("not a configuration response"); 926 throw std::logic_error("not a configuration response");
910 } 927 }
911 resp = {}; 928 resp = {};
912 if (r.getSuccess()) { 929 readConfigurationResponse(resp,
913 readConfigurationResponse(resp, 930 r.getResponse().getConfigure(),
914 r.getResponse().getConfigure(), 931 pmapper);
915 pmapper); 932 }
916 } 933
917 } 934 static void
918 935 readRpcRequest_Process(Vamp::HostExt::ProcessRequest &req,
919 static void 936 const RpcRequest::Reader &r,
920 readVampRequest_Process(Vamp::HostExt::ProcessRequest &req,
921 const VampRequest::Reader &r,
922 const PluginHandleMapper &pmapper) { 937 const PluginHandleMapper &pmapper) {
923 if (getRequestResponseType(r) != RRType::Process) { 938 if (getRequestResponseType(r) != RRType::Process) {
924 throw std::logic_error("not a process request"); 939 throw std::logic_error("not a process request");
925 } 940 }
926 readProcessRequest(req, r.getRequest().getProcess(), pmapper); 941 readProcessRequest(req, r.getRequest().getProcess(), pmapper);
927 } 942 }
928 943
929 static void 944 static void
930 readVampResponse_Process(Vamp::HostExt::ProcessResponse &resp, 945 readRpcResponse_Process(Vamp::HostExt::ProcessResponse &resp,
931 const VampResponse::Reader &r, 946 const RpcResponse::Reader &r,
932 const PluginHandleMapper &pmapper) { 947 const PluginHandleMapper &pmapper) {
933 if (getRequestResponseType(r) != RRType::Process) { 948 if (getRequestResponseType(r) != RRType::Process) {
934 throw std::logic_error("not a process response"); 949 throw std::logic_error("not a process response");
935 } 950 }
936 resp = {}; 951 resp = {};
937 if (r.getSuccess()) { 952 readProcessResponse(resp, r.getResponse().getProcess(), pmapper);
938 readProcessResponse(resp, r.getResponse().getProcess(), pmapper); 953 }
939 } 954
940 } 955 static void
941 956 readRpcRequest_Finish(Vamp::HostExt::FinishRequest &req,
942 static void 957 const RpcRequest::Reader &r,
943 readVampRequest_Finish(Vamp::HostExt::FinishRequest &req,
944 const VampRequest::Reader &r,
945 const PluginHandleMapper &pmapper) { 958 const PluginHandleMapper &pmapper) {
946 if (getRequestResponseType(r) != RRType::Finish) { 959 if (getRequestResponseType(r) != RRType::Finish) {
947 throw std::logic_error("not a finish request"); 960 throw std::logic_error("not a finish request");
948 } 961 }
949 req.plugin = pmapper.handleToPlugin 962 req.plugin = pmapper.handleToPlugin
950 (r.getRequest().getFinish().getPluginHandle()); 963 (r.getRequest().getFinish().getHandle());
951 } 964 }
952 965
953 static void 966 static void
954 readVampResponse_Finish(Vamp::HostExt::ProcessResponse &resp, 967 readRpcResponse_Finish(Vamp::HostExt::ProcessResponse &resp,
955 const VampResponse::Reader &r, 968 const RpcResponse::Reader &r,
956 const PluginHandleMapper &pmapper) { 969 const PluginHandleMapper &pmapper) {
957 if (getRequestResponseType(r) != RRType::Finish) { 970 if (getRequestResponseType(r) != RRType::Finish) {
958 throw std::logic_error("not a finish response"); 971 throw std::logic_error("not a finish response");
959 } 972 }
960 resp = {}; 973 resp = {};
961 if (r.getSuccess()) { 974 readProcessResponse(resp, r.getResponse().getFinish(), pmapper);
962 readProcessResponse(resp, r.getResponse().getFinish(), pmapper);
963 }
964 } 975 }
965 }; 976 };
966 977
967 } 978 }
968 979