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.Element;
26 
27 private import glib.ErrorG;
28 private import glib.GException;
29 private import glib.ListG;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 private import gobject.Type;
34 private import gstreamer.Bus;
35 private import gstreamer.Caps;
36 private import gstreamer.Clock;
37 private import gstreamer.Context;
38 private import gstreamer.ElementFactory;
39 private import gstreamer.Event;
40 private import gstreamer.Iterator;
41 private import gstreamer.Message;
42 private import gstreamer.ObjectGst;
43 private import gstreamer.Pad;
44 private import gstreamer.PadTemplate;
45 private import gstreamer.Plugin;
46 private import gstreamer.Query;
47 private import gstreamerc.gstreamer;
48 public  import gstreamerc.gstreamertypes;
49 public  import gtkc.gdktypes;
50 private import gtkc.gobject;
51 
52 
53 /**
54  * GstElement is the abstract base class needed to construct an element that
55  * can be used in a GStreamer pipeline. Please refer to the plugin writers
56  * guide for more information on creating #GstElement subclasses.
57  * 
58  * The name of a #GstElement can be get with gst_element_get_name() and set with
59  * gst_element_set_name().  For speed, GST_ELEMENT_NAME() can be used in the
60  * core when using the appropriate locking. Do not use this in plug-ins or
61  * applications in order to retain ABI compatibility.
62  * 
63  * Elements can have pads (of the type #GstPad).  These pads link to pads on
64  * other elements.  #GstBuffer flow between these linked pads.
65  * A #GstElement has a #GList of #GstPad structures for all their input (or sink)
66  * and output (or source) pads.
67  * Core and plug-in writers can add and remove pads with gst_element_add_pad()
68  * and gst_element_remove_pad().
69  * 
70  * An existing pad of an element can be retrieved by name with
71  * gst_element_get_static_pad(). A new dynamic pad can be created using
72  * gst_element_request_pad() with a #GstPadTemplate.
73  * An iterator of all pads can be retrieved with gst_element_iterate_pads().
74  * 
75  * Elements can be linked through their pads.
76  * If the link is straightforward, use the gst_element_link()
77  * convenience function to link two elements, or gst_element_link_many()
78  * for more elements in a row.
79  * Use gst_element_link_filtered() to link two elements constrained by
80  * a specified set of #GstCaps.
81  * For finer control, use gst_element_link_pads() and
82  * gst_element_link_pads_filtered() to specify the pads to link on
83  * each element by name.
84  * 
85  * Each element has a state (see #GstState).  You can get and set the state
86  * of an element with gst_element_get_state() and gst_element_set_state().
87  * Setting a state triggers a #GstStateChange. To get a string representation
88  * of a #GstState, use gst_element_state_get_name().
89  * 
90  * You can get and set a #GstClock on an element using gst_element_get_clock()
91  * and gst_element_set_clock().
92  * Some elements can provide a clock for the pipeline if
93  * the #GST_ELEMENT_FLAG_PROVIDE_CLOCK flag is set. With the
94  * gst_element_provide_clock() method one can retrieve the clock provided by
95  * such an element.
96  * Not all elements require a clock to operate correctly. If the
97  * #GST_ELEMENT_FLAG_REQUIRE_CLOCK() flag is set, a clock should be set on the
98  * element with gst_element_set_clock().
99  * 
100  * Note that clock selection and distribution is normally handled by the
101  * toplevel #GstPipeline so the clock functions are only to be used in very
102  * specific situations.
103  */
104 public class Element : ObjectGst
105 {
106 	/** the main Gtk struct */
107 	protected GstElement* gstElement;
108 
109 	/** Get the main Gtk struct */
110 	public GstElement* getElementStruct()
111 	{
112 		return gstElement;
113 	}
114 
115 	/** the main Gtk struct as a void* */
116 	protected override void* getStruct()
117 	{
118 		return cast(void*)gstElement;
119 	}
120 
121 	protected override void setStruct(GObject* obj)
122 	{
123 		gstElement = cast(GstElement*)obj;
124 		super.setStruct(obj);
125 	}
126 
127 	/**
128 	 * Sets our main struct and passes it to the parent class.
129 	 */
130 	public this (GstElement* gstElement, bool ownedRef = false)
131 	{
132 		this.gstElement = gstElement;
133 		super(cast(GstObject*)gstElement, ownedRef);
134 	}
135 
136 	/**
137 	 * Queries an element for the stream position.
138 	 * This is a convenience function for gstreamerD.
139 	 * Returns:
140 	 *  The current position in nanoseconds - GstFormat.TIME.
141 	 */
142 	public long queryPosition()
143 	{
144 		GstFormat form = GstFormat.TIME;
145 		long cur_pos;
146 		queryPosition( form, cur_pos );
147 		return cur_pos;
148 	}
149 	
150 	/**
151 	 * Queries an element for the stream duration.
152 	 * This is a convenience function for gstreamerD.
153 	 * Returns:
154 	 *  The duration in nanoseconds - GstFormat.TIME.
155 	 */
156 	public long queryDuration()
157 	{
158 		GstFormat form = GstFormat.TIME;
159 		long cur_dur;
160 		queryDuration( form, cur_dur );
161 		return cur_dur;
162 	}
163 	
164 	/**
165 	 *	This set's the filename for a filesrc element.
166 	 */
167 	public void location( string set )
168 	{
169 		//g_object_set( G_OBJECT(getElementStruct()), "location", set, NULL);
170 		setProperty("location", set);
171 	}
172 	
173 	/**
174 	 * Set the caps property of an Element.
175 	 */
176 	void caps( Caps cp )
177 	{
178 		g_object_set( getElementStruct(), Str.toStringz("caps"), cp.getCapsStruct(), null );
179 	}
180 	
181 	/**
182 	 * For your convenience in gstreamerD: you can seek to the
183 	 * position of the pipeline measured in time_nanoseconds.
184 	 */
185 	public int seek( long time_nanoseconds ) //gint64
186 	{
187 		return seek( 1.0, GstFormat.TIME, GstSeekFlags.FLUSH,
188 		GstSeekType.SET, time_nanoseconds,
189 		GstSeekType.NONE, GST_CLOCK_TIME_NONE);
190 	}
191 	
192 	/**
193 	 * Get's all the pads from an element in a Pad[].
194 	 */
195 	public Pad[] pads()
196 	{
197 		Pad[] result;
198 		GValue* pad = g_value_init(new GValue(), Type.fromName("GstPad"));
199 		GstIterator* iter = gst_element_iterate_pads(gstElement);
200 		
201 		while ( gst_iterator_next(iter, pad) == GstIteratorResult.OK )
202 		{
203 			result ~= new Pad(cast(GstPad*)g_value_get_object(pad));
204 			g_value_reset(pad);
205 		}
206 		
207 		g_value_unset(pad);
208 		
209 		return result;
210 	}
211 
212 	/**
213 	 */
214 
215 	/** */
216 	public static GType getType()
217 	{
218 		return gst_element_get_type();
219 	}
220 
221 	/**
222 	 * Creates an element for handling the given URI.
223 	 *
224 	 * Params:
225 	 *     type = Whether to create a source or a sink
226 	 *     uri = URI to create an element for
227 	 *     elementname = Name of created element, can be %NULL.
228 	 *
229 	 * Return: a new element or %NULL if none could be created
230 	 *
231 	 * Throws: GException on failure.
232 	 */
233 	public static Element makeFromUri(GstURIType type, string uri, string elementname)
234 	{
235 		GError* err = null;
236 		
237 		auto p = gst_element_make_from_uri(type, Str.toStringz(uri), Str.toStringz(elementname), &err);
238 		
239 		if (err !is null)
240 		{
241 			throw new GException( new ErrorG(err) );
242 		}
243 		
244 		if(p is null)
245 		{
246 			return null;
247 		}
248 		
249 		return ObjectG.getDObject!(Element)(cast(GstElement*) p);
250 	}
251 
252 	/**
253 	 * Create a new elementfactory capable of instantiating objects of the
254 	 * @type and add the factory to @plugin.
255 	 *
256 	 * Params:
257 	 *     plugin = #GstPlugin to register the element with, or %NULL for
258 	 *         a static element.
259 	 *     name = name of elements of this type
260 	 *     rank = rank of element (higher rank means more importance when autoplugging)
261 	 *     type = GType of element to register
262 	 *
263 	 * Return: %TRUE, if the registering succeeded, %FALSE on error
264 	 */
265 	public static bool register(Plugin plugin, string name, uint rank, GType type)
266 	{
267 		return gst_element_register((plugin is null) ? null : plugin.getPluginStruct(), Str.toStringz(name), rank, type) != 0;
268 	}
269 
270 	/**
271 	 * Gets a string representing the given state change result.
272 	 *
273 	 * Params:
274 	 *     stateRet = a #GstStateChangeReturn to get the name of.
275 	 *
276 	 * Return: a string with the name of the state
277 	 *     result.
278 	 */
279 	public static string stateChangeReturnGetName(GstStateChangeReturn stateRet)
280 	{
281 		return Str.toString(gst_element_state_change_return_get_name(stateRet));
282 	}
283 
284 	/**
285 	 * Gets a string representing the given state.
286 	 *
287 	 * Params:
288 	 *     state = a #GstState to get the name of.
289 	 *
290 	 * Return: a string with the name of the state.
291 	 */
292 	public static string stateGetName(GstState state)
293 	{
294 		return Str.toString(gst_element_state_get_name(state));
295 	}
296 
297 	/**
298 	 * Abort the state change of the element. This function is used
299 	 * by elements that do asynchronous state changes and find out
300 	 * something is wrong.
301 	 *
302 	 * This function should be called with the STATE_LOCK held.
303 	 *
304 	 * MT safe.
305 	 */
306 	public void abortState()
307 	{
308 		gst_element_abort_state(gstElement);
309 	}
310 
311 	/**
312 	 * Adds a pad (link point) to @element. @pad's parent will be set to @element;
313 	 * see gst_object_set_parent() for refcounting information.
314 	 *
315 	 * Pads are not automatically activated so elements should perform the needed
316 	 * steps to activate the pad in case this pad is added in the PAUSED or PLAYING
317 	 * state. See gst_pad_set_active() for more information about activating pads.
318 	 *
319 	 * The pad and the element should be unlocked when calling this function.
320 	 *
321 	 * This function will emit the #GstElement::pad-added signal on the element.
322 	 *
323 	 * Params:
324 	 *     pad = the #GstPad to add to the element.
325 	 *
326 	 * Return: %TRUE if the pad could be added. This function can fail when
327 	 *     a pad with the same name already existed or the pad already had another
328 	 *     parent.
329 	 *
330 	 *     MT safe.
331 	 */
332 	public bool addPad(Pad pad)
333 	{
334 		return gst_element_add_pad(gstElement, (pad is null) ? null : pad.getPadStruct()) != 0;
335 	}
336 
337 	/**
338 	 * Perform @transition on @element.
339 	 *
340 	 * This function must be called with STATE_LOCK held and is mainly used
341 	 * internally.
342 	 *
343 	 * Params:
344 	 *     transition = the requested transition
345 	 *
346 	 * Return: the #GstStateChangeReturn of the state transition.
347 	 */
348 	public GstStateChangeReturn changeState(GstStateChange transition)
349 	{
350 		return gst_element_change_state(gstElement, transition);
351 	}
352 
353 	/**
354 	 * Commit the state change of the element and proceed to the next
355 	 * pending state if any. This function is used
356 	 * by elements that do asynchronous state changes.
357 	 * The core will normally call this method automatically when an
358 	 * element returned %GST_STATE_CHANGE_SUCCESS from the state change function.
359 	 *
360 	 * If after calling this method the element still has not reached
361 	 * the pending state, the next state change is performed.
362 	 *
363 	 * This method is used internally and should normally not be called by plugins
364 	 * or applications.
365 	 *
366 	 * Params:
367 	 *     ret = The previous state return value
368 	 *
369 	 * Return: The result of the commit state change.
370 	 *
371 	 *     MT safe.
372 	 */
373 	public GstStateChangeReturn continueState(GstStateChangeReturn ret)
374 	{
375 		return gst_element_continue_state(gstElement, ret);
376 	}
377 
378 	/**
379 	 * Creates a pad for each pad template that is always available.
380 	 * This function is only useful during object initialization of
381 	 * subclasses of #GstElement.
382 	 */
383 	public void createAllPads()
384 	{
385 		gst_element_create_all_pads(gstElement);
386 	}
387 
388 	/**
389 	 * Returns the base time of the element. The base time is the
390 	 * absolute time of the clock when this element was last put to
391 	 * PLAYING. Subtracting the base time from the clock time gives
392 	 * the running time of the element.
393 	 *
394 	 * Return: the base time of the element.
395 	 *
396 	 *     MT safe.
397 	 */
398 	public GstClockTime getBaseTime()
399 	{
400 		return gst_element_get_base_time(gstElement);
401 	}
402 
403 	/**
404 	 * Returns the bus of the element. Note that only a #GstPipeline will provide a
405 	 * bus for the application.
406 	 *
407 	 * Return: the element's #GstBus. unref after usage.
408 	 *
409 	 *     MT safe.
410 	 */
411 	public Bus getBus()
412 	{
413 		auto p = gst_element_get_bus(gstElement);
414 		
415 		if(p is null)
416 		{
417 			return null;
418 		}
419 		
420 		return ObjectG.getDObject!(Bus)(cast(GstBus*) p, true);
421 	}
422 
423 	/**
424 	 * Gets the currently configured clock of the element. This is the clock as was
425 	 * last set with gst_element_set_clock().
426 	 *
427 	 * Elements in a pipeline will only have their clock set when the
428 	 * pipeline is in the PLAYING state.
429 	 *
430 	 * Return: the #GstClock of the element. unref after usage.
431 	 *
432 	 *     MT safe.
433 	 */
434 	public Clock getClock()
435 	{
436 		auto p = gst_element_get_clock(gstElement);
437 		
438 		if(p is null)
439 		{
440 			return null;
441 		}
442 		
443 		return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true);
444 	}
445 
446 	/**
447 	 * Looks for an unlinked pad to which the given pad can link. It is not
448 	 * guaranteed that linking the pads will work, though it should work in most
449 	 * cases.
450 	 *
451 	 * This function will first attempt to find a compatible unlinked ALWAYS pad,
452 	 * and if none can be found, it will request a compatible REQUEST pad by looking
453 	 * at the templates of @element.
454 	 *
455 	 * Params:
456 	 *     pad = the #GstPad to find a compatible one for.
457 	 *     caps = the #GstCaps to use as a filter.
458 	 *
459 	 * Return: the #GstPad to which a link
460 	 *     can be made, or %NULL if one cannot be found. gst_object_unref()
461 	 *     after usage.
462 	 */
463 	public Pad getCompatiblePad(Pad pad, Caps caps)
464 	{
465 		auto p = gst_element_get_compatible_pad(gstElement, (pad is null) ? null : pad.getPadStruct(), (caps is null) ? null : caps.getCapsStruct());
466 		
467 		if(p is null)
468 		{
469 			return null;
470 		}
471 		
472 		return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
473 	}
474 
475 	/**
476 	 * Retrieves a pad template from @element that is compatible with @compattempl.
477 	 * Pads from compatible templates can be linked together.
478 	 *
479 	 * Params:
480 	 *     compattempl = the #GstPadTemplate to find a compatible
481 	 *         template for
482 	 *
483 	 * Return: a compatible #GstPadTemplate,
484 	 *     or %NULL if none was found. No unreferencing is necessary.
485 	 */
486 	public PadTemplate getCompatiblePadTemplate(PadTemplate compattempl)
487 	{
488 		auto p = gst_element_get_compatible_pad_template(gstElement, (compattempl is null) ? null : compattempl.getPadTemplateStruct());
489 		
490 		if(p is null)
491 		{
492 			return null;
493 		}
494 		
495 		return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p);
496 	}
497 
498 	/**
499 	 * Gets the context with @context_type set on the element or NULL.
500 	 *
501 	 * MT safe.
502 	 *
503 	 * Params:
504 	 *     contextType = a name of a context to retrieve
505 	 *
506 	 * Return: A #GstContext or NULL
507 	 *
508 	 * Since: 1.8
509 	 */
510 	public Context getContext(string contextType)
511 	{
512 		auto p = gst_element_get_context(gstElement, Str.toStringz(contextType));
513 		
514 		if(p is null)
515 		{
516 			return null;
517 		}
518 		
519 		return ObjectG.getDObject!(Context)(cast(GstContext*) p, true);
520 	}
521 
522 	/**
523 	 * Gets the context with @context_type set on the element or NULL.
524 	 *
525 	 * Params:
526 	 *     contextType = a name of a context to retrieve
527 	 *
528 	 * Return: A #GstContext or NULL
529 	 *
530 	 * Since: 1.8
531 	 */
532 	public Context getContextUnlocked(string contextType)
533 	{
534 		auto p = gst_element_get_context_unlocked(gstElement, Str.toStringz(contextType));
535 		
536 		if(p is null)
537 		{
538 			return null;
539 		}
540 		
541 		return ObjectG.getDObject!(Context)(cast(GstContext*) p, true);
542 	}
543 
544 	/**
545 	 * Gets the contexts set on the element.
546 	 *
547 	 * MT safe.
548 	 *
549 	 * Return: List of #GstContext
550 	 *
551 	 * Since: 1.8
552 	 */
553 	public ListG getContexts()
554 	{
555 		auto p = gst_element_get_contexts(gstElement);
556 		
557 		if(p is null)
558 		{
559 			return null;
560 		}
561 		
562 		return new ListG(cast(GList*) p, true);
563 	}
564 
565 	/**
566 	 * Retrieves the factory that was used to create this element.
567 	 *
568 	 * Return: the #GstElementFactory used for creating this
569 	 *     element. no refcounting is needed.
570 	 */
571 	public ElementFactory getFactory()
572 	{
573 		auto p = gst_element_get_factory(gstElement);
574 		
575 		if(p is null)
576 		{
577 			return null;
578 		}
579 		
580 		return ObjectG.getDObject!(ElementFactory)(cast(GstElementFactory*) p);
581 	}
582 
583 	/**
584 	 * Retrieves a pad from the element by name (e.g. "src_\%d"). This version only
585 	 * retrieves request pads. The pad should be released with
586 	 * gst_element_release_request_pad().
587 	 *
588 	 * This method is slower than manually getting the pad template and calling
589 	 * gst_element_request_pad() if the pads should have a specific name (e.g.
590 	 * @name is "src_1" instead of "src_\%u").
591 	 *
592 	 * Params:
593 	 *     name = the name of the request #GstPad to retrieve.
594 	 *
595 	 * Return: requested #GstPad if found,
596 	 *     otherwise %NULL.  Release after usage.
597 	 */
598 	public Pad getRequestPad(string name)
599 	{
600 		auto p = gst_element_get_request_pad(gstElement, Str.toStringz(name));
601 		
602 		if(p is null)
603 		{
604 			return null;
605 		}
606 		
607 		return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
608 	}
609 
610 	/**
611 	 * Returns the start time of the element. The start time is the
612 	 * running time of the clock when this element was last put to PAUSED.
613 	 *
614 	 * Usually the start_time is managed by a toplevel element such as
615 	 * #GstPipeline.
616 	 *
617 	 * MT safe.
618 	 *
619 	 * Return: the start time of the element.
620 	 */
621 	public GstClockTime getStartTime()
622 	{
623 		return gst_element_get_start_time(gstElement);
624 	}
625 
626 	/**
627 	 * Gets the state of the element.
628 	 *
629 	 * For elements that performed an ASYNC state change, as reported by
630 	 * gst_element_set_state(), this function will block up to the
631 	 * specified timeout value for the state change to complete.
632 	 * If the element completes the state change or goes into
633 	 * an error, this function returns immediately with a return value of
634 	 * %GST_STATE_CHANGE_SUCCESS or %GST_STATE_CHANGE_FAILURE respectively.
635 	 *
636 	 * For elements that did not return %GST_STATE_CHANGE_ASYNC, this function
637 	 * returns the current and pending state immediately.
638 	 *
639 	 * This function returns %GST_STATE_CHANGE_NO_PREROLL if the element
640 	 * successfully changed its state but is not able to provide data yet.
641 	 * This mostly happens for live sources that only produce data in
642 	 * %GST_STATE_PLAYING. While the state change return is equivalent to
643 	 * %GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that
644 	 * some sink elements might not be able to complete their state change because
645 	 * an element is not producing data to complete the preroll. When setting the
646 	 * element to playing, the preroll will complete and playback will start.
647 	 *
648 	 * Params:
649 	 *     state = a pointer to #GstState to hold the state.
650 	 *         Can be %NULL.
651 	 *     pending = a pointer to #GstState to hold the pending
652 	 *         state. Can be %NULL.
653 	 *     timeout = a #GstClockTime to specify the timeout for an async
654 	 *         state change or %GST_CLOCK_TIME_NONE for infinite timeout.
655 	 *
656 	 * Return: %GST_STATE_CHANGE_SUCCESS if the element has no more pending state
657 	 *     and the last state change succeeded, %GST_STATE_CHANGE_ASYNC if the
658 	 *     element is still performing a state change or
659 	 *     %GST_STATE_CHANGE_FAILURE if the last state change failed.
660 	 *
661 	 *     MT safe.
662 	 */
663 	public GstStateChangeReturn getState(out GstState state, out GstState pending, GstClockTime timeout)
664 	{
665 		return gst_element_get_state(gstElement, &state, &pending, timeout);
666 	}
667 
668 	/**
669 	 * Retrieves a pad from @element by name. This version only retrieves
670 	 * already-existing (i.e. 'static') pads.
671 	 *
672 	 * Params:
673 	 *     name = the name of the static #GstPad to retrieve.
674 	 *
675 	 * Return: the requested #GstPad if
676 	 *     found, otherwise %NULL.  unref after usage.
677 	 *
678 	 *     MT safe.
679 	 */
680 	public Pad getStaticPad(string name)
681 	{
682 		auto p = gst_element_get_static_pad(gstElement, Str.toStringz(name));
683 		
684 		if(p is null)
685 		{
686 			return null;
687 		}
688 		
689 		return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
690 	}
691 
692 	/**
693 	 * Checks if the state of an element is locked.
694 	 * If the state of an element is locked, state changes of the parent don't
695 	 * affect the element.
696 	 * This way you can leave currently unused elements inside bins. Just lock their
697 	 * state before changing the state from #GST_STATE_NULL.
698 	 *
699 	 * MT safe.
700 	 *
701 	 * Return: %TRUE, if the element's state is locked.
702 	 */
703 	public bool isLockedState()
704 	{
705 		return gst_element_is_locked_state(gstElement) != 0;
706 	}
707 
708 	/**
709 	 * Retrieves an iterator of @element's pads. The iterator should
710 	 * be freed after usage. Also more specialized iterators exists such as
711 	 * gst_element_iterate_src_pads() or gst_element_iterate_sink_pads().
712 	 *
713 	 * The order of pads returned by the iterator will be the order in which
714 	 * the pads were added to the element.
715 	 *
716 	 * Return: the #GstIterator of #GstPad.
717 	 *
718 	 *     MT safe.
719 	 */
720 	public Iterator iteratePads()
721 	{
722 		auto p = gst_element_iterate_pads(gstElement);
723 		
724 		if(p is null)
725 		{
726 			return null;
727 		}
728 		
729 		return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
730 	}
731 
732 	/**
733 	 * Retrieves an iterator of @element's sink pads.
734 	 *
735 	 * The order of pads returned by the iterator will be the order in which
736 	 * the pads were added to the element.
737 	 *
738 	 * Return: the #GstIterator of #GstPad.
739 	 *
740 	 *     MT safe.
741 	 */
742 	public Iterator iterateSinkPads()
743 	{
744 		auto p = gst_element_iterate_sink_pads(gstElement);
745 		
746 		if(p is null)
747 		{
748 			return null;
749 		}
750 		
751 		return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
752 	}
753 
754 	/**
755 	 * Retrieves an iterator of @element's source pads.
756 	 *
757 	 * The order of pads returned by the iterator will be the order in which
758 	 * the pads were added to the element.
759 	 *
760 	 * Return: the #GstIterator of #GstPad.
761 	 *
762 	 *     MT safe.
763 	 */
764 	public Iterator iterateSrcPads()
765 	{
766 		auto p = gst_element_iterate_src_pads(gstElement);
767 		
768 		if(p is null)
769 		{
770 			return null;
771 		}
772 		
773 		return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
774 	}
775 
776 	/**
777 	 * Links @src to @dest. The link must be from source to
778 	 * destination; the other direction will not be tried. The function looks for
779 	 * existing pads that aren't linked yet. It will request new pads if necessary.
780 	 * Such pads need to be released manually when unlinking.
781 	 * If multiple links are possible, only one is established.
782 	 *
783 	 * Make sure you have added your elements to a bin or pipeline with
784 	 * gst_bin_add() before trying to link them.
785 	 *
786 	 * Params:
787 	 *     dest = the #GstElement containing the destination pad.
788 	 *
789 	 * Return: %TRUE if the elements could be linked, %FALSE otherwise.
790 	 */
791 	public bool link(Element dest)
792 	{
793 		return gst_element_link(gstElement, (dest is null) ? null : dest.getElementStruct()) != 0;
794 	}
795 
796 	/**
797 	 * Links @src to @dest using the given caps as filtercaps.
798 	 * The link must be from source to
799 	 * destination; the other direction will not be tried. The function looks for
800 	 * existing pads that aren't linked yet. It will request new pads if necessary.
801 	 * If multiple links are possible, only one is established.
802 	 *
803 	 * Make sure you have added your elements to a bin or pipeline with
804 	 * gst_bin_add() before trying to link them.
805 	 *
806 	 * Params:
807 	 *     dest = the #GstElement containing the destination pad.
808 	 *     filter = the #GstCaps to filter the link,
809 	 *         or %NULL for no filter.
810 	 *
811 	 * Return: %TRUE if the pads could be linked, %FALSE otherwise.
812 	 */
813 	public bool linkFiltered(Element dest, Caps filter)
814 	{
815 		return gst_element_link_filtered(gstElement, (dest is null) ? null : dest.getElementStruct(), (filter is null) ? null : filter.getCapsStruct()) != 0;
816 	}
817 
818 	/**
819 	 * Links the two named pads of the source and destination elements.
820 	 * Side effect is that if one of the pads has no parent, it becomes a
821 	 * child of the parent of the other element.  If they have different
822 	 * parents, the link fails.
823 	 *
824 	 * Params:
825 	 *     srcpadname = the name of the #GstPad in source element
826 	 *         or %NULL for any pad.
827 	 *     dest = the #GstElement containing the destination pad.
828 	 *     destpadname = the name of the #GstPad in destination element,
829 	 *         or %NULL for any pad.
830 	 *
831 	 * Return: %TRUE if the pads could be linked, %FALSE otherwise.
832 	 */
833 	public bool linkPads(string srcpadname, Element dest, string destpadname)
834 	{
835 		return gst_element_link_pads(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname)) != 0;
836 	}
837 
838 	/**
839 	 * Links the two named pads of the source and destination elements. Side effect
840 	 * is that if one of the pads has no parent, it becomes a child of the parent of
841 	 * the other element. If they have different parents, the link fails. If @caps
842 	 * is not %NULL, makes sure that the caps of the link is a subset of @caps.
843 	 *
844 	 * Params:
845 	 *     srcpadname = the name of the #GstPad in source element
846 	 *         or %NULL for any pad.
847 	 *     dest = the #GstElement containing the destination pad.
848 	 *     destpadname = the name of the #GstPad in destination element
849 	 *         or %NULL for any pad.
850 	 *     filter = the #GstCaps to filter the link,
851 	 *         or %NULL for no filter.
852 	 *
853 	 * Return: %TRUE if the pads could be linked, %FALSE otherwise.
854 	 */
855 	public bool linkPadsFiltered(string srcpadname, Element dest, string destpadname, Caps filter)
856 	{
857 		return gst_element_link_pads_filtered(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname), (filter is null) ? null : filter.getCapsStruct()) != 0;
858 	}
859 
860 	/**
861 	 * Links the two named pads of the source and destination elements.
862 	 * Side effect is that if one of the pads has no parent, it becomes a
863 	 * child of the parent of the other element.  If they have different
864 	 * parents, the link fails.
865 	 *
866 	 * Calling gst_element_link_pads_full() with @flags == %GST_PAD_LINK_CHECK_DEFAULT
867 	 * is the same as calling gst_element_link_pads() and the recommended way of
868 	 * linking pads with safety checks applied.
869 	 *
870 	 * This is a convenience function for gst_pad_link_full().
871 	 *
872 	 * Params:
873 	 *     srcpadname = the name of the #GstPad in source element
874 	 *         or %NULL for any pad.
875 	 *     dest = the #GstElement containing the destination pad.
876 	 *     destpadname = the name of the #GstPad in destination element,
877 	 *         or %NULL for any pad.
878 	 *     flags = the #GstPadLinkCheck to be performed when linking pads.
879 	 *
880 	 * Return: %TRUE if the pads could be linked, %FALSE otherwise.
881 	 */
882 	public bool linkPadsFull(string srcpadname, Element dest, string destpadname, GstPadLinkCheck flags)
883 	{
884 		return gst_element_link_pads_full(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname), flags) != 0;
885 	}
886 
887 	/**
888 	 * Brings the element to the lost state. The current state of the
889 	 * element is copied to the pending state so that any call to
890 	 * gst_element_get_state() will return %GST_STATE_CHANGE_ASYNC.
891 	 *
892 	 * An ASYNC_START message is posted. If the element was PLAYING, it will
893 	 * go to PAUSED. The element will be restored to its PLAYING state by
894 	 * the parent pipeline when it prerolls again.
895 	 *
896 	 * This is mostly used for elements that lost their preroll buffer
897 	 * in the %GST_STATE_PAUSED or %GST_STATE_PLAYING state after a flush,
898 	 * they will go to their pending state again when a new preroll buffer is
899 	 * queued. This function can only be called when the element is currently
900 	 * not in error or an async state change.
901 	 *
902 	 * This function is used internally and should normally not be called from
903 	 * plugins or applications.
904 	 */
905 	public void lostState()
906 	{
907 		gst_element_lost_state(gstElement);
908 	}
909 
910 	/**
911 	 * Post an error, warning or info message on the bus from inside an element.
912 	 *
913 	 * @type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or
914 	 * #GST_MESSAGE_INFO.
915 	 *
916 	 * MT safe.
917 	 *
918 	 * Params:
919 	 *     type = the #GstMessageType
920 	 *     domain = the GStreamer GError domain this message belongs to
921 	 *     code = the GError code belonging to the domain
922 	 *     text = an allocated text string to be used
923 	 *         as a replacement for the default message connected to code,
924 	 *         or %NULL
925 	 *     dbg = an allocated debug message to be
926 	 *         used as a replacement for the default debugging information,
927 	 *         or %NULL
928 	 *     file = the source code file where the error was generated
929 	 *     funct = the source code function where the error was generated
930 	 *     line = the source code line where the error was generated
931 	 */
932 	public void messageFull(GstMessageType type, GQuark domain, int code, string text, string dbg, string file, string funct, int line)
933 	{
934 		gst_element_message_full(gstElement, type, domain, code, Str.toStringz(text), Str.toStringz(dbg), Str.toStringz(file), Str.toStringz(funct), line);
935 	}
936 
937 	/**
938 	 * Use this function to signal that the element does not expect any more pads
939 	 * to show up in the current pipeline. This function should be called whenever
940 	 * pads have been added by the element itself. Elements with #GST_PAD_SOMETIMES
941 	 * pad templates use this in combination with autopluggers to figure out that
942 	 * the element is done initializing its pads.
943 	 *
944 	 * This function emits the #GstElement::no-more-pads signal.
945 	 *
946 	 * MT safe.
947 	 */
948 	public void noMorePads()
949 	{
950 		gst_element_no_more_pads(gstElement);
951 	}
952 
953 	/**
954 	 * Post a message on the element's #GstBus. This function takes ownership of the
955 	 * message; if you want to access the message after this call, you should add an
956 	 * additional reference before calling.
957 	 *
958 	 * Params:
959 	 *     message = a #GstMessage to post
960 	 *
961 	 * Return: %TRUE if the message was successfully posted. The function returns
962 	 *     %FALSE if the element did not have a bus.
963 	 *
964 	 *     MT safe.
965 	 */
966 	public bool postMessage(Message message)
967 	{
968 		return gst_element_post_message(gstElement, (message is null) ? null : message.getMessageStruct()) != 0;
969 	}
970 
971 	/**
972 	 * Get the clock provided by the given element.
973 	 * <note>An element is only required to provide a clock in the PAUSED
974 	 * state. Some elements can provide a clock in other states.</note>
975 	 *
976 	 * Return: the GstClock provided by the
977 	 *     element or %NULL if no clock could be provided.  Unref after usage.
978 	 *
979 	 *     MT safe.
980 	 */
981 	public Clock provideClock()
982 	{
983 		auto p = gst_element_provide_clock(gstElement);
984 		
985 		if(p is null)
986 		{
987 			return null;
988 		}
989 		
990 		return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true);
991 	}
992 
993 	/**
994 	 * Performs a query on the given element.
995 	 *
996 	 * For elements that don't implement a query handler, this function
997 	 * forwards the query to a random srcpad or to the peer of a
998 	 * random linked sinkpad of this element.
999 	 *
1000 	 * Please note that some queries might need a running pipeline to work.
1001 	 *
1002 	 * Params:
1003 	 *     query = the #GstQuery.
1004 	 *
1005 	 * Return: %TRUE if the query could be performed.
1006 	 *
1007 	 *     MT safe.
1008 	 */
1009 	public bool query(Query query)
1010 	{
1011 		return gst_element_query(gstElement, (query is null) ? null : query.getQueryStruct()) != 0;
1012 	}
1013 
1014 	/**
1015 	 * Queries an element to convert @src_val in @src_format to @dest_format.
1016 	 *
1017 	 * Params:
1018 	 *     srcFormat = a #GstFormat to convert from.
1019 	 *     srcVal = a value to convert.
1020 	 *     destFormat = the #GstFormat to convert to.
1021 	 *     destVal = a pointer to the result.
1022 	 *
1023 	 * Return: %TRUE if the query could be performed.
1024 	 */
1025 	public bool queryConvert(GstFormat srcFormat, long srcVal, GstFormat destFormat, out long destVal)
1026 	{
1027 		return gst_element_query_convert(gstElement, srcFormat, srcVal, destFormat, &destVal) != 0;
1028 	}
1029 
1030 	/**
1031 	 * Queries an element (usually top-level pipeline or playbin element) for the
1032 	 * total stream duration in nanoseconds. This query will only work once the
1033 	 * pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application
1034 	 * will receive an ASYNC_DONE message on the pipeline bus when that is the case.
1035 	 *
1036 	 * If the duration changes for some reason, you will get a DURATION_CHANGED
1037 	 * message on the pipeline bus, in which case you should re-query the duration
1038 	 * using this function.
1039 	 *
1040 	 * Params:
1041 	 *     format = the #GstFormat requested
1042 	 *     duration = A location in which to store the total duration, or %NULL.
1043 	 *
1044 	 * Return: %TRUE if the query could be performed.
1045 	 */
1046 	public bool queryDuration(GstFormat format, out long duration)
1047 	{
1048 		return gst_element_query_duration(gstElement, format, &duration) != 0;
1049 	}
1050 
1051 	/**
1052 	 * Queries an element (usually top-level pipeline or playbin element) for the
1053 	 * stream position in nanoseconds. This will be a value between 0 and the
1054 	 * stream duration (if the stream duration is known). This query will usually
1055 	 * only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING
1056 	 * state). The application will receive an ASYNC_DONE message on the pipeline
1057 	 * bus when that is the case.
1058 	 *
1059 	 * If one repeatedly calls this function one can also create a query and reuse
1060 	 * it in gst_element_query().
1061 	 *
1062 	 * Params:
1063 	 *     format = the #GstFormat requested
1064 	 *     cur = a location in which to store the current
1065 	 *         position, or %NULL.
1066 	 *
1067 	 * Return: %TRUE if the query could be performed.
1068 	 */
1069 	public bool queryPosition(GstFormat format, out long cur)
1070 	{
1071 		return gst_element_query_position(gstElement, format, &cur) != 0;
1072 	}
1073 
1074 	/**
1075 	 * Makes the element free the previously requested pad as obtained
1076 	 * with gst_element_request_pad().
1077 	 *
1078 	 * This does not unref the pad. If the pad was created by using
1079 	 * gst_element_request_pad(), gst_element_release_request_pad() needs to be
1080 	 * followed by gst_object_unref() to free the @pad.
1081 	 *
1082 	 * MT safe.
1083 	 *
1084 	 * Params:
1085 	 *     pad = the #GstPad to release.
1086 	 */
1087 	public void releaseRequestPad(Pad pad)
1088 	{
1089 		gst_element_release_request_pad(gstElement, (pad is null) ? null : pad.getPadStruct());
1090 	}
1091 
1092 	/**
1093 	 * Removes @pad from @element. @pad will be destroyed if it has not been
1094 	 * referenced elsewhere using gst_object_unparent().
1095 	 *
1096 	 * This function is used by plugin developers and should not be used
1097 	 * by applications. Pads that were dynamically requested from elements
1098 	 * with gst_element_request_pad() should be released with the
1099 	 * gst_element_release_request_pad() function instead.
1100 	 *
1101 	 * Pads are not automatically deactivated so elements should perform the needed
1102 	 * steps to deactivate the pad in case this pad is removed in the PAUSED or
1103 	 * PLAYING state. See gst_pad_set_active() for more information about
1104 	 * deactivating pads.
1105 	 *
1106 	 * The pad and the element should be unlocked when calling this function.
1107 	 *
1108 	 * This function will emit the #GstElement::pad-removed signal on the element.
1109 	 *
1110 	 * Params:
1111 	 *     pad = the #GstPad to remove from the element.
1112 	 *
1113 	 * Return: %TRUE if the pad could be removed. Can return %FALSE if the
1114 	 *     pad does not belong to the provided element.
1115 	 *
1116 	 *     MT safe.
1117 	 */
1118 	public bool removePad(Pad pad)
1119 	{
1120 		return gst_element_remove_pad(gstElement, (pad is null) ? null : pad.getPadStruct()) != 0;
1121 	}
1122 
1123 	/**
1124 	 * Retrieves a request pad from the element according to the provided template.
1125 	 * Pad templates can be looked up using
1126 	 * gst_element_factory_get_static_pad_templates().
1127 	 *
1128 	 * The pad should be released with gst_element_release_request_pad().
1129 	 *
1130 	 * Params:
1131 	 *     templ = a #GstPadTemplate of which we want a pad of.
1132 	 *     name = the name of the request #GstPad
1133 	 *         to retrieve. Can be %NULL.
1134 	 *     caps = the caps of the pad we want to
1135 	 *         request. Can be %NULL.
1136 	 *
1137 	 * Return: requested #GstPad if found,
1138 	 *     otherwise %NULL.  Release after usage.
1139 	 */
1140 	public Pad requestPad(PadTemplate templ, string name, Caps caps)
1141 	{
1142 		auto p = gst_element_request_pad(gstElement, (templ is null) ? null : templ.getPadTemplateStruct(), Str.toStringz(name), (caps is null) ? null : caps.getCapsStruct());
1143 		
1144 		if(p is null)
1145 		{
1146 			return null;
1147 		}
1148 		
1149 		return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
1150 	}
1151 
1152 	/**
1153 	 * Sends a seek event to an element. See gst_event_new_seek() for the details of
1154 	 * the parameters. The seek event is sent to the element using
1155 	 * gst_element_send_event().
1156 	 *
1157 	 * MT safe.
1158 	 *
1159 	 * Params:
1160 	 *     rate = The new playback rate
1161 	 *     format = The format of the seek values
1162 	 *     flags = The optional seek flags.
1163 	 *     startType = The type and flags for the new start position
1164 	 *     start = The value of the new start position
1165 	 *     stopType = The type and flags for the new stop position
1166 	 *     stop = The value of the new stop position
1167 	 *
1168 	 * Return: %TRUE if the event was handled. Flushing seeks will trigger a
1169 	 *     preroll, which will emit %GST_MESSAGE_ASYNC_DONE.
1170 	 */
1171 	public bool seek(double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop)
1172 	{
1173 		return gst_element_seek(gstElement, rate, format, flags, startType, start, stopType, stop) != 0;
1174 	}
1175 
1176 	/**
1177 	 * Simple API to perform a seek on the given element, meaning it just seeks
1178 	 * to the given position relative to the start of the stream. For more complex
1179 	 * operations like segment seeks (e.g. for looping) or changing the playback
1180 	 * rate or seeking relative to the last configured playback segment you should
1181 	 * use gst_element_seek().
1182 	 *
1183 	 * In a completely prerolled PAUSED or PLAYING pipeline, seeking is always
1184 	 * guaranteed to return %TRUE on a seekable media type or %FALSE when the media
1185 	 * type is certainly not seekable (such as a live stream).
1186 	 *
1187 	 * Some elements allow for seeking in the READY state, in this
1188 	 * case they will store the seek event and execute it when they are put to
1189 	 * PAUSED. If the element supports seek in READY, it will always return %TRUE when
1190 	 * it receives the event in the READY state.
1191 	 *
1192 	 * Params:
1193 	 *     format = a #GstFormat to execute the seek in, such as #GST_FORMAT_TIME
1194 	 *     seekFlags = seek options; playback applications will usually want to use
1195 	 *         GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here
1196 	 *     seekPos = position to seek to (relative to the start); if you are doing
1197 	 *         a seek in #GST_FORMAT_TIME this value is in nanoseconds -
1198 	 *         multiply with #GST_SECOND to convert seconds to nanoseconds or
1199 	 *         with #GST_MSECOND to convert milliseconds to nanoseconds.
1200 	 *
1201 	 * Return: %TRUE if the seek operation succeeded. Flushing seeks will trigger a
1202 	 *     preroll, which will emit %GST_MESSAGE_ASYNC_DONE.
1203 	 */
1204 	public bool seekSimple(GstFormat format, GstSeekFlags seekFlags, long seekPos)
1205 	{
1206 		return gst_element_seek_simple(gstElement, format, seekFlags, seekPos) != 0;
1207 	}
1208 
1209 	/**
1210 	 * Sends an event to an element. If the element doesn't implement an
1211 	 * event handler, the event will be pushed on a random linked sink pad for
1212 	 * downstream events or a random linked source pad for upstream events.
1213 	 *
1214 	 * This function takes ownership of the provided event so you should
1215 	 * gst_event_ref() it if you want to reuse the event after this call.
1216 	 *
1217 	 * MT safe.
1218 	 *
1219 	 * Params:
1220 	 *     event = the #GstEvent to send to the element.
1221 	 *
1222 	 * Return: %TRUE if the event was handled. Events that trigger a preroll (such
1223 	 *     as flushing seeks and steps) will emit %GST_MESSAGE_ASYNC_DONE.
1224 	 */
1225 	public bool sendEvent(Event event)
1226 	{
1227 		return gst_element_send_event(gstElement, (event is null) ? null : event.getEventStruct()) != 0;
1228 	}
1229 
1230 	/**
1231 	 * Set the base time of an element. See gst_element_get_base_time().
1232 	 *
1233 	 * MT safe.
1234 	 *
1235 	 * Params:
1236 	 *     time = the base time to set.
1237 	 */
1238 	public void setBaseTime(GstClockTime time)
1239 	{
1240 		gst_element_set_base_time(gstElement, time);
1241 	}
1242 
1243 	/**
1244 	 * Sets the bus of the element. Increases the refcount on the bus.
1245 	 * For internal use only, unless you're testing elements.
1246 	 *
1247 	 * MT safe.
1248 	 *
1249 	 * Params:
1250 	 *     bus = the #GstBus to set.
1251 	 */
1252 	public void setBus(Bus bus)
1253 	{
1254 		gst_element_set_bus(gstElement, (bus is null) ? null : bus.getBusStruct());
1255 	}
1256 
1257 	/**
1258 	 * Sets the clock for the element. This function increases the
1259 	 * refcount on the clock. Any previously set clock on the object
1260 	 * is unreffed.
1261 	 *
1262 	 * Params:
1263 	 *     clock = the #GstClock to set for the element.
1264 	 *
1265 	 * Return: %TRUE if the element accepted the clock. An element can refuse a
1266 	 *     clock when it, for example, is not able to slave its internal clock to the
1267 	 *     @clock or when it requires a specific clock to operate.
1268 	 *
1269 	 *     MT safe.
1270 	 */
1271 	public bool setClock(Clock clock)
1272 	{
1273 		return gst_element_set_clock(gstElement, (clock is null) ? null : clock.getClockStruct()) != 0;
1274 	}
1275 
1276 	/**
1277 	 * Sets the context of the element. Increases the refcount of the context.
1278 	 *
1279 	 * MT safe.
1280 	 *
1281 	 * Params:
1282 	 *     context = the #GstContext to set.
1283 	 */
1284 	public void setContext(Context context)
1285 	{
1286 		gst_element_set_context(gstElement, (context is null) ? null : context.getContextStruct());
1287 	}
1288 
1289 	/**
1290 	 * Locks the state of an element, so state changes of the parent don't affect
1291 	 * this element anymore.
1292 	 *
1293 	 * MT safe.
1294 	 *
1295 	 * Params:
1296 	 *     lockedState = %TRUE to lock the element's state
1297 	 *
1298 	 * Return: %TRUE if the state was changed, %FALSE if bad parameters were given
1299 	 *     or the elements state-locking needed no change.
1300 	 */
1301 	public bool setLockedState(bool lockedState)
1302 	{
1303 		return gst_element_set_locked_state(gstElement, lockedState) != 0;
1304 	}
1305 
1306 	/**
1307 	 * Set the start time of an element. The start time of the element is the
1308 	 * running time of the element when it last went to the PAUSED state. In READY
1309 	 * or after a flushing seek, it is set to 0.
1310 	 *
1311 	 * Toplevel elements like #GstPipeline will manage the start_time and
1312 	 * base_time on its children. Setting the start_time to #GST_CLOCK_TIME_NONE
1313 	 * on such a toplevel element will disable the distribution of the base_time to
1314 	 * the children and can be useful if the application manages the base_time
1315 	 * itself, for example if you want to synchronize capture from multiple
1316 	 * pipelines, and you can also ensure that the pipelines have the same clock.
1317 	 *
1318 	 * MT safe.
1319 	 *
1320 	 * Params:
1321 	 *     time = the base time to set.
1322 	 */
1323 	public void setStartTime(GstClockTime time)
1324 	{
1325 		gst_element_set_start_time(gstElement, time);
1326 	}
1327 
1328 	/**
1329 	 * Sets the state of the element. This function will try to set the
1330 	 * requested state by going through all the intermediary states and calling
1331 	 * the class's state change function for each.
1332 	 *
1333 	 * This function can return #GST_STATE_CHANGE_ASYNC, in which case the
1334 	 * element will perform the remainder of the state change asynchronously in
1335 	 * another thread.
1336 	 * An application can use gst_element_get_state() to wait for the completion
1337 	 * of the state change or it can wait for a %GST_MESSAGE_ASYNC_DONE or
1338 	 * %GST_MESSAGE_STATE_CHANGED on the bus.
1339 	 *
1340 	 * State changes to %GST_STATE_READY or %GST_STATE_NULL never return
1341 	 * #GST_STATE_CHANGE_ASYNC.
1342 	 *
1343 	 * Params:
1344 	 *     state = the element's new #GstState.
1345 	 *
1346 	 * Return: Result of the state change using #GstStateChangeReturn.
1347 	 *
1348 	 *     MT safe.
1349 	 */
1350 	public GstStateChangeReturn setState(GstState state)
1351 	{
1352 		return gst_element_set_state(gstElement, state);
1353 	}
1354 
1355 	/**
1356 	 * Tries to change the state of the element to the same as its parent.
1357 	 * If this function returns %FALSE, the state of element is undefined.
1358 	 *
1359 	 * Return: %TRUE, if the element's state could be synced to the parent's state.
1360 	 *
1361 	 *     MT safe.
1362 	 */
1363 	public bool syncStateWithParent()
1364 	{
1365 		return gst_element_sync_state_with_parent(gstElement) != 0;
1366 	}
1367 
1368 	/**
1369 	 * Unlinks all source pads of the source element with all sink pads
1370 	 * of the sink element to which they are linked.
1371 	 *
1372 	 * If the link has been made using gst_element_link(), it could have created an
1373 	 * requestpad, which has to be released using gst_element_release_request_pad().
1374 	 *
1375 	 * Params:
1376 	 *     dest = the sink #GstElement to unlink.
1377 	 */
1378 	public void unlink(Element dest)
1379 	{
1380 		gst_element_unlink(gstElement, (dest is null) ? null : dest.getElementStruct());
1381 	}
1382 
1383 	/**
1384 	 * Unlinks the two named pads of the source and destination elements.
1385 	 *
1386 	 * This is a convenience function for gst_pad_unlink().
1387 	 *
1388 	 * Params:
1389 	 *     srcpadname = the name of the #GstPad in source element.
1390 	 *     dest = a #GstElement containing the destination pad.
1391 	 *     destpadname = the name of the #GstPad in destination element.
1392 	 */
1393 	public void unlinkPads(string srcpadname, Element dest, string destpadname)
1394 	{
1395 		gst_element_unlink_pads(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname));
1396 	}
1397 
1398 	int[string] connectedSignals;
1399 
1400 	void delegate(Element)[] onNoMorePadsListeners;
1401 	/**
1402 	 * This signals that the element will not generate more dynamic pads.
1403 	 * Note that this signal will usually be emitted from the context of
1404 	 * the streaming thread.
1405 	 */
1406 	void addOnNoMorePads(void delegate(Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1407 	{
1408 		if ( "no-more-pads" !in connectedSignals )
1409 		{
1410 			Signals.connectData(
1411 				this,
1412 				"no-more-pads",
1413 				cast(GCallback)&callBackNoMorePads,
1414 				cast(void*)this,
1415 				null,
1416 				connectFlags);
1417 			connectedSignals["no-more-pads"] = 1;
1418 		}
1419 		onNoMorePadsListeners ~= dlg;
1420 	}
1421 	extern(C) static void callBackNoMorePads(GstElement* elementStruct, Element _element)
1422 	{
1423 		foreach ( void delegate(Element) dlg; _element.onNoMorePadsListeners )
1424 		{
1425 			dlg(_element);
1426 		}
1427 	}
1428 
1429 	void delegate(Pad, Element)[] onPadAddedListeners;
1430 	/**
1431 	 * a new #GstPad has been added to the element. Note that this signal will
1432 	 * usually be emitted from the context of the streaming thread. Also keep in
1433 	 * mind that if you add new elements to the pipeline in the signal handler
1434 	 * you will need to set them to the desired target state with
1435 	 * gst_element_set_state() or gst_element_sync_state_with_parent().
1436 	 *
1437 	 * Params:
1438 	 *     newPad = the pad that has been added
1439 	 */
1440 	void addOnPadAdded(void delegate(Pad, Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1441 	{
1442 		if ( "pad-added" !in connectedSignals )
1443 		{
1444 			Signals.connectData(
1445 				this,
1446 				"pad-added",
1447 				cast(GCallback)&callBackPadAdded,
1448 				cast(void*)this,
1449 				null,
1450 				connectFlags);
1451 			connectedSignals["pad-added"] = 1;
1452 		}
1453 		onPadAddedListeners ~= dlg;
1454 	}
1455 	extern(C) static void callBackPadAdded(GstElement* elementStruct, GstPad* newPad, Element _element)
1456 	{
1457 		foreach ( void delegate(Pad, Element) dlg; _element.onPadAddedListeners )
1458 		{
1459 			dlg(ObjectG.getDObject!(Pad)(newPad), _element);
1460 		}
1461 	}
1462 
1463 	void delegate(Pad, Element)[] onPadRemovedListeners;
1464 	/**
1465 	 * a #GstPad has been removed from the element
1466 	 *
1467 	 * Params:
1468 	 *     oldPad = the pad that has been removed
1469 	 */
1470 	void addOnPadRemoved(void delegate(Pad, Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1471 	{
1472 		if ( "pad-removed" !in connectedSignals )
1473 		{
1474 			Signals.connectData(
1475 				this,
1476 				"pad-removed",
1477 				cast(GCallback)&callBackPadRemoved,
1478 				cast(void*)this,
1479 				null,
1480 				connectFlags);
1481 			connectedSignals["pad-removed"] = 1;
1482 		}
1483 		onPadRemovedListeners ~= dlg;
1484 	}
1485 	extern(C) static void callBackPadRemoved(GstElement* elementStruct, GstPad* oldPad, Element _element)
1486 	{
1487 		foreach ( void delegate(Pad, Element) dlg; _element.onPadRemovedListeners )
1488 		{
1489 			dlg(ObjectG.getDObject!(Pad)(oldPad), _element);
1490 		}
1491 	}
1492 }