annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginLoader.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents b7bda433d832
children
rev   line source
Chris@12 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@12 2
Chris@12 3 /*
Chris@12 4 Vamp
Chris@12 5
Chris@12 6 An API for audio analysis and feature extraction plugins.
Chris@12 7
Chris@12 8 Centre for Digital Music, Queen Mary, University of London.
Chris@12 9 Copyright 2006-2009 Chris Cannam and QMUL.
Chris@12 10
Chris@12 11 Permission is hereby granted, free of charge, to any person
Chris@12 12 obtaining a copy of this software and associated documentation
Chris@12 13 files (the "Software"), to deal in the Software without
Chris@12 14 restriction, including without limitation the rights to use, copy,
Chris@12 15 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@12 16 of the Software, and to permit persons to whom the Software is
Chris@12 17 furnished to do so, subject to the following conditions:
Chris@12 18
Chris@12 19 The above copyright notice and this permission notice shall be
Chris@12 20 included in all copies or substantial portions of the Software.
Chris@12 21
Chris@12 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@12 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@12 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@12 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
Chris@12 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@12 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@12 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@12 29
Chris@12 30 Except as contained in this notice, the names of the Centre for
Chris@12 31 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@12 32 shall not be used in advertising or otherwise to promote the sale,
Chris@12 33 use or other dealings in this Software without prior written
Chris@12 34 authorization.
Chris@12 35 */
Chris@12 36
Chris@12 37 #ifndef _VAMP_PLUGIN_LOADER_H_
Chris@12 38 #define _VAMP_PLUGIN_LOADER_H_
Chris@12 39
Chris@12 40 #include <vector>
Chris@12 41 #include <string>
Chris@12 42 #include <map>
Chris@12 43
Chris@12 44 #include "hostguard.h"
Chris@12 45 #include "PluginWrapper.h"
Chris@12 46
Chris@12 47 _VAMP_SDK_HOSTSPACE_BEGIN(PluginLoader.h)
Chris@12 48
Chris@12 49 namespace Vamp {
Chris@12 50
Chris@12 51 class Plugin;
Chris@12 52
Chris@12 53 namespace HostExt {
Chris@12 54
Chris@12 55 /**
Chris@12 56 * \class PluginLoader PluginLoader.h <vamp-hostsdk/PluginLoader.h>
Chris@12 57 *
Chris@12 58 * Vamp::HostExt::PluginLoader is a convenience class for discovering
Chris@12 59 * and loading Vamp plugins using the typical plugin-path, library
Chris@12 60 * naming, and categorisation conventions described in the Vamp SDK
Chris@12 61 * documentation. This class is intended to greatly simplify the task
Chris@12 62 * of becoming a Vamp plugin host for any C++ application.
Chris@12 63 *
Chris@12 64 * Hosts are not required by the Vamp specification to use the same
Chris@12 65 * plugin search path and naming conventions as implemented by this
Chris@12 66 * class, and are certainly not required to use this actual class.
Chris@12 67 * But we do strongly recommend it.
Chris@12 68 *
Chris@12 69 * \note This class was introduced in version 1.1 of the Vamp plugin SDK.
Chris@12 70 */
Chris@12 71
Chris@12 72 class PluginLoader
Chris@12 73 {
Chris@12 74 public:
Chris@12 75 /**
Chris@12 76 * Obtain a pointer to the singleton instance of PluginLoader.
Chris@12 77 * Use this to obtain your loader object.
Chris@12 78 */
Chris@12 79 static PluginLoader *getInstance();
Chris@12 80
Chris@12 81 /**
Chris@12 82 * PluginKey is a string type that is used to identify a plugin
Chris@12 83 * uniquely within the scope of "the current system". It consists
Chris@12 84 * of the lower-cased base name of the plugin library, a colon
Chris@12 85 * separator, and the identifier string for the plugin. It is
Chris@12 86 * only meaningful in the context of a given plugin path (the one
Chris@12 87 * returned by PluginHostAdapter::getPluginPath()).
Chris@12 88 *
Chris@12 89 * Use composePluginKey() to construct a plugin key from a known
Chris@12 90 * plugin library name and identifier.
Chris@12 91 *
Chris@12 92 * Note: the fact that the library component of the key is
Chris@12 93 * lower-cased implies that library names are matched
Chris@12 94 * case-insensitively by the PluginLoader class, regardless of the
Chris@12 95 * case sensitivity of the underlying filesystem. (Plugin
Chris@12 96 * identifiers _are_ case sensitive, however.) Also, it is not
Chris@12 97 * possible to portably extract a working library name from a
Chris@12 98 * plugin key, as the result may fail on case-sensitive
Chris@12 99 * filesystems. Use getLibraryPathForPlugin() instead.
Chris@12 100 */
Chris@12 101 typedef std::string PluginKey;
Chris@12 102
Chris@12 103 /**
Chris@12 104 * PluginKeyList is a sequence of plugin keys, such as returned by
Chris@12 105 * listPlugins().
Chris@12 106 */
Chris@12 107 typedef std::vector<PluginKey> PluginKeyList;
Chris@12 108
Chris@12 109 /**
Chris@12 110 * PluginCategoryHierarchy is a sequence of general->specific
Chris@12 111 * category names, as may be associated with a single plugin.
Chris@12 112 * This sequence describes the location of a plugin within a
Chris@12 113 * category forest, containing the human-readable names of the
Chris@12 114 * plugin's category tree root, followed by each of the nodes down
Chris@12 115 * to the leaf containing the plugin.
Chris@12 116 *
Chris@12 117 * \see getPluginCategory()
Chris@12 118 */
Chris@12 119 typedef std::vector<std::string> PluginCategoryHierarchy;
Chris@12 120
Chris@12 121 /**
Chris@12 122 * Search for all available Vamp plugins, and return a list of
Chris@12 123 * them in the order in which they were found.
Chris@12 124 */
Chris@12 125 PluginKeyList listPlugins();
Chris@12 126
Chris@12 127 /**
Chris@12 128 * AdapterFlags contains a set of values that may be OR'd together
Chris@12 129 * to indicate in which circumstances PluginLoader should use a
Chris@12 130 * plugin adapter to make a plugin easier to use for a host that
Chris@12 131 * does not want to cater for complex features.
Chris@12 132 *
Chris@12 133 * The available flags are:
Chris@12 134 *
Chris@12 135 * ADAPT_INPUT_DOMAIN - If the plugin expects frequency domain
Chris@12 136 * input, wrap it in a PluginInputDomainAdapter that automatically
Chris@12 137 * converts the plugin to one that expects time-domain input.
Chris@12 138 * This enables a host to accommodate time- and frequency-domain
Chris@12 139 * plugins without needing to do any conversion itself.
Chris@12 140 *
Chris@12 141 * ADAPT_CHANNEL_COUNT - Wrap the plugin in a PluginChannelAdapter
Chris@12 142 * to handle any mismatch between the number of channels of audio
Chris@12 143 * the plugin can handle and the number available in the host.
Chris@12 144 * This enables a host to use plugins that may require the input
Chris@12 145 * to be mixed down to mono, etc., without having to worry about
Chris@12 146 * doing that itself.
Chris@12 147 *
Chris@12 148 * ADAPT_BUFFER_SIZE - Wrap the plugin in a PluginBufferingAdapter
Chris@12 149 * permitting the host to provide audio input using any block
Chris@12 150 * size, with no overlap, regardless of the plugin's preferred
Chris@12 151 * block size (suitable for hosts that read from non-seekable
Chris@12 152 * streaming media, for example). This adapter introduces some
Chris@12 153 * run-time overhead and also changes the semantics of the plugin
Chris@12 154 * slightly (see the PluginBufferingAdapter header documentation
Chris@12 155 * for details).
Chris@12 156 *
Chris@12 157 * ADAPT_ALL_SAFE - Perform all available adaptations that are
Chris@12 158 * meaningful for the plugin and "safe". Currently this means to
Chris@12 159 * ADAPT_INPUT_DOMAIN if the plugin wants FrequencyDomain input;
Chris@12 160 * ADAPT_CHANNEL_COUNT always; and ADAPT_BUFFER_SIZE never.
Chris@12 161 *
Chris@12 162 * ADAPT_ALL - Perform all available adaptations that are
Chris@12 163 * meaningful for the plugin.
Chris@12 164 *
Chris@12 165 * See PluginInputDomainAdapter, PluginChannelAdapter and
Chris@12 166 * PluginBufferingAdapter for more details of the classes that the
Chris@12 167 * loader may use if these flags are set.
Chris@12 168 */
Chris@12 169 enum AdapterFlags {
Chris@12 170
Chris@12 171 ADAPT_INPUT_DOMAIN = 0x01,
Chris@12 172 ADAPT_CHANNEL_COUNT = 0x02,
Chris@12 173 ADAPT_BUFFER_SIZE = 0x04,
Chris@12 174
Chris@12 175 ADAPT_ALL_SAFE = 0x03,
Chris@12 176
Chris@12 177 ADAPT_ALL = 0xff
Chris@12 178 };
Chris@12 179
Chris@12 180 /**
Chris@12 181 * Load a Vamp plugin, given its identifying key. If the plugin
Chris@12 182 * could not be loaded, returns 0.
Chris@12 183 *
Chris@12 184 * The returned plugin should be deleted (using the standard C++
Chris@12 185 * delete keyword) after use.
Chris@12 186 *
Chris@12 187 * \param adapterFlags a bitwise OR of the values in the AdapterFlags
Chris@12 188 * enumeration, indicating under which circumstances an adapter should be
Chris@12 189 * used to wrap the original plugin. If adapterFlags is 0, no
Chris@12 190 * optional adapters will be used. Otherwise, the returned plugin
Chris@12 191 * may be of an adapter class type which will behave identically
Chris@12 192 * to the original plugin, apart from any particular features
Chris@12 193 * implemented by the adapter itself.
Chris@12 194 *
Chris@12 195 * \see AdapterFlags, PluginInputDomainAdapter, PluginChannelAdapter
Chris@12 196 */
Chris@12 197 Plugin *loadPlugin(PluginKey key,
Chris@12 198 float inputSampleRate,
Chris@12 199 int adapterFlags = 0);
Chris@12 200
Chris@12 201 /**
Chris@12 202 * Given a Vamp plugin library name and plugin identifier, return
Chris@12 203 * the corresponding plugin key in a form suitable for passing in to
Chris@12 204 * loadPlugin().
Chris@12 205 */
Chris@12 206 PluginKey composePluginKey(std::string libraryName,
Chris@12 207 std::string identifier);
Chris@12 208
Chris@12 209 /**
Chris@12 210 * Return the category hierarchy for a Vamp plugin, given its
Chris@12 211 * identifying key.
Chris@12 212 *
Chris@12 213 * If the plugin has no category information, return an empty
Chris@12 214 * hierarchy.
Chris@12 215 *
Chris@12 216 * \see PluginCategoryHierarchy
Chris@12 217 */
Chris@12 218 PluginCategoryHierarchy getPluginCategory(PluginKey plugin);
Chris@12 219
Chris@12 220 /**
Chris@12 221 * Return the file path of the dynamic library from which the
Chris@12 222 * given plugin will be loaded (if available).
Chris@12 223 */
Chris@12 224 std::string getLibraryPathForPlugin(PluginKey plugin);
Chris@12 225
Chris@12 226 protected:
Chris@12 227 PluginLoader();
Chris@12 228 virtual ~PluginLoader();
Chris@12 229
Chris@12 230 class Impl;
Chris@12 231 Impl *m_impl;
Chris@12 232
Chris@12 233 static PluginLoader *m_instance;
Chris@12 234 };
Chris@12 235
Chris@12 236 }
Chris@12 237
Chris@12 238 }
Chris@12 239
Chris@12 240 _VAMP_SDK_HOSTSPACE_END(PluginLoader.h)
Chris@12 241
Chris@12 242 #endif
Chris@12 243