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