2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GstElement.html
50 * - gstreamer.Iterator
61 * - GstClock* -> Clock
62 * - GstElement* -> Element
63 * - GstEvent* -> Event
64 * - GstIndex* -> Index
65 * - GstIterator* -> Iterator
66 * - GstMessage* -> Message
68 * - GstQuery* -> Query
69 * - GstTagList* -> TagList
74 module gstreamer
.Element
;
80 import tango
.io
.Stdout
; // use the tango loging?
84 private import gstreamerc
.gstreamertypes
;
86 private import gstreamerc
.gstreamer
;
89 private import glib
.Str
;
90 private import gtkc
.gobject
;
91 private import gstreamer
.Pad
;
92 private import gstreamer
.Clock
;
93 private import gstreamer
.Caps
;
94 private import gstreamer
.Iterator
;
95 private import gstreamer
.Index
;
96 private import gstreamer
.TagList
;
97 private import gstreamer
.Message
;
98 private import gstreamer
.Query
;
99 private import gstreamer
.Event
;
100 private import gstreamer
.Bus
;
101 private import gstreamer
.Buffer
;
108 * GstElement is the abstract base class needed to construct an element that
109 * can be used in a GStreamer pipeline. Please refer to the plugin writers
110 * guide for more information on creating GstElement subclasses.
111 * The name of a GstElement can be get with gst_element_get_name() and set with
112 * gst_element_set_name(). For speed, GST_ELEMENT_NAME() can be used in the
113 * core when using the appropriate locking. Do not use this in plug-ins or
114 * applications in order to retain ABI compatibility.
115 * All elements have pads (of the type GstPad). These pads link to pads on
116 * other elements. GstBuffer flow between these linked pads.
117 * A GstElement has a GList of GstPad structures for all their input (or sink)
118 * and output (or source) pads.
119 * Core and plug-in writers can add and remove pads with gst_element_add_pad()
120 * and gst_element_remove_pad().
121 * A pad of an element can be retrieved by name with gst_element_get_pad().
122 * An iterator of all pads can be retrieved with gst_element_iterate_pads().
123 * Elements can be linked through their pads.
124 * If the link is straightforward, use the gst_element_link()
125 * convenience function to link two elements, or gst_element_link_many()
126 * for more elements in a row.
127 * Use gst_element_link_filtered() to link two elements constrained by
128 * a specified set of GstCaps.
129 * For finer control, use gst_element_link_pads() and
130 * gst_element_link_pads_filtered() to specify the pads to link on
131 * each element by name.
132 * Each element has a state (see GstState). You can get and set the state
133 * of an element with gst_element_get_state() and gst_element_set_state().
134 * To get a string representation of a GstState, use
135 * gst_element_state_get_name().
136 * You can get and set a GstClock on an element using gst_element_get_clock()
137 * and gst_element_set_clock().
138 * Some elements can provide a clock for the pipeline if
139 * gst_element_provides_clock() returns TRUE. With the
140 * gst_element_provide_clock() method one can retrieve the clock provided by
142 * Not all elements require a clock to operate correctly. If
143 * gst_element_requires_clock() returns TRUE, a clock should be set on the
144 * element with gst_element_set_clock().
145 * Note that clock slection and distribution is normally handled by the
146 * toplevel GstPipeline so the clock functions are only to be used in very
147 * specific situations.
148 * Last reviewed on 2006-03-12 (0.10.5)
150 private import gstreamer
.ObjectGst
;
151 public class Element
: ObjectGst
154 /** the main Gtk struct */
155 protected GstElement
* gstElement
;
158 public GstElement
* getElementStruct()
164 /** the main Gtk struct as a void* */
165 protected void* getStruct()
167 return cast(void*)gstElement
;
171 * Sets our main struct and passes it to the parent class
173 public this (GstElement
* gstElement
)
177 if ( gstElement is null )
182 Stdout("struct gstElement is null on constructor").newline;
186 printf("struct gstElement is null on constructor");
193 assert(gstElement !is null, "struct gstElement is null on constructor");
195 super(cast(GstObject
*)gstElement
);
196 this.gstElement
= gstElement
;
200 * Queries an element for the stream position.
201 * This is a convenience function for gstreamerD.
203 * The current position in nanoseconds - GstFormat.TIME.
205 public long queryPosition()
207 GstFormat form
= GstFormat
.TIME
;
209 queryPosition( &form
, &cur_pos
);
214 * Queries an element for the stream duration.
215 * This is a convenience function for gstreamerD.
217 * The duration in nanoseconds - GstFormat.TIME.
219 public long queryDuration()
221 GstFormat form
= GstFormat
.TIME
;
223 queryDuration( &form
, &cur_dur
);
228 * This set's the filename for a filesrc element.
230 public void location( char[] set
)
232 //g_object_set( G_OBJECT(getElementStruct()), "location", set, NULL);
233 setProperty("location", set
);
237 * Set the caps property of an Element.
241 g_object_set( getElementStruct(), Str
.toStringz("caps"), cp
.getCapsStruct(), null );
245 * For your convenience in gstreamerD: you can seek to the
246 * position of the pipeline measured in time_nanoseconds.
248 public int seek( ulong time_nanoseconds
) //gint64
250 return seek( 1.0, GstFormat
.TIME
, GstSeekFlags
.FLUSH
,
251 GstSeekType
.SET
, time_nanoseconds
,
252 GstSeekType
.NONE
, GST_CLOCK_TIME_NONE
);
256 * Get's all the pads from an element in a Pad[]. FIXME: This a hackish mess.
260 Pad
[] result
= new Pad
[0];
262 Iterator iter
= iteratePads();
263 GstPad
* obu_c
= null;
264 iter
.next( cast(void**) &obu_c
);
265 while( obu_c
!is null )
267 Pad tmpobu
= new Pad( obu_c
);
268 //writefln( "iterating Padname: ", tmpobu.getName() );
269 result
.length
= result
.length
+ 1;
270 result
[result
.length
-1] = tmpobu
;
273 iter
.next( cast(void**) &obu_c
);
275 //writefln("no more pads.");
279 //HANDEDIT: This is a way to add disconnectOnPadAdded
280 //There still doesn't seem to be a way to put it
281 //there automatically...
283 protected uint padAddedHandlerId
;
284 void delegate(Pad
, Element
)[] onPadAddedListeners
;
285 void addOnPadAdded(void delegate(Pad
, Element
) dlg
)
287 if ( !("pad-added" in connectedSignals
) )
289 padAddedHandlerId
= Signals
.connectData(
292 cast(GCallback
)&callBackPadAdded
,
295 cast(ConnectFlags
)0);
296 connectedSignals
["pad-added"] = 1;
298 onPadAddedListeners
~= dlg
;
300 extern(C
) static void callBackPadAdded(GstElement
* gstelementStruct
, GObject
* newPad
, Element element
)
302 bool consumed
= false;
304 foreach ( void delegate(Pad
, Element
) dlg
; element
.onPadAddedListeners
)
306 dlg(new Pad(newPad
), element
);
311 void disconnectOnPadAdded()
313 if( "pad-added" in connectedSignals
)
315 Signals
.handlerDisconnect( getStruct(), padAddedHandlerId
);
316 padAddedHandlerId
= 0;
317 connectedSignals
["pad-added"] = 0;
318 onPadAddedListeners
= null;
322 /* gst-inspect fakesink sanoo:
323 "handoff" : void user_function (GstElement* object,
327 "preroll-handoff" : void user_function (GstElement* object,
330 gpointer user_data);*/
333 protected uint handOffHandlerId
;
334 void delegate(Element
, Buffer
, Pad
)[] onHandOffListeners
;
335 //Object[][] onHandOffUserData;
336 //This way only one userdata ob, per all the listeners...Booh.
337 //Object[] onHandOffUserData;
338 void addOnHandOff(void delegate(Element
, Buffer
, Pad
) dlg
)
342 if ( !("handoff" in connectedSignals
) )
345 //onHandOffUserData ~= this;
346 //if( userdata !is null )
347 // onHandOffUserData ~= userdata;
349 handOffHandlerId
= Signals
.connectData(
352 cast(GCallback
)&callBackHandOff
,
356 cast(ConnectFlags
)0);
357 connectedSignals
["handoff"] = 1;
359 onHandOffListeners
~= dlg
;
361 extern(C
) static void callBackHandOff(GstElement
* gstelementStruct
, GstBuffer
* newBuffer
, GObject
* newPad
, Element element
)
363 bool consumed
= false;
365 //Object[] ob_array = cast(Object[]) userdata_array;
366 //Object[] ob_array = userdata_array;
367 //Element element = cast(Element)ob_array[0];
369 foreach ( void delegate(Element
, Buffer
, Pad
) dlg
; element
.onHandOffListeners
)
371 dlg(element
, new Buffer(newBuffer
), new Pad(newPad
));
376 void disconnectOnHandOff()
378 if( "handoff" in connectedSignals
)
380 Signals
.handlerDisconnect( getStruct(), handOffHandlerId
);
381 handOffHandlerId
= 0;
382 connectedSignals
["handoff"] = 0;
383 onHandOffListeners
= null;
387 protected uint prerollHandOffHandlerId
;
388 void delegate(Element
, Buffer
, Pad
)[] onPrerollHandOffListeners
;
389 //Object[][] onPrerollHandOffUserData;
390 //This way only one userdata ob, per all the listeners...Booh.
391 //Object[] onPrerollHandOffUserData;
392 void addOnPrerollHandOff(void delegate(Element
, Buffer
, Pad
) dlg
)
396 if ( !("preroll-handoff" in connectedSignals
) )
399 //onPrerollHandOffUserData ~= this;
400 //if( userdata !is null )
401 // onPrerollHandOffUserData ~= userdata;
403 prerollHandOffHandlerId
= Signals
.connectData(
406 cast(GCallback
)&callBackPrerollHandOff
,
408 //onPrerollHandOffUserData,
410 cast(ConnectFlags
)0);
411 connectedSignals
["preroll-handoff"] = 1;
413 onPrerollHandOffListeners
~= dlg
;
415 extern(C
) static void callBackPrerollHandOff(GstElement
* gstelementStruct
, GstBuffer
* newBuffer
, GObject
* newPad
, Element element
)
417 bool consumed
= false;
419 //Object[] ob_array = cast(Object[]) userdata_array;
420 //Element element = cast(Element)ob_array[0];
422 foreach ( void delegate(Element
, Buffer
, Pad
) dlg
; element
.onPrerollHandOffListeners
)
424 dlg(element
, new Buffer(newBuffer
), new Pad(newPad
));
429 void disconnectOnPrerollHandOff()
431 if( "preroll-handoff" in connectedSignals
)
433 Signals
.handlerDisconnect( getStruct(), prerollHandOffHandlerId
);
434 prerollHandOffHandlerId
= 0;
435 connectedSignals
["preroll-handoff"] = 0;
436 onPrerollHandOffListeners
= null;
443 // imports for the signal processing
444 private import gobject
.Signals
;
445 private import gtkc
.gdktypes
;
446 int[char[]] connectedSignals
;
448 void delegate(Element
)[] onNoMorePadsListeners
;
449 void addOnNoMorePads(void delegate(Element
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
451 if ( !("no-more-pads" in connectedSignals
) )
456 cast(GCallback
)&callBackNoMorePads
,
460 connectedSignals
["no-more-pads"] = 1;
462 onNoMorePadsListeners
~= dlg
;
464 extern(C
) static void callBackNoMorePads(GstElement
* gstelementStruct
, Element element
)
466 bool consumed
= false;
468 foreach ( void delegate(Element
) dlg
; element
.onNoMorePadsListeners
)
476 void delegate(Pad, Element)[] onPadAddedListeners;
477 void addOnPadAdded(void delegate(Pad, Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
479 if ( !("pad-added" in connectedSignals) )
484 cast(GCallback)&callBackPadAdded,
488 connectedSignals["pad-added"] = 1;
490 onPadAddedListeners ~= dlg;
492 extern(C) static void callBackPadAdded(GstElement* gstelementStruct, GObject* newPad, Element element)
494 bool consumed = false;
496 foreach ( void delegate(Pad, Element) dlg ; element.onPadAddedListeners )
498 dlg(new Pad(newPad), element);
504 void delegate(Pad
, Element
)[] onPadRemovedListeners
;
505 void addOnPadRemoved(void delegate(Pad
, Element
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
507 if ( !("pad-removed" in connectedSignals
) )
512 cast(GCallback
)&callBackPadRemoved
,
516 connectedSignals
["pad-removed"] = 1;
518 onPadRemovedListeners
~= dlg
;
520 extern(C
) static void callBackPadRemoved(GstElement
* gstelementStruct
, GObject
* oldPad
, Element element
)
522 bool consumed
= false;
524 foreach ( void delegate(Pad
, Element
) dlg
; element
.onPadRemovedListeners
)
526 dlg(new Pad(oldPad
), element
);
559 * Adds a padtemplate to an element class. This is mainly used in the _base_init
560 * functions of classes.
562 * the GstElementClass to add the pad template to.
564 * a GstPadTemplate to add to the element class.
566 public static void classAddPadTemplate(GstElementClass
* klass
, GstPadTemplate
* templ
)
568 // void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ);
569 gst_element_class_add_pad_template(klass
, templ
);
573 * Retrieves a padtemplate from element_class with the given name.
575 * If you use this function in the GInstanceInitFunc of an object class
576 * that has subclasses, make sure to pass the g_class parameter of the
577 * GInstanceInitFunc here.
579 * a GstElementClass to get the pad template of.
581 * the name of the GstPadTemplate to get.
583 * the GstPadTemplate with the given name, or NULL if none was found.
584 * No unreferencing is necessary.
586 public static GstPadTemplate
* classGetPadTemplate(GstElementClass
* elementClass
, char[] name
)
588 // GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name);
589 return gst_element_class_get_pad_template(elementClass
, Str
.toStringz(name
));
593 * Retrieves a list of the pad templates associated with element_class. The
594 * list must not be modified by the calling code.
596 * If you use this function in the GInstanceInitFunc of an object class
597 * that has subclasses, make sure to pass the g_class parameter of the
598 * GInstanceInitFunc here.
600 * a GstElementClass to get pad templates of.
602 * the GList of padtemplates.
604 public static GList
* classGetPadTemplateList(GstElementClass
* elementClass
)
606 // GList* gst_element_class_get_pad_template_list (GstElementClass *element_class);
607 return gst_element_class_get_pad_template_list(elementClass
);
611 * Adds a list of standardized properties with types to the klass.
612 * the id is for the property switch in your get_prop method, and
613 * the flags determine readability / writeability.
615 * the GstElementClass to add the properties to.
617 * the name of the first property.
618 * in a NULL terminated
620 * the id and flags of the first property, followed by
621 * further 'name', 'id', 'flags' triplets and terminated by NULL.
623 public static void classInstallStdProps(GstElementClass
* klass
, char[] firstName
, ... )
625 // void gst_element_class_install_std_props (GstElementClass *klass, const gchar *first_name, ...);
626 gst_element_class_install_std_props(klass
, Str
.toStringz(firstName
));
630 * Sets the detailed information for a GstElementClass.
632 * This function is for use in _base_init functions only.
633 * The details are copied.
635 * class to set details for
639 public static void classSetDetails(GstElementClass
* klass
, GstElementDetails
* details
)
641 // void gst_element_class_set_details (GstElementClass *klass, const GstElementDetails *details);
642 gst_element_class_set_details(klass
, details
);
646 * Adds a pad (link point) to element. pad's parent will be set to element;
647 * see gst_object_set_parent() for refcounting information.
648 * Pads are not automatically activated so elements should perform the needed
649 * steps to activate the pad in case this pad is added in the PAUSED or PLAYING
650 * state. See gst_pad_set_active() for more information about activating pads.
651 * The pad and the element should be unlocked when calling this function.
652 * This function will emit the GstElement::pad-added signal on the element.
654 * a GstElement to add the pad to.
656 * the GstPad to add to the element.
658 * TRUE if the pad could be added. This function can fail when
659 * a pad with the same name already existed or the pad already had another
663 public int addPad(Pad pad
)
665 // gboolean gst_element_add_pad (GstElement *element, GstPad *pad);
666 return gst_element_add_pad(gstElement
, (pad
is null) ?
null : pad
.getPadStruct());
670 * Retrieves a pad from element by name. Tries gst_element_get_static_pad()
671 * first, then gst_element_get_request_pad().
673 * Usage of this function is not recommended as it is unclear if the reference
674 * to the result pad should be released with gst_object_unref() in case of a static pad
675 * or gst_element_release_request_pad() in case of a request pad.
679 * the name of the pad to retrieve.
681 * the GstPad if found, otherwise NULL. Unref or Release after usage,
682 * depending on the type of the pad.
684 public Pad
getPad(char[] name
)
686 // GstPad* gst_element_get_pad (GstElement *element, const gchar *name);
687 return new Pad( gst_element_get_pad(gstElement
, Str
.toStringz(name
)) );
691 * Creates a pad for each pad template that is always available.
692 * This function is only useful during object intialization of
693 * subclasses of GstElement.
695 * a GstElement to create pads for
697 public void createAllPads()
699 // void gst_element_create_all_pads (GstElement *element);
700 gst_element_create_all_pads(gstElement
);
704 * Looks for an unlinked pad to which the given pad can link. It is not
705 * guaranteed that linking the pads will work, though it should work in most
708 * a GstElement in which the pad should be found.
710 * the GstPad to find a compatible one for.
712 * the GstCaps to use as a filter.
714 * the GstPad to which a link can be made, or NULL if one cannot be
717 public Pad
getCompatiblePad(Pad pad
, Caps caps
)
719 // GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad, const GstCaps *caps);
720 return new Pad( gst_element_get_compatible_pad(gstElement
, (pad
is null) ?
null : pad
.getPadStruct(), (caps
is null) ?
null : caps
.getCapsStruct()) );
724 * Retrieves a pad template from element that is compatible with compattempl.
725 * Pads from compatible templates can be linked together.
727 * a GstElement to get a compatible pad template for.
729 * the GstPadTemplate to find a compatible template for.
731 * a compatible GstPadTemplate, or NULL if none was found. No
732 * unreferencing is necessary.
734 public GstPadTemplate
* getCompatiblePadTemplate(GstPadTemplate
* compattempl
)
736 // GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
737 return gst_element_get_compatible_pad_template(gstElement
, compattempl
);
741 * Retrieves a pad from the element by name. This version only retrieves
742 * request pads. The pad should be released with
743 * gst_element_release_request_pad().
745 * a GstElement to find a request pad of.
747 * the name of the request GstPad to retrieve.
749 * requested GstPad if found, otherwise NULL. Release after usage.
751 public Pad
getRequestPad(char[] name
)
753 // GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name);
754 return new Pad( gst_element_get_request_pad(gstElement
, Str
.toStringz(name
)) );
758 * Retrieves a pad from element by name. This version only retrieves
759 * already-existing (i.e. 'static') pads.
761 * a GstElement to find a static pad of.
763 * the name of the static GstPad to retrieve.
765 * the requested GstPad if found, otherwise NULL. unref after
769 public Pad
getStaticPad(char[] name
)
771 // GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name);
772 return new Pad( gst_element_get_static_pad(gstElement
, Str
.toStringz(name
)) );
776 * Use this function to signal that the element does not expect any more pads
777 * to show up in the current pipeline. This function should be called whenever
778 * pads have been added by the element itself. Elements with GST_PAD_SOMETIMES
779 * pad templates use this in combination with autopluggers to figure out that
780 * the element is done initializing its pads.
781 * This function emits the GstElement::no-more-pads signal.
786 public void noMorePads()
788 // void gst_element_no_more_pads (GstElement *element);
789 gst_element_no_more_pads(gstElement
);
793 * Makes the element free the previously requested pad as obtained
794 * with gst_element_get_request_pad().
797 * a GstElement to release the request pad of.
799 * the GstPad to release.
801 public void releaseRequestPad(Pad pad
)
803 // void gst_element_release_request_pad (GstElement *element, GstPad *pad);
804 gst_element_release_request_pad(gstElement
, (pad
is null) ?
null : pad
.getPadStruct());
808 * Removes pad from element. pad will be destroyed if it has not been
809 * referenced elsewhere using gst_object_unparent().
810 * This function is used by plugin developers and should not be used
811 * by applications. Pads that were dynamically requested from elements
812 * with gst_element_get_request_pad() should be released with the
813 * gst_element_release_request_pad() function instead.
814 * Pads are not automatically deactivated so elements should perform the needed
815 * steps to deactivate the pad in case this pad is removed in the PAUSED or
816 * PLAYING state. See gst_pad_set_active() for more information about
818 * The pad and the element should be unlocked when calling this function.
819 * This function will emit the GstElement::pad-removed signal on the element.
821 * a GstElement to remove pad from.
823 * the GstPad to remove from the element.
825 * TRUE if the pad could be removed. Can return FALSE if the
826 * pad does not belong to the provided element.
829 public int removePad(Pad pad
)
831 // gboolean gst_element_remove_pad (GstElement *element, GstPad *pad);
832 return gst_element_remove_pad(gstElement
, (pad
is null) ?
null : pad
.getPadStruct());
836 * Retrieves an iterattor of element's pads. The iterator should
837 * be freed after usage.
839 * a GstElement to iterate pads of.
841 * the GstIterator of GstPad. Unref each pad after use.
844 public Iterator
iteratePads()
846 // GstIterator* gst_element_iterate_pads (GstElement *element);
847 return new Iterator( gst_element_iterate_pads(gstElement
) );
851 * Retrieves an iterator of element's sink pads.
855 * the GstIterator of GstPad. Unref each pad after use.
858 public Iterator
iterateSinkPads()
860 // GstIterator* gst_element_iterate_sink_pads (GstElement *element);
861 return new Iterator( gst_element_iterate_sink_pads(gstElement
) );
865 * Retrieves an iterator of element's source pads.
869 * the GstIterator of GstPad. Unref each pad after use.
872 public Iterator
iterateSrcPads()
874 // GstIterator* gst_element_iterate_src_pads (GstElement *element);
875 return new Iterator( gst_element_iterate_src_pads(gstElement
) );
879 * Links src to dest. The link must be from source to
880 * destination; the other direction will not be tried. The function looks for
881 * existing pads that aren't linked yet. It will request new pads if necessary.
882 * If multiple links are possible, only one is established.
883 * Make sure you have added your elements to a bin or pipeline with
884 * gst_bin_add() before trying to link them.
886 * a GstElement containing the source pad.
888 * the GstElement containing the destination pad.
890 * TRUE if the elements could be linked, FALSE otherwise.
892 public int link(Element dest
)
894 // gboolean gst_element_link (GstElement *src, GstElement *dest);
895 return gst_element_link(gstElement
, (dest
is null) ?
null : dest
.getElementStruct());
899 * Unlinks all source pads of the source element with all sink pads
900 * of the sink element to which they are linked.
902 * the source GstElement to unlink.
904 * the sink GstElement to unlink.
906 public void unlink(Element dest
)
908 // void gst_element_unlink (GstElement *src, GstElement *dest);
909 gst_element_unlink(gstElement
, (dest
is null) ?
null : dest
.getElementStruct());
913 * Chain together a series of elements. Uses gst_element_link().
914 * Make sure you have added your elements to a bin or pipeline with
915 * gst_bin_add() before trying to link them.
917 * the first GstElement in the link chain.
919 * the second GstElement in the link chain.
921 * the NULL-terminated list of elements to link in order.
923 * TRUE on success, FALSE otherwise.
925 public int linkMany(Element element2
, ... )
927 // gboolean gst_element_link_many (GstElement *element_1, GstElement *element_2, ...);
928 return gst_element_link_many(gstElement
, (element2
is null) ?
null : element2
.getElementStruct());
932 * Unlinks a series of elements. Uses gst_element_unlink().
934 * the first GstElement in the link chain.
936 * the second GstElement in the link chain.
938 * the NULL-terminated list of elements to unlink in order.
940 public void unlinkMany(Element element2
, ... )
942 // void gst_element_unlink_many (GstElement *element_1, GstElement *element_2, ...);
943 gst_element_unlink_many(gstElement
, (element2
is null) ?
null : element2
.getElementStruct());
947 * Links the two named pads of the source and destination elements.
948 * Side effect is that if one of the pads has no parent, it becomes a
949 * child of the parent of the other element. If they have different
950 * parents, the link fails.
952 * a GstElement containing the source pad.
954 * the name of the GstPad in source element or NULL for any pad.
956 * the GstElement containing the destination pad.
958 * the name of the GstPad in destination element,
959 * or NULL for any pad.
961 * TRUE if the pads could be linked, FALSE otherwise.
963 public int linkPads(char[] srcpadname
, Element dest
, char[] destpadname
)
965 // gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname, GstElement *dest, const gchar *destpadname);
966 return gst_element_link_pads(gstElement
, Str
.toStringz(srcpadname
), (dest
is null) ?
null : dest
.getElementStruct(), Str
.toStringz(destpadname
));
970 * Unlinks the two named pads of the source and destination elements.
972 * a GstElement containing the source pad.
974 * the name of the GstPad in source element.
976 * a GstElement containing the destination pad.
978 * the name of the GstPad in destination element.
980 public void unlinkPads(char[] srcpadname
, Element dest
, char[] destpadname
)
982 // void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname, GstElement *dest, const gchar *destpadname);
983 gst_element_unlink_pads(gstElement
, Str
.toStringz(srcpadname
), (dest
is null) ?
null : dest
.getElementStruct(), Str
.toStringz(destpadname
));
987 * Links the two named pads of the source and destination elements. Side effect
988 * is that if one of the pads has no parent, it becomes a child of the parent of
989 * the other element. If they have different parents, the link fails. If caps
990 * is not NULL, makes sure that the caps of the link is a subset of caps.
992 * a GstElement containing the source pad.
994 * the name of the GstPad in source element or NULL for any pad.
996 * the GstElement containing the destination pad.
998 * the name of the GstPad in destination element or NULL for any pad.
1000 * the GstCaps to filter the link, or NULL for no filter.
1002 * TRUE if the pads could be linked, FALSE otherwise.
1004 public int linkPadsFiltered(char[] srcpadname
, Element dest
, char[] destpadname
, Caps filter
)
1006 // gboolean gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, GstElement *dest, const gchar *destpadname, GstCaps *filter);
1007 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());
1011 * Links src to dest using the given caps as filtercaps.
1012 * The link must be from source to
1013 * destination; the other direction will not be tried. The function looks for
1014 * existing pads that aren't linked yet. It will request new pads if necessary.
1015 * If multiple links are possible, only one is established.
1016 * Make sure you have added your elements to a bin or pipeline with
1017 * gst_bin_add() before trying to link them.
1019 * a GstElement containing the source pad.
1021 * the GstElement containing the destination pad.
1023 * the GstCaps to filter the link, or NULL for no filter.
1025 * TRUE if the pads could be linked, FALSE otherwise.
1027 public int linkFiltered(Element dest
, Caps filter
)
1029 // gboolean gst_element_link_filtered (GstElement *src, GstElement *dest, GstCaps *filter);
1030 return gst_element_link_filtered(gstElement
, (dest
is null) ?
null : dest
.getElementStruct(), (filter
is null) ?
null : filter
.getCapsStruct());
1034 * Set the base time of an element. See gst_element_get_base_time().
1039 * the base time to set.
1041 public void setBaseTime(GstClockTime time
)
1043 // void gst_element_set_base_time (GstElement *element, GstClockTime time);
1044 gst_element_set_base_time(gstElement
, time
);
1048 * Returns the base time of the element. The base time is the
1049 * absolute time of the clock when this element was last put to
1050 * PLAYING. Subtracting the base time from the clock time gives
1051 * the stream time of the element.
1055 * the base time of the element.
1058 public GstClockTime
getBaseTime()
1060 // GstClockTime gst_element_get_base_time (GstElement *element);
1061 return gst_element_get_base_time(gstElement
);
1065 * Sets the bus of the element. Increases the refcount on the bus.
1066 * For internal use only, unless you're testing elements.
1069 * a GstElement to set the bus of.
1071 * the GstBus to set.
1073 public void setBus(Bus bus
)
1075 // void gst_element_set_bus (GstElement *element, GstBus *bus);
1076 gst_element_set_bus(gstElement
, (bus
is null) ?
null : bus
.getBusStruct());
1080 * Returns the bus of the element.
1082 * a GstElement to get the bus of.
1084 * the element's GstBus. unref after usage.
1089 // GstBus* gst_element_get_bus (GstElement *element);
1090 return new Bus( gst_element_get_bus(gstElement
) );
1094 * Retrieves the factory that was used to create this element.
1096 * a GstElement to request the element factory of.
1098 * the GstElementFactory used for creating this element.
1099 * no refcounting is needed.
1101 public GstElementFactory
* getFactory()
1103 // GstElementFactory* gst_element_get_factory (GstElement *element);
1104 return gst_element_get_factory(gstElement
);
1108 * Set index on the element. The refcount of the index
1109 * will be increased, any previously set index is unreffed.
1116 public void setIndex(Index index
)
1118 // void gst_element_set_index (GstElement *element, GstIndex *index);
1119 gst_element_set_index(gstElement
, (index
is null) ?
null : index
.getIndexStruct());
1123 * Gets the index from the element.
1127 * a GstIndex or NULL when no index was set on the
1128 * element. unref after usage.
1131 public Index
getIndex()
1133 // GstIndex* gst_element_get_index (GstElement *element);
1134 return new Index( gst_element_get_index(gstElement
) );
1138 * Queries if the element can be indexed.
1142 * TRUE if the element can be indexed.
1145 public int isIndexable()
1147 // gboolean gst_element_is_indexable (GstElement *element);
1148 return gst_element_is_indexable(gstElement
);
1156 * Query if the element requires a clock.
1158 * a GstElement to query
1160 * TRUE if the element requires a clock
1163 public int requiresClock()
1165 // gboolean gst_element_requires_clock (GstElement *element);
1166 return gst_element_requires_clock(gstElement
);
1170 * Sets the clock for the element. This function increases the
1171 * refcount on the clock. Any previously set clock on the object
1174 * a GstElement to set the clock for.
1176 * the GstClock to set for the element.
1178 * TRUE if the element accepted the clock. An element can refuse a
1179 * clock when it, for example, is not able to slave its internal clock to the
1180 * clock or when it requires a specific clock to operate.
1183 public int setClock(Clock clock
)
1185 // gboolean gst_element_set_clock (GstElement *element, GstClock *clock);
1186 return gst_element_set_clock(gstElement
, (clock
is null) ?
null : clock
.getClockStruct());
1190 * Gets the currently configured clock of the element. This is the clock as was
1191 * last set with gst_element_set_clock().
1193 * a GstElement to get the clock of.
1195 * the GstClock of the element. unref after usage.
1198 public Clock
getClock()
1200 // GstClock* gst_element_get_clock (GstElement *element);
1201 return new Clock( gst_element_get_clock(gstElement
) );
1205 * Query if the element provides a clock. A GstClock provided by an
1206 * element can be used as the global GstClock for the pipeline.
1207 * An element that can provide a clock is only required to do so in the PAUSED
1208 * state, this means when it is fully negotiated and has allocated the resources
1209 * to operate the clock.
1211 * a GstElement to query
1213 * TRUE if the element provides a clock
1216 public int providesClock()
1218 // gboolean gst_element_provides_clock (GstElement *element);
1219 return gst_element_provides_clock(gstElement
);
1223 * Get the clock provided by the given element.
1225 * An element is only required to provide a clock in the PAUSED
1226 * state. Some elements can provide a clock in other states.
1228 * a GstElement to query
1230 * the GstClock provided by the element or NULL
1231 * if no clock could be provided. Unref after usage.
1234 public Clock
provideClock()
1236 // GstClock* gst_element_provide_clock (GstElement *element);
1237 return new Clock( gst_element_provide_clock(gstElement
) );
1241 * Sets the state of the element. This function will try to set the
1242 * requested state by going through all the intermediary states and calling
1243 * the class's state change function for each.
1244 * This function can return GST_STATE_CHANGE_ASYNC, in which case the
1245 * element will perform the remainder of the state change asynchronously in
1247 * An application can use gst_element_get_state() to wait for the completion
1248 * of the state change or it can wait for a state change message on the bus.
1250 * a GstElement to change state of.
1252 * the element's new GstState.
1254 * Result of the state change using GstStateChangeReturn.
1257 public GstStateChangeReturn
setState(GstState state
)
1259 // GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state);
1260 return gst_element_set_state(gstElement
, state
);
1264 * Gets the state of the element.
1265 * For elements that performed an ASYNC state change, as reported by
1266 * gst_element_set_state(), this function will block up to the
1267 * specified timeout value for the state change to complete.
1268 * If the element completes the state change or goes into
1269 * an error, this function returns immediately with a return value of
1270 * GST_STATE_CHANGE_SUCCESS or GST_STATE_CHANGE_FAILURE respectively.
1271 * For elements that did not return GST_STATE_CHANGE_ASYNC, this function
1272 * returns the current and pending state immediately.
1273 * This function returns GST_STATE_CHANGE_NO_PREROLL if the element
1274 * successfully changed its state but is not able to provide data yet.
1275 * This mostly happens for live sources that only produce data in the PLAYING
1276 * state. While the state change return is equivalent to
1277 * GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that
1278 * some sink elements might not be able to complete their state change because
1279 * an element is not producing data to complete the preroll. When setting the
1280 * element to playing, the preroll will complete and playback will start.
1282 * a GstElement to get the state of.
1284 * a pointer to GstState to hold the state. Can be NULL.
1286 * a pointer to GstState to hold the pending state.
1289 * a GstClockTime to specify the timeout for an async
1290 * state change or GST_CLOCK_TIME_NONE for infinite timeout.
1292 * GST_STATE_CHANGE_SUCCESS if the element has no more pending state
1293 * and the last state change succeeded, GST_STATE_CHANGE_ASYNC if the
1294 * element is still performing a state change or
1295 * GST_STATE_CHANGE_FAILURE if the last state change failed.
1298 public GstStateChangeReturn
getState(GstState
* state
, GstState
* pending
, GstClockTime timeout
)
1300 // GstStateChangeReturn gst_element_get_state (GstElement *element, GstState *state, GstState *pending, GstClockTime timeout);
1301 return gst_element_get_state(gstElement
, state
, pending
, timeout
);
1305 * Locks the state of an element, so state changes of the parent don't affect
1306 * this element anymore.
1311 * TRUE to lock the element's state
1313 * TRUE if the state was changed, FALSE if bad parameters were given
1314 * or the elements state-locking needed no change.
1316 public int setLockedState(int lockedState
)
1318 // gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
1319 return gst_element_set_locked_state(gstElement
, lockedState
);
1323 * Checks if the state of an element is locked.
1324 * If the state of an element is locked, state changes of the parent don't
1325 * affect the element.
1326 * This way you can leave currently unused elements inside bins. Just lock their
1327 * state before changing the state from GST_STATE_NULL.
1332 * TRUE, if the element's state is locked.
1334 public int isLockedState()
1336 // gboolean gst_element_is_locked_state (GstElement *element);
1337 return gst_element_is_locked_state(gstElement
);
1341 * Abort the state change of the element. This function is used
1342 * by elements that do asynchronous state changes and find out
1343 * something is wrong.
1344 * This function should be called with the STATE_LOCK held.
1347 * a GstElement to abort the state of.
1349 public void abortState()
1351 // void gst_element_abort_state (GstElement *element);
1352 gst_element_abort_state(gstElement
);
1356 * Commit the state change of the element and proceed to the next
1357 * pending state if any. This function is used
1358 * by elements that do asynchronous state changes.
1359 * The core will normally call this method automatically when an
1360 * element returned GST_STATE_CHANGE_SUCCESS from the state change function.
1361 * If after calling this method the element still has not reached
1362 * the pending state, the next state change is performed.
1363 * This method is used internally and should normally not be called by plugins
1366 * a GstElement to continue the state change of.
1368 * The previous state return value
1370 * The result of the commit state change.
1373 public GstStateChangeReturn
continueState(GstStateChangeReturn
ret)
1375 // GstStateChangeReturn gst_element_continue_state (GstElement *element, GstStateChangeReturn ret);
1376 return gst_element_continue_state(gstElement
, ret);
1380 * Brings the element to the lost state. The current state of the
1381 * element is copied to the pending state so that any call to
1382 * gst_element_get_state() will return GST_STATE_CHANGE_ASYNC.
1383 * This is mostly used for elements that lost their preroll buffer
1384 * in the GST_STATE_PAUSED state after a flush, they become GST_STATE_PAUSED
1385 * again if a new preroll buffer is queued.
1386 * This function can only be called when the element is currently
1387 * not in error or an async state change.
1388 * This function is used internally and should normally not be called from
1389 * plugins or applications.
1392 * a GstElement the state is lost of
1394 public void lostState()
1396 // void gst_element_lost_state (GstElement *element);
1397 gst_element_lost_state(gstElement
);
1401 * Gets a string representing the given state.
1403 * a GstState to get the name of.
1405 * a string with the name of the state.
1407 public static char[] stateGetName(GstState state
)
1409 // const gchar* gst_element_state_get_name (GstState state);
1410 return Str
.toString(gst_element_state_get_name(state
) );
1414 * Gets a string representing the given state change result.
1416 * a GstStateChangeReturn to get the name of.
1418 * a string with the name of the state change result.
1420 public static char[] stateChangeReturnGetName(GstStateChangeReturn stateRet
)
1422 // const gchar* gst_element_state_change_return_get_name (GstStateChangeReturn state_ret);
1423 return Str
.toString(gst_element_state_change_return_get_name(stateRet
) );
1427 * Tries to change the state of the element to the same as its parent.
1428 * If this function returns FALSE, the state of element is undefined.
1432 * TRUE, if the element's state could be synced to the parent's state.
1435 public int syncStateWithParent()
1437 // gboolean gst_element_sync_state_with_parent (GstElement *element);
1438 return gst_element_sync_state_with_parent(gstElement
);
1442 * Posts a message to the bus that new tags were found, and pushes an event
1443 * to all sourcepads. Takes ownership of the list.
1444 * This is a utility method for elements. Applications should use the
1445 * GstTagSetter interface.
1447 * element for which we found the tags.
1451 public void foundTags(TagList list
)
1453 // void gst_element_found_tags (GstElement *element, GstTagList *list);
1454 gst_element_found_tags(gstElement
, (list
is null) ?
null : list
.getTagListStruct());
1458 * Posts a message to the bus that new tags were found and pushes the
1459 * tags as event. Takes ownership of the list.
1460 * This is a utility method for elements. Applications should use the
1461 * GstTagSetter interface.
1463 * element for which to post taglist to bus.
1465 * pad on which to push tag-event.
1467 * the taglist to post on the bus and create event from.
1469 public void foundTagsForPad(Pad pad
, TagList list
)
1471 // void gst_element_found_tags_for_pad (GstElement *element, GstPad *pad, GstTagList *list);
1472 gst_element_found_tags_for_pad(gstElement
, (pad
is null) ?
null : pad
.getPadStruct(), (list
is null) ?
null : list
.getTagListStruct());
1476 * Post an error, warning or info message on the bus from inside an element.
1477 * type must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or
1481 * a GstElement to send message from
1483 * the GstMessageType
1485 * the GStreamer GError domain this message belongs to
1487 * the GError code belonging to the domain
1489 * an allocated text string to be used as a replacement for the
1490 * default message connected to code, or NULL
1492 * an allocated debug message to be used as a replacement for the
1493 * default debugging information, or NULL
1495 * the source code file where the error was generated
1497 * the source code function where the error was generated
1499 * the source code line where the error was generated
1501 public void messageFull(GstMessageType type
, GQuark domain
, int code
, char[] text
, char[] dbug
, char[] file
, char[] funct
, int line
)
1503 // void gst_element_message_full (GstElement *element, GstMessageType type, GQuark domain, gint code, gchar *text, gchar *debug, const gchar *file, const gchar *function, gint line);
1504 gst_element_message_full(gstElement
, type
, domain
, code
, Str
.toStringz(text
), Str
.toStringz(dbug
), Str
.toStringz(file
), Str
.toStringz(funct
), line
);
1508 * Post a message on the element's GstBus. This function takes ownership of the
1509 * message; if you want to access the message after this call, you should add an
1510 * additional reference before calling.
1512 * a GstElement posting the message
1514 * a GstMessage to post
1516 * TRUE if the message was successfully posted. The function returns
1517 * FALSE if the element did not have a bus.
1520 public int postMessage(Message message
)
1522 // gboolean gst_element_post_message (GstElement *element, GstMessage *message);
1523 return gst_element_post_message(gstElement
, (message
is null) ?
null : message
.getMessageStruct());
1527 * Get an array of query types from the element.
1528 * If the element doesn't implement a query types function,
1529 * the query will be forwarded to the peer of a random linked sink pad.
1531 * a GstElement to query
1533 * An array of GstQueryType elements that should not
1534 * be freed or modified.
1537 public GstQueryType
* getQueryTypes()
1539 // const GstQueryType* gst_element_get_query_types (GstElement *element);
1540 return gst_element_get_query_types(gstElement
);
1544 * Performs a query on the given element.
1545 * For elements that don't implement a query handler, this function
1546 * forwards the query to a random srcpad or to the peer of a
1547 * random linked sinkpad of this element.
1549 * a GstElement to perform the query on.
1553 * TRUE if the query could be performed.
1556 public int query(Query query
)
1558 // gboolean gst_element_query (GstElement *element, GstQuery *query);
1559 return gst_element_query(gstElement
, (query
is null) ?
null : query
.getQueryStruct());
1563 * Queries an element to convert src_val in src_format to dest_format.
1565 * a GstElement to invoke the convert query on.
1567 * a GstFormat to convert from.
1569 * a value to convert.
1571 * a pointer to the GstFormat to convert to.
1573 * a pointer to the result.
1575 * TRUE if the query could be performed.
1577 public int queryConvert(GstFormat srcFormat
, long srcVal
, GstFormat
* destFormat
, long* destVal
)
1579 // gboolean gst_element_query_convert (GstElement *element, GstFormat src_format, gint64 src_val, GstFormat *dest_format, gint64 *dest_val);
1580 return gst_element_query_convert(gstElement
, srcFormat
, srcVal
, destFormat
, destVal
);
1584 * Queries an element for the stream position.
1586 * a GstElement to invoke the position query on.
1588 * a pointer to the GstFormat asked for.
1589 * On return contains the GstFormat used.
1591 * A location in which to store the current position, or NULL.
1593 * TRUE if the query could be performed.
1595 public int queryPosition(GstFormat
* format
, long* cur
)
1597 // gboolean gst_element_query_position (GstElement *element, GstFormat *format, gint64 *cur);
1598 return gst_element_query_position(gstElement
, format
, cur
);
1602 * Queries an element for the total stream duration.
1604 * a GstElement to invoke the duration query on.
1606 * a pointer to the GstFormat asked for.
1607 * On return contains the GstFormat used.
1609 * A location in which to store the total duration, or NULL.
1611 * TRUE if the query could be performed.
1613 public int queryDuration(GstFormat
* format
, long* duration
)
1615 // gboolean gst_element_query_duration (GstElement *element, GstFormat *format, gint64 *duration);
1616 return gst_element_query_duration(gstElement
, format
, duration
);
1620 * Sends an event to an element. If the element doesn't implement an
1621 * event handler, the event will be pushed on a random linked sink pad for
1622 * upstream events or a random linked source pad for downstream events.
1623 * This function takes owership of the provided event so you should
1624 * gst_event_ref() it if you want to reuse the event after this call.
1626 * a GstElement to send the event to.
1628 * the GstEvent to send to the element.
1630 * TRUE if the event was handled.
1633 public int sendEvent(Event event
)
1635 // gboolean gst_element_send_event (GstElement *element, GstEvent *event);
1636 return gst_element_send_event(gstElement
, (event
is null) ?
null : event
.getEventStruct());
1640 * Simple API to perform a seek on the given element, meaning it just seeks
1641 * to the given position relative to the start of the stream. For more complex
1642 * operations like segment seeks (e.g. for looping) or changing the playback
1643 * rate or seeking relative to the last configured playback segment you should
1644 * use gst_element_seek().
1645 * In a completely prerolled PAUSED or PLAYING pipeline, seeking is always
1646 * guaranteed to return TRUE on a seekable media type or FALSE when the media
1647 * type is certainly not seekable (such as a live stream).
1648 * Some elements allow for seeking in the READY state, in this
1649 * case they will store the seek event and execute it when they are put to
1650 * PAUSED. If the element supports seek in READY, it will always return TRUE when
1651 * it receives the event in the READY state.
1653 * a GstElement to seek on
1655 * a GstFormat to execute the seek in, such as GST_FORMAT_TIME
1659 * position to seek to (relative to the start); if you are doing
1660 * a seek in GST_FORMAT_TIME this value is in nanoseconds -
1661 * multiply with GST_SECOND to convert seconds to nanoseconds or
1662 * with GST_MSECOND to convert milliseconds to nanoseconds.
1664 * TRUE if the seek operation succeeded (the seek might not always be
1665 * executed instantly though)
1668 public int seekSimple(GstFormat format
, GstSeekFlags seekFlags
, long seekPos
)
1670 // gboolean gst_element_seek_simple (GstElement *element, GstFormat format, GstSeekFlags seek_flags, gint64 seek_pos);
1671 return gst_element_seek_simple(gstElement
, format
, seekFlags
, seekPos
);
1675 * Sends a seek event to an element. See gst_event_new_seek() for the details of
1676 * the parameters. The seek event is sent to the element using
1677 * gst_element_send_event().
1679 * a GstElement to send the event to.
1681 * The new playback rate
1683 * The format of the seek values
1685 * The optional seek flags.
1687 * The type and flags for the new current position
1689 * The value of the new current position
1691 * The type and flags for the new stop position
1693 * The value of the new stop position
1695 * TRUE if the event was handled.
1698 * The "no-more-pads" signal
1699 * void user_function (GstElement *gstelement,
1700 * gpointer user_data) : Run last
1701 * This signals that the element will not generate more dynamic pads.
1703 * the object which received the signal
1705 * user data set when the signal handler was connected.
1707 public int seek(double rate
, GstFormat format
, GstSeekFlags flags
, GstSeekType curType
, long cur
, GstSeekType stopType
, long stop
)
1709 // gboolean gst_element_seek (GstElement *element, gdouble rate, GstFormat format, GstSeekFlags flags, GstSeekType cur_type, gint64 cur, GstSeekType stop_type, gint64 stop);
1710 return gst_element_seek(gstElement
, rate
, format
, flags
, curType
, cur
, stopType
, stop
);