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