1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GstPlugin.html 27 * outPack = gstreamer 28 * outFile = Plugin 29 * strct = GstPlugin 30 * realStrct= 31 * ctorStrct= 32 * clss = Plugin 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_plugin_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ErrorG 48 * - glib.GException 49 * - glib.ListG 50 * - gstreamer.Structure 51 * structWrap: 52 * - GList* -> ListG 53 * - GstPlugin* -> Plugin 54 * - GstStructure* -> Structure 55 * module aliases: 56 * local aliases: 57 * overrides: 58 * - getName 59 */ 60 61 module gstreamer.Plugin; 62 63 public import gstreamerc.gstreamertypes; 64 65 private import gstreamerc.gstreamer; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 70 private import glib.Str; 71 private import glib.ErrorG; 72 private import glib.GException; 73 private import glib.ListG; 74 private import gstreamer.Structure; 75 76 77 78 private import gstreamer.ObjectGst; 79 80 /** 81 * GStreamer is extensible, so GstElement instances can be loaded at runtime. 82 * A plugin system can provide one or more of the basic 83 * GStreamer GstPluginFeature subclasses. 84 * 85 * A plugin should export a symbol gst_plugin_desc that is a 86 * struct of type GstPluginDesc. 87 * the plugin loader will check the version of the core library the plugin was 88 * linked against and will create a new GstPlugin. It will then call the 89 * GstPluginInitFunc function that was provided in the 90 * gst_plugin_desc. 91 * 92 * Once you have a handle to a GstPlugin (e.g. from the GstRegistry), you 93 * can add any object that subclasses GstPluginFeature. 94 * 95 * Usually plugins are always automaticlly loaded so you don't need to call 96 * gst_plugin_load() explicitly to bring it into memory. There are options to 97 * statically link plugins to an app or even use GStreamer without a plugin 98 * repository in which case gst_plugin_load() can be needed to bring the plugin 99 * into memory. 100 */ 101 public class Plugin : ObjectGst 102 { 103 104 /** the main Gtk struct */ 105 protected GstPlugin* gstPlugin; 106 107 108 public GstPlugin* getPluginStruct() 109 { 110 return gstPlugin; 111 } 112 113 114 /** the main Gtk struct as a void* */ 115 protected override void* getStruct() 116 { 117 return cast(void*)gstPlugin; 118 } 119 120 /** 121 * Sets our main struct and passes it to the parent class 122 */ 123 public this (GstPlugin* gstPlugin) 124 { 125 super(cast(GstObject*)gstPlugin); 126 this.gstPlugin = gstPlugin; 127 } 128 129 protected override void setStruct(GObject* obj) 130 { 131 super.setStruct(obj); 132 gstPlugin = cast(GstPlugin*)obj; 133 } 134 135 /** 136 */ 137 138 /** 139 * Get the error quark. 140 * Returns: The error quark used in GError messages 141 */ 142 public static GQuark errorQuark() 143 { 144 // GQuark gst_plugin_error_quark (void); 145 return gst_plugin_error_quark(); 146 } 147 148 /** 149 * Get the short name of the plugin 150 * Returns: the name of the plugin 151 */ 152 public override string getName() 153 { 154 // const gchar * gst_plugin_get_name (GstPlugin *plugin); 155 return Str.toString(gst_plugin_get_name(gstPlugin)); 156 } 157 158 /** 159 * Get the long descriptive name of the plugin 160 * Returns: the long name of the plugin 161 */ 162 public string getDescription() 163 { 164 // const gchar * gst_plugin_get_description (GstPlugin *plugin); 165 return Str.toString(gst_plugin_get_description(gstPlugin)); 166 } 167 168 /** 169 * get the filename of the plugin 170 * Returns: the filename of the plugin 171 */ 172 public string getFilename() 173 { 174 // const gchar * gst_plugin_get_filename (GstPlugin *plugin); 175 return Str.toString(gst_plugin_get_filename(gstPlugin)); 176 } 177 178 /** 179 * get the license of the plugin 180 * Returns: the license of the plugin 181 */ 182 public string getLicense() 183 { 184 // const gchar * gst_plugin_get_license (GstPlugin *plugin); 185 return Str.toString(gst_plugin_get_license(gstPlugin)); 186 } 187 188 /** 189 * get the package the plugin belongs to. 190 * Returns: the package of the plugin 191 */ 192 public string getPackage() 193 { 194 // const gchar * gst_plugin_get_package (GstPlugin *plugin); 195 return Str.toString(gst_plugin_get_package(gstPlugin)); 196 } 197 198 /** 199 * get the URL where the plugin comes from 200 * Returns: the origin of the plugin 201 */ 202 public string getOrigin() 203 { 204 // const gchar * gst_plugin_get_origin (GstPlugin *plugin); 205 return Str.toString(gst_plugin_get_origin(gstPlugin)); 206 } 207 208 /** 209 * get the source module the plugin belongs to. 210 * Returns: the source of the plugin 211 */ 212 public string getSource() 213 { 214 // const gchar * gst_plugin_get_source (GstPlugin *plugin); 215 return Str.toString(gst_plugin_get_source(gstPlugin)); 216 } 217 218 /** 219 * get the version of the plugin 220 * Returns: the version of the plugin 221 */ 222 public string getVersion() 223 { 224 // const gchar * gst_plugin_get_version (GstPlugin *plugin); 225 return Str.toString(gst_plugin_get_version(gstPlugin)); 226 } 227 228 /** 229 * Get the release date (and possibly time) in form of a string, if available. 230 * For normal GStreamer plugin releases this will usually just be a date in 231 * the form of "YYYY-MM-DD", while pre-releases and builds from git may contain 232 * a time component after the date as well, in which case the string will be 233 * formatted like "YYYY-MM-DDTHH:MMZ" (e.g. "2012-04-30T09:30Z"). 234 * There may be plugins that do not have a valid release date set on them. 235 * Returns: the date string of the plugin, or NULL if not available. 236 */ 237 public string getReleaseDateString() 238 { 239 // const gchar * gst_plugin_get_release_date_string (GstPlugin *plugin); 240 return Str.toString(gst_plugin_get_release_date_string(gstPlugin)); 241 } 242 243 /** 244 * queries if the plugin is loaded into memory 245 * Returns: TRUE is loaded, FALSE otherwise 246 */ 247 public int isLoaded() 248 { 249 // gboolean gst_plugin_is_loaded (GstPlugin *plugin); 250 return gst_plugin_is_loaded(gstPlugin); 251 } 252 253 /** 254 * Gets the plugin specific data cache. If it is NULL there is no cached data 255 * stored. This is the case when the registry is getting rebuilt. 256 * Returns: The cached data as a GstStructure or NULL. [transfer none] 257 */ 258 public Structure getCacheData() 259 { 260 // const GstStructure * gst_plugin_get_cache_data (GstPlugin *plugin); 261 auto p = gst_plugin_get_cache_data(gstPlugin); 262 263 if(p is null) 264 { 265 return null; 266 } 267 268 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 269 } 270 271 /** 272 * Adds plugin specific data to cache. Passes the ownership of the structure to 273 * the plugin. 274 * The cache is flushed every time the registry is rebuilt. 275 * Params: 276 * cacheData = a structure containing the data to cache. [transfer full] 277 */ 278 public void setCacheData(Structure cacheData) 279 { 280 // void gst_plugin_set_cache_data (GstPlugin *plugin, GstStructure *cache_data); 281 gst_plugin_set_cache_data(gstPlugin, (cacheData is null) ? null : cacheData.getStructureStruct()); 282 } 283 284 /** 285 * Loads the given plugin and refs it. Caller needs to unref after use. 286 * Params: 287 * filename = the plugin filename to load 288 * Returns: a reference to the existing loaded GstPlugin, a reference to the newly-loaded GstPlugin, or NULL if an error occurred. [transfer full] 289 * Throws: GException on failure. 290 */ 291 public static Plugin loadFile(string filename) 292 { 293 // GstPlugin * gst_plugin_load_file (const gchar *filename, GError **error); 294 GError* err = null; 295 296 auto p = gst_plugin_load_file(Str.toStringz(filename), &err); 297 298 if (err !is null) 299 { 300 throw new GException( new ErrorG(err) ); 301 } 302 303 304 if(p is null) 305 { 306 return null; 307 } 308 309 return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p); 310 } 311 312 /** 313 * Loads plugin. Note that the *return value* is the loaded plugin; plugin is 314 * Returns: a reference to a loaded plugin, or NULL on error. [transfer full] 315 */ 316 public Plugin load() 317 { 318 // GstPlugin * gst_plugin_load (GstPlugin *plugin); 319 auto p = gst_plugin_load(gstPlugin); 320 321 if(p is null) 322 { 323 return null; 324 } 325 326 return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p); 327 } 328 329 /** 330 * Load the named plugin. Refs the plugin. 331 * Params: 332 * name = name of plugin to load 333 * Returns: a reference to a loaded plugin, or NULL on error. [transfer full] 334 */ 335 public static Plugin loadByName(string name) 336 { 337 // GstPlugin * gst_plugin_load_by_name (const gchar *name); 338 auto p = gst_plugin_load_by_name(Str.toStringz(name)); 339 340 if(p is null) 341 { 342 return null; 343 } 344 345 return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p); 346 } 347 348 /** 349 * Unrefs each member of list, then frees the list. 350 * Params: 351 * list = list of GstPlugin. [transfer full][element-type Gst.Plugin] 352 */ 353 public static void listFree(ListG list) 354 { 355 // void gst_plugin_list_free (GList *list); 356 gst_plugin_list_free((list is null) ? null : list.getListGStruct()); 357 } 358 359 /** 360 * Registers a static plugin, ie. a plugin which is private to an application 361 * or library and contained within the application or library (as opposed to 362 * being shipped as a separate module file). 363 * You must make sure that GStreamer has been initialised (with gst_init() or 364 * via gst_init_get_option_group()) before calling this function. 365 * Params: 366 * majorVersion = the major version number of the GStreamer core that the 367 * plugin was compiled for, you can just use GST_VERSION_MAJOR here 368 * minorVersion = the minor version number of the GStreamer core that the 369 * plugin was compiled for, you can just use GST_VERSION_MINOR here 370 * name = a unique name of the plugin (ideally prefixed with an application- or 371 * library-specific namespace prefix in order to avoid name conflicts in 372 * case a similar plugin with the same name ever gets added to GStreamer) 373 * description = description of the plugin 374 * initFunc = pointer to the init function of this plugin. [scope call] 375 * license = effective license of plugin. Must be one of the approved licenses 376 * (see GstPluginDesc above) or the plugin will not be registered. 377 * source = source module plugin belongs to 378 * origin = URL to provider of plugin 379 * Returns: TRUE if the plugin was registered correctly, otherwise FALSE. 380 */ 381 public static int registerStatic(int majorVersion, int minorVersion, string name, string description, GstPluginInitFunc initFunc, string versio, string license, string source, string p, string origin) 382 { 383 // gboolean gst_plugin_register_static (gint major_version, gint minor_version, const gchar *name, const gchar *description, GstPluginInitFunc init_func, const gchar *version, const gchar *license, const gchar *source, const gchar *package, const gchar *origin); 384 return gst_plugin_register_static(majorVersion, minorVersion, Str.toStringz(name), Str.toStringz(description), initFunc, Str.toStringz(versio), Str.toStringz(license), Str.toStringz(source), Str.toStringz(p), Str.toStringz(origin)); 385 } 386 387 /** 388 * Registers a static plugin, ie. a plugin which is private to an application 389 * or library and contained within the application or library (as opposed to 390 * being shipped as a separate module file) with a GstPluginInitFullFunc 391 * which allows user data to be passed to the callback function (useful 392 * for bindings). 393 * You must make sure that GStreamer has been initialised (with gst_init() or 394 * via gst_init_get_option_group()) before calling this function. 395 * Params: 396 * majorVersion = the major version number of the GStreamer core that the 397 * plugin was compiled for, you can just use GST_VERSION_MAJOR here 398 * minorVersion = the minor version number of the GStreamer core that the 399 * plugin was compiled for, you can just use GST_VERSION_MINOR here 400 * name = a unique name of the plugin (ideally prefixed with an application- or 401 * library-specific namespace prefix in order to avoid name conflicts in 402 * case a similar plugin with the same name ever gets added to GStreamer) 403 * description = description of the plugin 404 * initFullFunc = pointer to the init function with user data 405 * of this plugin. [scope call] 406 * license = effective license of plugin. Must be one of the approved licenses 407 * (see GstPluginDesc above) or the plugin will not be registered. 408 * source = source module plugin belongs to 409 * origin = URL to provider of plugin 410 * userData = gpointer to user data 411 * Returns: TRUE if the plugin was registered correctly, otherwise FALSE. 412 */ 413 public static int registerStaticFull(int majorVersion, int minorVersion, string name, string description, GstPluginInitFullFunc initFullFunc, string versio, string license, string source, string p, string origin, void* userData) 414 { 415 // gboolean gst_plugin_register_static_full (gint major_version, gint minor_version, const gchar *name, const gchar *description, GstPluginInitFullFunc init_full_func, const gchar *version, const gchar *license, const gchar *source, const gchar *package, const gchar *origin, gpointer user_data); 416 return gst_plugin_register_static_full(majorVersion, minorVersion, Str.toStringz(name), Str.toStringz(description), initFullFunc, Str.toStringz(versio), Str.toStringz(license), Str.toStringz(source), Str.toStringz(p), Str.toStringz(origin), userData); 417 } 418 419 /** 420 * Make GStreamer aware of external dependencies which affect the feature 421 * set of this plugin (ie. the elements or typefinders associated with it). 422 * GStreamer will re-inspect plugins with external dependencies whenever any 423 * of the external dependencies change. This is useful for plugins which wrap 424 * other plugin systems, e.g. a plugin which wraps a plugin-based visualisation 425 * library and makes visualisations available as GStreamer elements, or a 426 * codec loader which exposes elements and/or caps dependent on what external 427 * codec libraries are currently installed. 428 * Params: 429 * envVars = NULL-terminated array of environment variables affecting the 430 * feature set of the plugin (e.g. an environment variable containing 431 * paths where to look for additional modules/plugins of a library), 432 * or NULL. Environment variable names may be followed by a path component 433 * which will be added to the content of the environment variable, e.g. 434 * "HOME/.mystuff/plugins". [allow-none] 435 * paths = NULL-terminated array of directories/paths where dependent files 436 * may be, or NULL. [allow-none] 437 * names = NULL-terminated array of file names (or file name suffixes, 438 * depending on flags) to be used in combination with the paths from 439 * paths and/or the paths extracted from the environment variables in 440 * env_vars, or NULL. [allow-none] 441 * flags = optional flags, or GST_PLUGIN_DEPENDENCY_FLAG_NONE 442 */ 443 public void addDependency(string[] envVars, string[] paths, string[] names, GstPluginDependencyFlags flags) 444 { 445 // void gst_plugin_add_dependency (GstPlugin *plugin, const gchar **env_vars, const gchar **paths, const gchar **names, GstPluginDependencyFlags flags); 446 gst_plugin_add_dependency(gstPlugin, Str.toStringzArray(envVars), Str.toStringzArray(paths), Str.toStringzArray(names), flags); 447 } 448 449 /** 450 * Make GStreamer aware of external dependencies which affect the feature 451 * set of this plugin (ie. the elements or typefinders associated with it). 452 * GStreamer will re-inspect plugins with external dependencies whenever any 453 * of the external dependencies change. This is useful for plugins which wrap 454 * other plugin systems, e.g. a plugin which wraps a plugin-based visualisation 455 * library and makes visualisations available as GStreamer elements, or a 456 * codec loader which exposes elements and/or caps dependent on what external 457 * codec libraries are currently installed. 458 * Convenience wrapper function for gst_plugin_add_dependency() which 459 * takes simple strings as arguments instead of string arrays, with multiple 460 * arguments separated by predefined delimiters (see above). 461 * Params: 462 * envVars = one or more environment variables (separated by ':', ';' or ','), 463 * or NULL. Environment variable names may be followed by a path component 464 * which will be added to the content of the environment variable, e.g. 465 * "HOME/.mystuff/plugins:MYSTUFF_PLUGINS_PATH". [allow-none] 466 * paths = one ore more directory paths (separated by ':' or ';' or ','), 467 * or NULL. Example: "/usr/lib/mystuff/plugins". [allow-none] 468 * names = one or more file names or file name suffixes (separated by commas), 469 * or NULL. [allow-none] 470 * flags = optional flags, or GST_PLUGIN_DEPENDENCY_FLAG_NONE 471 */ 472 public void addDependencySimple(string envVars, string paths, string names, GstPluginDependencyFlags flags) 473 { 474 // void gst_plugin_add_dependency_simple (GstPlugin *plugin, const gchar *env_vars, const gchar *paths, const gchar *names, GstPluginDependencyFlags flags); 475 gst_plugin_add_dependency_simple(gstPlugin, Str.toStringz(envVars), Str.toStringz(paths), Str.toStringz(names), flags); 476 } 477 }