annotate vamp-support/RequestResponse.h @ 186:52322dde68ea

Fix erroneous logic for handling step and block size in prior commit The earlier change had a logical misconception. If PluginStub is receiving the correct step and block size back from the configure call, the plugin on the server side must have already been successfully initialised, as the step and block size are only returned in a successful configure response. This means the test for a failed initialise and redo with the correct parameters must be done on the server side (in LoaderRequests) not the client. The client has a more complicated job, which is to notice that a *successful* configure had returned different framing parameters from those passed to the initialise call, and to pretend that it had actually failed until the host called again with the correct parameters. We definitely need tests for this!
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 06 Feb 2017 16:44:33 +0000
parents 3eb00e5c76c4
children 02de5df3a884
rev   line source
c@97 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@97 2
c@97 3 /*
c@97 4 Piper C++
c@97 5
c@97 6 An API for audio analysis and feature extraction plugins.
c@97 7
c@97 8 Centre for Digital Music, Queen Mary, University of London.
c@97 9 Copyright 2006-2016 Chris Cannam and QMUL.
c@97 10
c@97 11 Permission is hereby granted, free of charge, to any person
c@97 12 obtaining a copy of this software and associated documentation
c@97 13 files (the "Software"), to deal in the Software without
c@97 14 restriction, including without limitation the rights to use, copy,
c@97 15 modify, merge, publish, distribute, sublicense, and/or sell copies
c@97 16 of the Software, and to permit persons to whom the Software is
c@97 17 furnished to do so, subject to the following conditions:
c@97 18
c@97 19 The above copyright notice and this permission notice shall be
c@97 20 included in all copies or substantial portions of the Software.
c@97 21
c@97 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@97 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@97 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@97 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
c@97 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@97 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@97 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@97 29
c@97 30 Except as contained in this notice, the names of the Centre for
c@97 31 Digital Music; Queen Mary, University of London; and Chris Cannam
c@97 32 shall not be used in advertising or otherwise to promote the sale,
c@97 33 use or other dealings in this Software without prior written
c@97 34 authorization.
c@97 35 */
c@97 36
c@97 37 #ifndef PIPER_REQUEST_RESPONSE_H
c@97 38 #define PIPER_REQUEST_RESPONSE_H
c@97 39
c@97 40 #include "PluginStaticData.h"
c@97 41 #include "PluginConfiguration.h"
c@97 42
c@97 43 #include <map>
c@97 44 #include <string>
c@97 45
c@97 46 namespace piper_vamp {
c@97 47
c@97 48 /**
c@97 49 * \class ListRequest
c@97 50 *
c@97 51 * ListRequest is a structure containing the information needed to
c@127 52 * list plugins.
c@97 53 *
c@97 54 * \see ListResponse
c@97 55 */
c@97 56 struct ListRequest
c@97 57 {
c@127 58 ListRequest() { } // no constraints by default
c@127 59
c@127 60 std::vector<std::string> from;
c@97 61 };
c@97 62
c@97 63 /**
c@97 64 * \class ListResponse
c@97 65 *
c@97 66 * ListResponse is a structure containing the information returned by
c@97 67 * PluginLoader when asked to list static information about the
c@97 68 * available plugins.
c@97 69 *
c@97 70 * \see PluginStaticData
c@97 71 */
c@97 72 struct ListResponse
c@97 73 {
c@97 74 ListResponse() { } // empty by default
c@97 75
c@97 76 std::vector<PluginStaticData> available;
c@97 77 };
c@97 78
c@97 79 /**
c@97 80 * \class LoadRequest
c@97 81 *
c@97 82 * LoadRequest is a structure containing the information necessary to
c@97 83 * load a plugin. When a request is made to load a plugin using a
c@97 84 * LoadRequest, the response is typically returned in a LoadResponse
c@97 85 * structure.
c@97 86 *
c@97 87 * \see LoadResponse
c@97 88 */
c@97 89 struct LoadRequest
c@97 90 {
c@97 91 LoadRequest() : // invalid request by default
c@97 92 inputSampleRate(0.f),
c@97 93 adapterFlags(0) { }
c@97 94
c@97 95 /**
c@97 96 * PluginKey is a string type that is used to identify a plugin
c@97 97 * uniquely within the scope of "the current system". For further
c@97 98 * details \see Vamp::PluginLoader::PluginKey.
c@97 99 */
c@97 100 typedef std::string PluginKey;
c@97 101
c@97 102 /**
c@97 103 * The identifying key for the plugin to be loaded.
c@97 104 */
c@97 105 PluginKey pluginKey;
c@97 106
c@97 107 /**
c@97 108 * Sample rate to be passed to the plugin's constructor.
c@97 109 */
c@97 110 float inputSampleRate;
c@97 111
c@97 112 /**
c@97 113 * A bitwise OR of the values in the PluginLoader::AdapterFlags
c@97 114 * enumeration, indicating under which circumstances an adapter
c@97 115 * should be used to wrap the original plugin. If adapterFlags is
c@97 116 * 0, no optional adapters will be used.
c@97 117 *
c@97 118 * \see Vamp::PluginLoader::AdapterFlags
c@97 119 */
c@97 120 int adapterFlags;
c@97 121 };
c@97 122
c@97 123 /**
c@97 124 * \class LoadResponse
c@97 125 *
c@97 126 * LoadResponse is a structure containing the information returned by
c@97 127 * PluginLoader when asked to load a plugin using a LoadRequest.
c@97 128 *
c@97 129 * If the plugin could not be loaded, the plugin field will be 0.
c@97 130 *
c@97 131 * The caller takes ownership of the plugin contained here, which
c@97 132 * should be deleted (using the standard C++ delete keyword) after
c@97 133 * use.
c@97 134 *
c@97 135 * \see LoadRequest
c@97 136 */
c@97 137 struct LoadResponse
c@97 138 {
c@97 139 LoadResponse() : // invalid (failed) response by default
c@97 140 plugin(0) { }
c@97 141
c@97 142 /**
c@97 143 * A pointer to the loaded plugin, or 0 if loading failed. Caller
c@97 144 * takes ownership of the plugin and must delete it after use.
c@97 145 */
c@97 146 Vamp::Plugin *plugin;
c@97 147
c@97 148 /**
c@97 149 * The static data associated with the loaded plugin, that is, all
c@97 150 * information about it that does not depend on its configuration
c@97 151 * (parameters, programs, initialisation parameters). The contents
c@97 152 * of this structure are only valid if plugin is non-0.
c@97 153 *
c@97 154 * Much of the data in here is duplicated with the plugin itself.
c@97 155 */
c@97 156 PluginStaticData staticData;
c@97 157
c@97 158 /**
c@97 159 * The default configuration for this plugin, that is, default
c@97 160 * values for parameters etc. The contents of this structure are
c@97 161 * only valid if plugin is non-0.
c@97 162 */
c@97 163 PluginConfiguration defaultConfiguration;
c@97 164 };
c@97 165
c@97 166 /**
c@97 167 * \class ConfigurationRequest
c@97 168 *
c@97 169 * A wrapper for a plugin pointer and PluginConfiguration, bundling up
c@97 170 * the data needed to configure a plugin after it has been loaded.
c@97 171 *
c@97 172 * \see PluginConfiguration, ConfigurationResponse, LoadRequest, LoadResponse
c@97 173 */
c@97 174 struct ConfigurationRequest
c@97 175 {
c@97 176 public:
c@97 177 ConfigurationRequest() : // invalid request by default
c@97 178 plugin(0) { }
c@97 179
c@97 180 Vamp::Plugin *plugin;
c@97 181 PluginConfiguration configuration;
c@97 182 };
c@97 183
c@97 184 /**
c@97 185 * \class ConfigurationResponse
c@97 186 *
c@97 187 * The return value from a configuration request (i.e. setting the
c@97 188 * parameters and initialising the plugin). If the configuration was
c@97 189 * successful, the output list will contain the final
cannam@185 190 * post-initialisation output descriptors and the required step and
cannam@185 191 * block size. (The step and block size will usually match those
cannam@185 192 * passed to configure, but may differ if the parameter settings
cannam@185 193 * turned out to be incompatible with those.) If configuration failed,
c@97 194 * the output list will be empty.
c@97 195 *
c@97 196 * \see PluginConfiguration, ConfigurationRequest, LoadRequest, LoadResponse
c@97 197 */
c@97 198 struct ConfigurationResponse
c@97 199 {
c@97 200 public:
c@97 201 ConfigurationResponse() : // failed by default
c@97 202 plugin(0) { }
c@97 203
c@97 204 Vamp::Plugin *plugin;
c@97 205 Vamp::Plugin::OutputList outputs;
cannam@185 206 Framing framing;
c@97 207 };
c@97 208
c@97 209 /**
c@97 210 * \class ProcessRequest
c@97 211 *
c@97 212 * A structure that bundles the necessary data for making a process
c@97 213 * call: plugin, input buffers, and timestamp. Caller retains
c@97 214 * ownership of the plugin, but the buffers are passed "by value" to
c@97 215 * avoid ownership concerns.
c@97 216 *
c@97 217 * \see Vamp::Plugin::process()
c@97 218 */
c@97 219 struct ProcessRequest
c@97 220 {
c@97 221 public:
c@97 222 ProcessRequest() : // invalid by default
c@97 223 plugin(0) { }
c@97 224
c@97 225 Vamp::Plugin *plugin;
c@97 226 std::vector<std::vector<float> > inputBuffers;
c@97 227 Vamp::RealTime timestamp;
c@97 228 };
c@97 229
c@97 230 /**
c@97 231 * \class ProcessResponse
c@97 232 *
c@97 233 * A structure that bundles the data returned by a process call. This
c@97 234 * is simply a FeatureSet wrapper that happens to reference the plugin
c@97 235 * as well.
c@97 236 *
c@97 237 * \see FinishResponse, Vamp::Plugin::process()
c@97 238 */
c@97 239 struct ProcessResponse
c@97 240 {
c@97 241 public:
c@97 242 ProcessResponse() : // invalid by default
c@97 243 plugin(0) { }
c@97 244
c@97 245 Vamp::Plugin *plugin;
c@97 246 Vamp::Plugin::FeatureSet features;
c@97 247 };
c@97 248
c@97 249 /**
c@97 250 * \class FinishRequest
c@97 251 *
c@97 252 * A structure that bundles the necessary data for finishing
c@97 253 * processing, i.e. calling getRemainingFeatures(). This consists only
c@97 254 * of the plugin pointer. Caller retains ownership of the plugin.
c@97 255 *
c@97 256 * \see Vamp::Plugin::getRemainingFeatures()
c@97 257 */
c@97 258 struct FinishRequest
c@97 259 {
c@97 260 public:
c@97 261 FinishRequest() : // invalid by default
c@97 262 plugin(0) { }
c@97 263
c@97 264 Vamp::Plugin *plugin;
c@97 265 };
c@97 266
c@97 267
c@97 268 /**
c@97 269 * \class FinishResponse
c@97 270 *
c@97 271 * A structure that bundles the data returned by a
c@97 272 * getRemainingFeatures() call. This is identical to ProcessResponse.
c@97 273 *
c@97 274 * \see ProcessResponse, Vamp::Plugin::getRemainingFeatures()
c@97 275 */
c@97 276 struct FinishResponse
c@97 277 {
c@97 278 public:
c@97 279 FinishResponse() : // invalid by default
c@97 280 plugin(0) { }
c@97 281
c@97 282 Vamp::Plugin *plugin;
c@97 283 Vamp::Plugin::FeatureSet features;
c@97 284 };
c@97 285
c@97 286 }
c@97 287
c@97 288 #endif