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