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 = GstElementFactory.html 27 * outPack = gstreamer 28 * outFile = ElementFactory 29 * strct = GstElementFactory 30 * realStrct= 31 * ctorStrct= 32 * clss = ElementFactory 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_element_factory_ 41 * - gst_element_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ListG 49 * - gstreamer.Caps 50 * - gstreamer.Element 51 * - gstreamer.Plugin 52 * structWrap: 53 * - GList* -> ListG 54 * - GstCaps* -> Caps 55 * - GstElement* -> Element 56 * - GstElementFactory* -> ElementFactory 57 * - GstPlugin* -> Plugin 58 * module aliases: 59 * local aliases: 60 * overrides: 61 */ 62 63 module gstreamer.ElementFactory; 64 65 public import gstreamerc.gstreamertypes; 66 67 private import gstreamerc.gstreamer; 68 private import glib.ConstructionException; 69 private import gobject.ObjectG; 70 71 private import glib.Str; 72 private import glib.ListG; 73 private import gstreamer.Caps; 74 private import gstreamer.Element; 75 private import gstreamer.Plugin; 76 77 78 private import gstreamer.PluginFeature; 79 80 /** 81 * GstElementFactory is used to create instances of elements. A 82 * GstElementfactory can be added to a GstPlugin as it is also a 83 * GstPluginFeature. 84 * 85 * Use the gst_element_factory_find() and gst_element_factory_create() 86 * functions to create element instances or use gst_element_factory_make() as a 87 * convenient shortcut. 88 * 89 * The following code example shows you how to create a GstFileSrc element. 90 * 91 * $(DDOC_COMMENT example) 92 * 93 * Last reviewed on 2005-11-23 (0.9.5) 94 */ 95 public class ElementFactory : PluginFeature 96 { 97 98 /** the main Gtk struct */ 99 protected GstElementFactory* gstElementFactory; 100 101 102 /** Get the main Gtk struct */ 103 public GstElementFactory* getElementFactoryStruct() 104 { 105 return gstElementFactory; 106 } 107 108 109 /** the main Gtk struct as a void* */ 110 protected override void* getStruct() 111 { 112 return cast(void*)gstElementFactory; 113 } 114 115 /** 116 * Sets our main struct and passes it to the parent class 117 */ 118 public this (GstElementFactory* gstElementFactory) 119 { 120 super(cast(GstPluginFeature*)gstElementFactory); 121 this.gstElementFactory = gstElementFactory; 122 } 123 124 protected override void setStruct(GObject* obj) 125 { 126 super.setStruct(obj); 127 gstElementFactory = cast(GstElementFactory*)obj; 128 } 129 130 /** 131 * Create a new element of the type defined by the given element factory. 132 * The element will receive a guaranteed unique name, 133 * consisting of the element factory name and a number. 134 * Params: 135 * factoryname = a named factory to instantiate 136 * Returns: 137 * new GstElement or NULL if unable to create element 138 */ 139 public static Element make( string factoryname ) 140 { 141 // GstElement* gst_element_factory_make (const gchar *factoryname, const gchar *name); 142 auto p = gst_element_factory_make(Str.toStringz(factoryname), null ); 143 144 if(p is null) 145 { 146 throw new ConstructionException("null returned by gst_element_factory_make"); 147 } 148 149 return new Element( p ); 150 } 151 152 /** 153 */ 154 155 /** 156 * Create a new elementfactory capable of instantiating objects of the 157 * type and add the factory to plugin. 158 * Params: 159 * plugin = GstPlugin to register the element with, or NULL for 160 * a static element. [allow-none] 161 * name = name of elements of this type 162 * rank = rank of element (higher rank means more importance when autoplugging) 163 * type = GType of element to register 164 * Returns: TRUE, if the registering succeeded, FALSE on error 165 */ 166 public static int register(Plugin plugin, string name, uint rank, GType type) 167 { 168 // gboolean gst_element_register (GstPlugin *plugin, const gchar *name, guint rank, GType type); 169 return gst_element_register((plugin is null) ? null : plugin.getPluginStruct(), Str.toStringz(name), rank, type); 170 } 171 172 /** 173 * Search for an element factory of the given name. Refs the returned 174 * element factory; caller is responsible for unreffing. 175 * Params: 176 * name = name of factory to find 177 * Returns: GstElementFactory if found, NULL otherwise. [transfer full] 178 */ 179 public static ElementFactory find(string name) 180 { 181 // GstElementFactory * gst_element_factory_find (const gchar *name); 182 auto p = gst_element_factory_find(Str.toStringz(name)); 183 184 if(p is null) 185 { 186 return null; 187 } 188 189 return ObjectG.getDObject!(ElementFactory)(cast(GstElementFactory*) p); 190 } 191 192 /** 193 * Get the GType for elements managed by this factory. The type can 194 * only be retrieved if the element factory is loaded, which can be 195 * assured with gst_plugin_feature_load(). 196 * Returns: the GType for elements managed by this factory or 0 if the factory is not loaded. 197 */ 198 public GType getElementType() 199 { 200 // GType gst_element_factory_get_element_type (GstElementFactory *factory); 201 return gst_element_factory_get_element_type(gstElementFactory); 202 } 203 204 /** 205 * Get the metadata on factory with key. 206 * Params: 207 * key = a key 208 * Returns: the metadata with key on factory or NULL when there was no metadata with the given key. 209 */ 210 public string getMetadata(string key) 211 { 212 // const gchar * gst_element_factory_get_metadata (GstElementFactory *factory, const gchar *key); 213 return Str.toString(gst_element_factory_get_metadata(gstElementFactory, Str.toStringz(key))); 214 } 215 216 /** 217 * Get the available keys for the metadata on factory. 218 * Returns: a NULL-terminated array of key strings, or NULL when there is no metadata. Free with g_strfreev() when no longer needed. [transfer full][element-type utf8][array zero-terminated=1] 219 */ 220 public string[] getMetadataKeys() 221 { 222 // gchar ** gst_element_factory_get_metadata_keys (GstElementFactory *factory); 223 return Str.toStringArray(gst_element_factory_get_metadata_keys(gstElementFactory)); 224 } 225 226 /** 227 * Gets the number of pad_templates in this factory. 228 * Returns: the number of pad_templates 229 */ 230 public uint getNumPadTemplates() 231 { 232 // guint gst_element_factory_get_num_pad_templates (GstElementFactory *factory); 233 return gst_element_factory_get_num_pad_templates(gstElementFactory); 234 } 235 236 /** 237 * Gets the type of URIs the element supports or GST_URI_UNKNOWN if none. 238 * Returns: type of URIs this element supports 239 */ 240 public GstURIType getUriType() 241 { 242 // GstURIType gst_element_factory_get_uri_type (GstElementFactory *factory); 243 return gst_element_factory_get_uri_type(gstElementFactory); 244 } 245 246 /** 247 * Gets a NULL-terminated array of protocols this element supports or NULL if 248 * no protocols are supported. You may not change the contents of the returned 249 * array, as it is still owned by the element factory. Use g_strdupv() to 250 * make a copy of the protocol string array if you need to. 251 * Returns: the supported protocols or NULL. [transfer none][array zero-terminated=1] 252 */ 253 public string[] getUriProtocols() 254 { 255 // const gchar * const * gst_element_factory_get_uri_protocols (GstElementFactory *factory); 256 return Str.toStringArray(gst_element_factory_get_uri_protocols(gstElementFactory)); 257 } 258 259 /** 260 * Check if factory implements the interface with name interfacename. 261 * Params: 262 * interfacename = an interface name 263 * Returns: TRUE when factory implement the interface. 264 */ 265 public int hasInterface(string interfacename) 266 { 267 // gboolean gst_element_factory_has_interface (GstElementFactory *factory, const gchar *interfacename); 268 return gst_element_factory_has_interface(gstElementFactory, Str.toStringz(interfacename)); 269 } 270 271 /** 272 * Create a new element of the type defined by the given elementfactory. 273 * It will be given the name supplied, since all elements require a name as 274 * their first argument. 275 * Params: 276 * name = name of new element, or NULL to automatically create 277 * a unique name. [allow-none] 278 * Returns: new GstElement or NULL if the element couldn't be created. [transfer floating] 279 */ 280 public Element create(string name) 281 { 282 // GstElement * gst_element_factory_create (GstElementFactory *factory, const gchar *name); 283 auto p = gst_element_factory_create(gstElementFactory, Str.toStringz(name)); 284 285 if(p is null) 286 { 287 return null; 288 } 289 290 return ObjectG.getDObject!(Element)(cast(GstElement*) p); 291 } 292 293 /** 294 * Create a new element of the type defined by the given element factory. 295 * If name is NULL, then the element will receive a guaranteed unique name, 296 * consisting of the element factory name and a number. 297 * If name is given, it will be given the name supplied. 298 * Params: 299 * factoryname = a named factory to instantiate 300 * name = name of new element, or NULL to automatically create 301 * a unique name. [allow-none] 302 * Returns: new GstElement or NULL if unable to create element. [transfer floating] 303 */ 304 public static Element make(string factoryname, string name) 305 { 306 // GstElement * gst_element_factory_make (const gchar *factoryname, const gchar *name); 307 auto p = gst_element_factory_make(Str.toStringz(factoryname), Str.toStringz(name)); 308 309 if(p is null) 310 { 311 return null; 312 } 313 314 return ObjectG.getDObject!(Element)(cast(GstElement*) p); 315 } 316 317 /** 318 * Checks if the factory can sink all possible capabilities. 319 * Params: 320 * caps = the caps to check 321 * Returns: TRUE if the caps are fully compatible. 322 */ 323 public int canSinkAllCaps(Caps caps) 324 { 325 // gboolean gst_element_factory_can_sink_all_caps (GstElementFactory *factory, const GstCaps *caps); 326 return gst_element_factory_can_sink_all_caps(gstElementFactory, (caps is null) ? null : caps.getCapsStruct()); 327 } 328 329 /** 330 * Checks if the factory can src all possible capabilities. 331 * Params: 332 * caps = the caps to check 333 * Returns: TRUE if the caps are fully compatible. 334 */ 335 public int canSrcAllCaps(Caps caps) 336 { 337 // gboolean gst_element_factory_can_src_all_caps (GstElementFactory *factory, const GstCaps *caps); 338 return gst_element_factory_can_src_all_caps(gstElementFactory, (caps is null) ? null : caps.getCapsStruct()); 339 } 340 341 /** 342 * Checks if the factory can sink any possible capability. 343 * Params: 344 * caps = the caps to check 345 * Returns: TRUE if the caps have a common subset. 346 */ 347 public int canSinkAnyCaps(Caps caps) 348 { 349 // gboolean gst_element_factory_can_sink_any_caps (GstElementFactory *factory, const GstCaps *caps); 350 return gst_element_factory_can_sink_any_caps(gstElementFactory, (caps is null) ? null : caps.getCapsStruct()); 351 } 352 353 /** 354 * Checks if the factory can src any possible capability. 355 * Params: 356 * caps = the caps to check 357 * Returns: TRUE if the caps have a common subset. 358 */ 359 public int canSrcAnyCaps(Caps caps) 360 { 361 // gboolean gst_element_factory_can_src_any_caps (GstElementFactory *factory, const GstCaps *caps); 362 return gst_element_factory_can_src_any_caps(gstElementFactory, (caps is null) ? null : caps.getCapsStruct()); 363 } 364 365 /** 366 * Gets the GList of GstStaticPadTemplate for this factory. 367 * Returns: the static pad templates. [transfer none][element-type Gst.StaticPadTemplate] 368 */ 369 public ListG getStaticPadTemplates() 370 { 371 // const GList * gst_element_factory_get_static_pad_templates (GstElementFactory *factory); 372 auto p = gst_element_factory_get_static_pad_templates(gstElementFactory); 373 374 if(p is null) 375 { 376 return null; 377 } 378 379 return ObjectG.getDObject!(ListG)(cast(GList*) p); 380 } 381 382 /** 383 * Filter out all the elementfactories in list that can handle caps in 384 * the given direction. 385 * If subsetonly is TRUE, then only the elements whose pads templates 386 * are a complete superset of caps will be returned. Else any element 387 * whose pad templates caps can intersect with caps will be returned. 388 * Params: 389 * list = a GList of 390 * GstElementFactory to filter. [transfer none][element-type Gst.ElementFactory] 391 * caps = a GstCaps 392 * direction = a GstPadDirection to filter on 393 * subsetonly = whether to filter on caps subsets or not. 394 * Returns: a GList of GstElementFactory elements that match the given requisits. Use gst_plugin_feature_list_free after usage. [transfer full][element-type Gst.ElementFactory] 395 */ 396 public static ListG listFilter(ListG list, Caps caps, GstPadDirection direction, int subsetonly) 397 { 398 // GList * gst_element_factory_list_filter (GList *list, const GstCaps *caps, GstPadDirection direction, gboolean subsetonly); 399 auto p = gst_element_factory_list_filter((list is null) ? null : list.getListGStruct(), (caps is null) ? null : caps.getCapsStruct(), direction, subsetonly); 400 401 if(p is null) 402 { 403 return null; 404 } 405 406 return ObjectG.getDObject!(ListG)(cast(GList*) p); 407 } 408 409 /** 410 * Get a list of factories that match the given type. Only elements 411 * with a rank greater or equal to minrank will be returned. 412 * The list of factories is returned by decreasing rank. 413 * Params: 414 * type = a GstElementFactoryListType 415 * minrank = Minimum rank 416 * Returns: a GList of GstElementFactory elements. Use gst_plugin_feature_list_free() after usage. [transfer full][element-type Gst.ElementFactory] 417 */ 418 public static ListG listGetElements(GstElementFactoryListType type, GstRank minrank) 419 { 420 // GList * gst_element_factory_list_get_elements (GstElementFactoryListType type, GstRank minrank); 421 auto p = gst_element_factory_list_get_elements(type, minrank); 422 423 if(p is null) 424 { 425 return null; 426 } 427 428 return ObjectG.getDObject!(ListG)(cast(GList*) p); 429 } 430 431 /** 432 * Check if factory is of the given types. 433 * Params: 434 * type = a GstElementFactoryListType 435 * Returns: TRUE if factory is of type. 436 */ 437 public int listIsType(GstElementFactoryListType type) 438 { 439 // gboolean gst_element_factory_list_is_type (GstElementFactory *factory, GstElementFactoryListType type); 440 return gst_element_factory_list_is_type(gstElementFactory, type); 441 } 442 }