annotate win32-mingw/include/vamp-hostsdk/PluginLoader.h @ 30:553a5f65ef64

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