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