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 = GstRegistry.html 27 * outPack = gstreamer 28 * outFile = Registry 29 * strct = GstRegistry 30 * realStrct= 31 * ctorStrct= 32 * clss = Registry 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_registry_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ListG 48 * - gstreamer.Plugin 49 * - gstreamer.PluginFeature 50 * structWrap: 51 * - GList* -> ListG 52 * - GstPlugin* -> Plugin 53 * - GstPluginFeature* -> PluginFeature 54 * - GstRegistry* -> Registry 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gstreamer.Registry; 61 62 public import gstreamerc.gstreamertypes; 63 64 private import gstreamerc.gstreamer; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import gobject.Signals; 69 public import gtkc.gdktypes; 70 71 private import glib.Str; 72 private import glib.ListG; 73 private import gstreamer.Plugin; 74 private import gstreamer.PluginFeature; 75 76 77 78 private import gstreamer.ObjectGst; 79 80 /** 81 * One registry holds the metadata of a set of plugins. 82 * 83 * Design: 84 * 85 * The GstRegistry object is a list of plugins and some functions for dealing 86 * with them. Each GstPlugin is matched 1-1 with a file on disk, and may or may 87 * not be loaded at a given time. 88 * 89 * The primary source, at all times, of plugin information is each plugin file 90 * itself. Thus, if an application wants information about a particular plugin, 91 * or wants to search for a feature that satisfies given criteria, the primary 92 * means of doing so is to load every plugin and look at the resulting 93 * information that is gathered in the default registry. Clearly, this is a time 94 * consuming process, so we cache information in the registry file. The format 95 * and location of the cache file is internal to gstreamer. 96 * 97 * On startup, plugins are searched for in the plugin search path. The following 98 * locations are checked in this order: 99 * 100 * location from --gst-plugin-path commandline option. 101 * 102 * the GST_PLUGIN_PATH environment variable. 103 * 104 * the GST_PLUGIN_SYSTEM_PATH environment variable. 105 * 106 * default locations (if GST_PLUGIN_SYSTEM_PATH is not set). Those 107 * default locations are: 108 * ~/.gstreamer-$GST_API_VERSION/plugins/ 109 * and $prefix/libs/gstreamer-$GST_API_VERSION/. 110 * 111 * The registry cache file is loaded from 112 * ~/.gstreamer-$GST_API_VERSION/registry-$ARCH.bin or the 113 * file listed in the GST_REGISTRY env var. One reason to change the registry 114 * location is for testing. 115 * 116 * For each plugin that is found in the plugin search path, there could be 3 117 * possibilities for cached information: 118 * 119 * the cache may not contain information about a given file. 120 * 121 * the cache may have stale information. 122 * 123 * the cache may have current information. 124 * 125 * In the first two cases, the plugin is loaded and the cache updated. In 126 * addition to these cases, the cache may have entries for plugins that are not 127 * relevant to the current process. These are marked as not available to the 128 * current process. If the cache is updated for whatever reason, it is marked 129 * dirty. 130 * 131 * A dirty cache is written out at the end of initialization. Each entry is 132 * checked to make sure the information is minimally valid. If not, the entry is 133 * simply dropped. 134 * 135 * Implementation notes: 136 * 137 * The "cache" and "registry" are different concepts and can represent 138 * different sets of plugins. For various reasons, at init time, the cache is 139 * stored in the default registry, and plugins not relevant to the current 140 * process are marked with the GST_PLUGIN_FLAG_CACHED bit. These plugins are 141 * removed at the end of initialization. 142 * 143 * Last reviewed on 2012-03-29 (0.11.3) 144 */ 145 public class Registry : ObjectGst 146 { 147 148 /** the main Gtk struct */ 149 protected GstRegistry* gstRegistry; 150 151 152 public GstRegistry* getRegistryStruct() 153 { 154 return gstRegistry; 155 } 156 157 158 /** the main Gtk struct as a void* */ 159 protected override void* getStruct() 160 { 161 return cast(void*)gstRegistry; 162 } 163 164 /** 165 * Sets our main struct and passes it to the parent class 166 */ 167 public this (GstRegistry* gstRegistry) 168 { 169 super(cast(GstObject*)gstRegistry); 170 this.gstRegistry = gstRegistry; 171 } 172 173 protected override void setStruct(GObject* obj) 174 { 175 super.setStruct(obj); 176 gstRegistry = cast(GstRegistry*)obj; 177 } 178 179 /** 180 */ 181 int[string] connectedSignals; 182 183 void delegate(PluginFeature, Registry)[] onFeatureAddedListeners; 184 /** 185 * Signals that a feature has been added to the registry (possibly 186 * replacing a previously-added one by the same name) 187 */ 188 void addOnFeatureAdded(void delegate(PluginFeature, Registry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 189 { 190 if ( !("feature-added" in connectedSignals) ) 191 { 192 Signals.connectData( 193 getStruct(), 194 "feature-added", 195 cast(GCallback)&callBackFeatureAdded, 196 cast(void*)this, 197 null, 198 connectFlags); 199 connectedSignals["feature-added"] = 1; 200 } 201 onFeatureAddedListeners ~= dlg; 202 } 203 extern(C) static void callBackFeatureAdded(GstRegistry* registryStruct, GstPluginFeature* feature, Registry _registry) 204 { 205 foreach ( void delegate(PluginFeature, Registry) dlg ; _registry.onFeatureAddedListeners ) 206 { 207 dlg(ObjectG.getDObject!(PluginFeature)(feature), _registry); 208 } 209 } 210 211 void delegate(Plugin, Registry)[] onPluginAddedListeners; 212 /** 213 * Signals that a plugin has been added to the registry (possibly 214 * replacing a previously-added one by the same name) 215 * See Also 216 * GstPlugin, GstPluginFeature 217 */ 218 void addOnPluginAdded(void delegate(Plugin, Registry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 219 { 220 if ( !("plugin-added" in connectedSignals) ) 221 { 222 Signals.connectData( 223 getStruct(), 224 "plugin-added", 225 cast(GCallback)&callBackPluginAdded, 226 cast(void*)this, 227 null, 228 connectFlags); 229 connectedSignals["plugin-added"] = 1; 230 } 231 onPluginAddedListeners ~= dlg; 232 } 233 extern(C) static void callBackPluginAdded(GstRegistry* registryStruct, GstPlugin* plugin, Registry _registry) 234 { 235 foreach ( void delegate(Plugin, Registry) dlg ; _registry.onPluginAddedListeners ) 236 { 237 dlg(ObjectG.getDObject!(Plugin)(plugin), _registry); 238 } 239 } 240 241 242 /** 243 * Retrieves the singleton plugin registry. The caller does not own a 244 * reference on the registry, as it is alive as long as GStreamer is 245 * initialized. 246 * Returns: the GstRegistry. [transfer none] 247 */ 248 public static Registry get() 249 { 250 // GstRegistry * gst_registry_get (void); 251 auto p = gst_registry_get(); 252 253 if(p is null) 254 { 255 return null; 256 } 257 258 return ObjectG.getDObject!(Registry)(cast(GstRegistry*) p); 259 } 260 261 /** 262 * Retrieves a GList of GstPluginFeature of type. 263 * Params: 264 * type = a GType. 265 * Returns: a GList of GstPluginFeature of type. Use gst_plugin_feature_list_free() after use MT safe. [transfer full][element-type Gst.PluginFeature] 266 */ 267 public ListG getFeatureList(GType type) 268 { 269 // GList * gst_registry_get_feature_list (GstRegistry *registry, GType type); 270 auto p = gst_registry_get_feature_list(gstRegistry, type); 271 272 if(p is null) 273 { 274 return null; 275 } 276 277 return ObjectG.getDObject!(ListG)(cast(GList*) p); 278 } 279 280 /** 281 * Returns the registrys feature list cookie. This changes 282 * every time a feature is added or removed from the registry. 283 * Returns: the feature list cookie. 284 */ 285 public uint getFeatureListCookie() 286 { 287 // guint32 gst_registry_get_feature_list_cookie (GstRegistry *registry); 288 return gst_registry_get_feature_list_cookie(gstRegistry); 289 } 290 291 /** 292 * Retrieves a GList of features of the plugin with name name. 293 * Params: 294 * name = a plugin name. 295 * Returns: a GList of GstPluginFeature. Use gst_plugin_feature_list_free() after usage. [transfer full][element-type Gst.PluginFeature] 296 */ 297 public ListG getFeatureListByPlugin(string name) 298 { 299 // GList * gst_registry_get_feature_list_by_plugin (GstRegistry *registry, const gchar *name); 300 auto p = gst_registry_get_feature_list_by_plugin(gstRegistry, Str.toStringz(name)); 301 302 if(p is null) 303 { 304 return null; 305 } 306 307 return ObjectG.getDObject!(ListG)(cast(GList*) p); 308 } 309 310 /** 311 * Get a copy of all plugins registered in the given registry. The refcount 312 * of each element in the list in incremented. 313 * Returns: a GList of GstPlugin. Use gst_plugin_list_free() after usage. MT safe. [transfer full][element-type Gst.Plugin] 314 */ 315 public ListG getPluginList() 316 { 317 // GList * gst_registry_get_plugin_list (GstRegistry *registry); 318 auto p = gst_registry_get_plugin_list(gstRegistry); 319 320 if(p is null) 321 { 322 return null; 323 } 324 325 return ObjectG.getDObject!(ListG)(cast(GList*) p); 326 } 327 328 /** 329 * Add the plugin to the registry. The plugin-added signal will be emitted. 330 * This function will sink plugin. 331 * Params: 332 * plugin = the plugin to add. [transfer full] 333 * Returns: TRUE on success. MT safe. 334 */ 335 public int addPlugin(Plugin plugin) 336 { 337 // gboolean gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin); 338 return gst_registry_add_plugin(gstRegistry, (plugin is null) ? null : plugin.getPluginStruct()); 339 } 340 341 /** 342 * Remove the plugin from the registry. 343 * MT safe. 344 * Params: 345 * plugin = the plugin to remove. [transfer none] 346 */ 347 public void removePlugin(Plugin plugin) 348 { 349 // void gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin); 350 gst_registry_remove_plugin(gstRegistry, (plugin is null) ? null : plugin.getPluginStruct()); 351 } 352 353 /** 354 * Runs a filter against all plugins in the registry and returns a GList with 355 * the results. If the first flag is set, only the first match is 356 * returned (as a list with a single object). 357 * Every plugin is reffed; use gst_plugin_list_free() after use, which 358 * will unref again. 359 * Params: 360 * filter = the filter to use. [scope call] 361 * first = only return first match 362 * userData = user data passed to the filter function. [closure] 363 * Returns: a GList of GstPlugin. Use gst_plugin_list_free() after usage. MT safe. [transfer full][element-type Gst.Plugin] 364 */ 365 public ListG pluginFilter(GstPluginFilter filter, int first, void* userData) 366 { 367 // GList * gst_registry_plugin_filter (GstRegistry *registry, GstPluginFilter filter, gboolean first, gpointer user_data); 368 auto p = gst_registry_plugin_filter(gstRegistry, filter, first, userData); 369 370 if(p is null) 371 { 372 return null; 373 } 374 375 return ObjectG.getDObject!(ListG)(cast(GList*) p); 376 } 377 378 /** 379 * Runs a filter against all features of the plugins in the registry 380 * and returns a GList with the results. 381 * If the first flag is set, only the first match is 382 * returned (as a list with a single object). 383 * Params: 384 * filter = the filter to use. [scope call] 385 * first = only return first match 386 * userData = user data passed to the filter function. [closure] 387 * Returns: a GList of GstPluginFeature. Use gst_plugin_feature_list_free() after usage. MT safe. [transfer full][element-type Gst.PluginFeature] 388 */ 389 public ListG featureFilter(GstPluginFeatureFilter filter, int first, void* userData) 390 { 391 // GList * gst_registry_feature_filter (GstRegistry *registry, GstPluginFeatureFilter filter, gboolean first, gpointer user_data); 392 auto p = gst_registry_feature_filter(gstRegistry, filter, first, userData); 393 394 if(p is null) 395 { 396 return null; 397 } 398 399 return ObjectG.getDObject!(ListG)(cast(GList*) p); 400 } 401 402 /** 403 * Find the plugin with the given name in the registry. 404 * The plugin will be reffed; caller is responsible for unreffing. 405 * Params: 406 * name = the plugin name to find 407 * Returns: the plugin with the given name or NULL if the plugin was not found. gst_object_unref() after usage. MT safe. [transfer full] 408 */ 409 public Plugin findPlugin(string name) 410 { 411 // GstPlugin * gst_registry_find_plugin (GstRegistry *registry, const gchar *name); 412 auto p = gst_registry_find_plugin(gstRegistry, Str.toStringz(name)); 413 414 if(p is null) 415 { 416 return null; 417 } 418 419 return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p); 420 } 421 422 /** 423 * Find the pluginfeature with the given name and type in the registry. 424 * Params: 425 * name = the pluginfeature name to find 426 * type = the pluginfeature type to find 427 * Returns: the pluginfeature with the given name and type or NULL if the plugin was not found. gst_object_unref() after usage. MT safe. [transfer full] 428 */ 429 public PluginFeature findFeature(string name, GType type) 430 { 431 // GstPluginFeature * gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type); 432 auto p = gst_registry_find_feature(gstRegistry, Str.toStringz(name), type); 433 434 if(p is null) 435 { 436 return null; 437 } 438 439 return ObjectG.getDObject!(PluginFeature)(cast(GstPluginFeature*) p); 440 } 441 442 /** 443 * Find a GstPluginFeature with name in registry. 444 * Params: 445 * name = a GstPluginFeature name 446 * Returns: a GstPluginFeature with its refcount incremented, use gst_object_unref() after usage. MT safe. [transfer full] 447 */ 448 public PluginFeature lookupFeature(string name) 449 { 450 // GstPluginFeature * gst_registry_lookup_feature (GstRegistry *registry, const char *name); 451 auto p = gst_registry_lookup_feature(gstRegistry, Str.toStringz(name)); 452 453 if(p is null) 454 { 455 return null; 456 } 457 458 return ObjectG.getDObject!(PluginFeature)(cast(GstPluginFeature*) p); 459 } 460 461 /** 462 * Scan the given path for plugins to add to the registry. The syntax of the 463 * path is specific to the registry. 464 * Params: 465 * path = the path to scan 466 * Returns: TRUE if registry changed 467 */ 468 public int scanPath(string path) 469 { 470 // gboolean gst_registry_scan_path (GstRegistry *registry, const gchar *path); 471 return gst_registry_scan_path(gstRegistry, Str.toStringz(path)); 472 } 473 474 /** 475 * Look up a plugin in the given registry with the given filename. 476 * If found, plugin is reffed. 477 * Params: 478 * filename = the name of the file to look up 479 * Returns: the GstPlugin if found, or NULL if not. gst_object_unref() after usage. [transfer full] 480 */ 481 public Plugin lookup(string filename) 482 { 483 // GstPlugin * gst_registry_lookup (GstRegistry *registry, const char *filename); 484 auto p = gst_registry_lookup(gstRegistry, Str.toStringz(filename)); 485 486 if(p is null) 487 { 488 return null; 489 } 490 491 return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p); 492 } 493 494 /** 495 * Remove the feature from the registry. 496 * MT safe. 497 * Params: 498 * feature = the feature to remove. [transfer none] 499 */ 500 public void removeFeature(PluginFeature feature) 501 { 502 // void gst_registry_remove_feature (GstRegistry *registry, GstPluginFeature *feature); 503 gst_registry_remove_feature(gstRegistry, (feature is null) ? null : feature.getPluginFeatureStruct()); 504 } 505 506 /** 507 * Add the feature to the registry. The feature-added signal will be emitted. 508 * This function sinks feature. 509 * Params: 510 * feature = the feature to add. [transfer full] 511 * Returns: TRUE on success. MT safe. 512 */ 513 public int addFeature(PluginFeature feature) 514 { 515 // gboolean gst_registry_add_feature (GstRegistry *registry, GstPluginFeature *feature); 516 return gst_registry_add_feature(gstRegistry, (feature is null) ? null : feature.getPluginFeatureStruct()); 517 } 518 519 /** 520 * Checks whether a plugin feature by the given name exists in 521 * registry and whether its version is at least the 522 * version required. 523 * Params: 524 * featureName = the name of the feature (e.g. "oggdemux") 525 * minMajor = the minimum major version number 526 * minMinor = the minimum minor version number 527 * minMicro = the minimum micro version number 528 * feature = the feature that has been added 529 * Returns: TRUE if the feature could be found and the version is the same as the required version or newer, and FALSE otherwise. Signal Details The "feature-added" signal void user_function (GstRegistry *registry, GstPluginFeature *feature, gpointer user_data) : Run Last Signals that a feature has been added to the registry (possibly replacing a previously-added one by the same name) 530 */ 531 public int checkFeatureVersion(string featureName, uint minMajor, uint minMinor, uint minMicro) 532 { 533 // gboolean gst_registry_check_feature_version (GstRegistry *registry, const gchar *feature_name, guint min_major, guint min_minor, guint min_micro); 534 return gst_registry_check_feature_version(gstRegistry, Str.toStringz(featureName), minMajor, minMinor, minMicro); 535 } 536 }