annotate PiperPluginLibrary.h @ 47:cedcaa258e22

Support "from" field in list request
author Chris Cannam
date Mon, 07 Nov 2016 14:49:05 +0000
parents b780e56eebb4
children
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@43 4 Piper Vamp JSON Adapter
Chris@0 5
Chris@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7 Copyright 2015-2016 QMUL.
Chris@0 8
Chris@0 9 Permission is hereby granted, free of charge, to any person
Chris@0 10 obtaining a copy of this software and associated documentation
Chris@0 11 files (the "Software"), to deal in the Software without
Chris@0 12 restriction, including without limitation the rights to use, copy,
Chris@0 13 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@0 14 of the Software, and to permit persons to whom the Software is
Chris@0 15 furnished to do so, subject to the following conditions:
Chris@0 16
Chris@0 17 The above copyright notice and this permission notice shall be
Chris@0 18 included in all copies or substantial portions of the Software.
Chris@0 19
Chris@0 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@0 21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@0 22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@0 23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
Chris@0 24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@0 25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@0 26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@0 27
Chris@0 28 Except as contained in this notice, the names of the Centre for
Chris@0 29 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@0 30 shall not be used in advertising or otherwise to promote the sale,
Chris@0 31 use or other dealings in this Software without prior written
Chris@0 32 authorization.
Chris@0 33 */
Chris@0 34
Chris@43 35 #ifndef PIPER_PLUGIN_LIBRARY_H
Chris@43 36 #define PIPER_PLUGIN_LIBRARY_H
Chris@0 37
Chris@43 38 #include "vamp-support/CountingPluginHandleMapper.h"
Chris@46 39 #include "vamp-support/PluginStaticData.h"
Chris@46 40 #include "vamp-support/RequestResponse.h"
Chris@0 41
Chris@0 42 #include <vector>
Chris@0 43 #include <string>
Chris@0 44 #include <cstring>
Chris@0 45
Chris@46 46 namespace piper_vamp_js {
Chris@0 47
Chris@43 48 class PiperAdapterInterface;
Chris@0 49
Chris@43 50 class PiperPluginLibrary
Chris@0 51 {
Chris@0 52 public:
Chris@43 53 PiperPluginLibrary(std::vector<PiperAdapterInterface *> pp);
Chris@0 54
Chris@0 55 const char *requestJson(const char *request) {
Chris@0 56 return strdup(requestJsonImpl(request).c_str());
Chris@0 57 }
Chris@0 58
Chris@14 59 const char *processRaw(int handle, const float *const *inputBuffers,
Chris@14 60 int sec, int nsec) {
Chris@14 61 return strdup(processRawImpl(handle, inputBuffers, sec, nsec).c_str());
Chris@13 62 }
Chris@13 63
Chris@0 64 void freeJson(const char *json) {
Chris@0 65 free(const_cast<char *>(json));
Chris@0 66 }
Chris@0 67
Chris@0 68 private:
Chris@0 69 std::string requestJsonImpl(std::string req);
Chris@14 70 std::string processRawImpl(int, const float *const *, int, int);
Chris@0 71
Chris@47 72 piper_vamp::ListResponse listPluginData(piper_vamp::ListRequest r) const;
Chris@46 73 piper_vamp::LoadResponse loadPlugin(piper_vamp::LoadRequest r,
Chris@46 74 std::string &err) const;
Chris@46 75 piper_vamp::ConfigurationResponse configurePlugin(piper_vamp::ConfigurationRequest r,
Chris@46 76 std::string &err)
Chris@25 77 const;
Chris@0 78
Chris@25 79 // map from pluginKey -> adapter
Chris@43 80 std::map<std::string, PiperAdapterInterface *> m_adapters;
Chris@46 81 piper_vamp::CountingPluginHandleMapper m_mapper;
Chris@12 82 bool m_useBase64;
Chris@0 83 };
Chris@0 84
Chris@0 85 }
Chris@0 86
Chris@0 87 #endif