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