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