Element

Description GstElement is the abstract base class needed to construct an element that can be used in a GStreamer pipeline. Please refer to the plugin writers guide for more information on creating GstElement subclasses. The name of a GstElement can be get with gst_element_get_name() and set with gst_element_set_name(). For speed, GST_ELEMENT_NAME() can be used in the core when using the appropriate locking. Do not use this in plug-ins or applications in order to retain ABI compatibility. All elements have pads (of the type GstPad). These pads link to pads on other elements. GstBuffer flow between these linked pads. A GstElement has a GList of GstPad structures for all their input (or sink) and output (or source) pads. Core and plug-in writers can add and remove pads with gst_element_add_pad() and gst_element_remove_pad(). A pad of an element can be retrieved by name with gst_element_get_pad(). An iterator of all pads can be retrieved with gst_element_iterate_pads(). Elements can be linked through their pads. If the link is straightforward, use the gst_element_link() convenience function to link two elements, or gst_element_link_many() for more elements in a row. Use gst_element_link_filtered() to link two elements constrained by a specified set of GstCaps. For finer control, use gst_element_link_pads() and gst_element_link_pads_filtered() to specify the pads to link on each element by name. Each element has a state (see GstState). You can get and set the state of an element with gst_element_get_state() and gst_element_set_state(). To get a string representation of a GstState, use gst_element_state_get_name(). You can get and set a GstClock on an element using gst_element_get_clock() and gst_element_set_clock(). Some elements can provide a clock for the pipeline if gst_element_provides_clock() returns TRUE. With the gst_element_provide_clock() method one can retrieve the clock provided by such an element. Not all elements require a clock to operate correctly. If gst_element_requires_clock() returns TRUE, a clock should be set on the element with gst_element_set_clock(). Note that clock slection and distribution is normally handled by the toplevel GstPipeline so the clock functions are only to be used in very specific situations. Last reviewed on 2006-03-12 (0.10.5)

class Element : ObjectGst {}

Constructors

this
this(GstElement* gstElement)

Sets our main struct and passes it to the parent class

Members

Functions

abortState
void abortState()

Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong. This function should be called with the STATE_LOCK held. MT safe.

addOnNoMorePads
void addOnNoMorePads(void delegate(Element) dlg, ConnectFlags connectFlags)

This signals that the element will not generate more dynamic pads.

addOnPadAdded
void addOnPadAdded(void delegate(Pad, Element) dlg, ConnectFlags connectFlags)

a new GstPad has been added to the element.

addOnPadRemoved
void addOnPadRemoved(void delegate(Pad, Element) dlg, ConnectFlags connectFlags)

a GstPad has been removed from the element See Also GstElementFactory, GstPad

addPad
int addPad(Pad pad)

Adds a pad (link point) to element. pad's parent will be set to element; see gst_object_set_parent() for refcounting information. Pads are not automatically activated so elements should perform the needed steps to activate the pad in case this pad is added in the PAUSED or PLAYING state. See gst_pad_set_active() for more information about activating pads. The pad and the element should be unlocked when calling this function. This function will emit the GstElement::pad-added signal on the element.

caps
void caps(Caps cp)

Set the caps property of an Element.

changeState
GstStateChangeReturn changeState(GstStateChange transition)

Perform transition on element. This function must be called with STATE_LOCK held and is mainly used internally.

continueState
GstStateChangeReturn continueState(GstStateChangeReturn ret)

Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned GST_STATE_CHANGE_SUCCESS from the state change function. If after calling this method the element still has not reached the pending state, the next state change is performed. This method is used internally and should normally not be called by plugins or applications.

createAllPads
void createAllPads()

Creates a pad for each pad template that is always available. This function is only useful during object intialization of subclasses of GstElement.

foundTags
void foundTags(TagList list)

Posts a message to the bus that new tags were found, and pushes an event to all sourcepads. Takes ownership of the list. This is a utility method for elements. Applications should use the GstTagSetter interface.

foundTagsForPad
void foundTagsForPad(Pad pad, TagList list)

Posts a message to the bus that new tags were found and pushes the tags as event. Takes ownership of the list. This is a utility method for elements. Applications should use the GstTagSetter interface.

getBaseTime
GstClockTime getBaseTime()

Returns the base time of the element. The base time is the absolute time of the clock when this element was last put to PLAYING. Subtracting the base time from the clock time gives the stream time of the element.

getBus
Bus getBus()

Returns the bus of the element. Note that only a GstPipeline will provide a bus for the application.

getClock
Clock getClock()

Gets the currently configured clock of the element. This is the clock as was last set with gst_element_set_clock().

getCompatiblePad
Pad getCompatiblePad(Pad pad, Caps caps)

Looks for an unlinked pad to which the given pad can link. It is not guaranteed that linking the pads will work, though it should work in most cases.

getCompatiblePadTemplate
PadTemplate getCompatiblePadTemplate(PadTemplate compattempl)

Retrieves a pad template from element that is compatible with compattempl. Pads from compatible templates can be linked together.

getElementStruct
GstElement* getElementStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getFactory
ElementFactory getFactory()

Retrieves the factory that was used to create this element.

getIndex
Index getIndex()

Gets the index from the element.

getPad
Pad getPad(string name)

Retrieves a pad from element by name. Tries gst_element_get_static_pad() first, then gst_element_get_request_pad(). Note Usage of this function is not recommended as it is unclear if the reference to the result pad should be released with gst_object_unref() in case of a static pad or gst_element_release_request_pad() in case of a request pad.

getQueryTypes
GstQueryType* getQueryTypes()

Get an array of query types from the element. If the element doesn't implement a query types function, the query will be forwarded to the peer of a random linked sink pad.

getRequestPad
Pad getRequestPad(string name)

Retrieves a pad from the element by name. This version only retrieves request pads. The pad should be released with gst_element_release_request_pad().

getState
GstStateChangeReturn getState(GstState state, GstState pending, GstClockTime timeout)

Gets the state of the element. For elements that performed an ASYNC state change, as reported by gst_element_set_state(), this function will block up to the specified timeout value for the state change to complete. If the element completes the state change or goes into an error, this function returns immediately with a return value of GST_STATE_CHANGE_SUCCESS or GST_STATE_CHANGE_FAILURE respectively. For elements that did not return GST_STATE_CHANGE_ASYNC, this function returns the current and pending state immediately. This function returns GST_STATE_CHANGE_NO_PREROLL if the element successfully changed its state but is not able to provide data yet. This mostly happens for live sources that only produce data in the PLAYING state. While the state change return is equivalent to GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start.

getStaticPad
Pad getStaticPad(string name)

Retrieves a pad from element by name. This version only retrieves already-existing (i.e. 'static') pads.

getStruct
void* getStruct()

the main Gtk struct as a void*

isIndexable
int isIndexable()

Queries if the element can be indexed.

isLockedState
int isLockedState()

Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don't affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from GST_STATE_NULL. MT safe.

iteratePads
Iterator iteratePads()

Retrieves an iterattor of element's pads. The iterator should be freed after usage.

iterateSinkPads
Iterator iterateSinkPads()

Retrieves an iterator of element's sink pads.

iterateSrcPads
Iterator iterateSrcPads()

Retrieves an iterator of element's source pads.

link
int link(Element dest)

Links src to dest. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. Such pads need to be released manualy when unlinking. If multiple links are possible, only one is established. Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.

linkFiltered
int linkFiltered(Element dest, Caps filter)

Links src to dest using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. If multiple links are possible, only one is established. Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.

linkPads
int linkPads(string srcpadname, Element dest, string destpadname)

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

linkPadsFiltered
int linkPadsFiltered(string srcpadname, Element dest, string destpadname, Caps filter)

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. If caps is not NULL, makes sure that the caps of the link is a subset of caps.

location
void location(string set)

This set's the filename for a filesrc element.

lostState
void lostState()

Brings the element to the lost state. The current state of the element is copied to the pending state so that any call to gst_element_get_state() will return GST_STATE_CHANGE_ASYNC. An ASYNC_START message is posted with an indication to distribute a new base_time to the element. If the element was PLAYING, it will go to PAUSED. The element will be restored to its PLAYING state by the parent pipeline when it prerolls again. This is mostly used for elements that lost their preroll buffer in the GST_STATE_PAUSED or GST_STATE_PLAYING state after a flush, they will go to their pending state again when a new preroll buffer is queued. This function can only be called when the element is currently not in error or an async state change. This function is used internally and should normally not be called from plugins or applications. MT safe.

messageFull
void messageFull(GstMessageType type, GQuark domain, int code, string text, string dbug, string file, string funct, int line)

Post an error, warning or info message on the bus from inside an element. type must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or GST_MESSAGE_INFO. MT safe.

noMorePads
void noMorePads()

Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with GST_PAD_SOMETIMES pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads. This function emits the GstElement::no-more-pads signal. MT safe.

pads
Pad[] pads()

Get's all the pads from an element in a Pad[]. FIXME: This a hackish mess.

postMessage
int postMessage(Message message)

Post a message on the element's GstBus. This function takes ownership of the message; if you want to access the message after this call, you should add an additional reference before calling.

provideClock
Clock provideClock()

Get the clock provided by the given element. Note An element is only required to provide a clock in the PAUSED state. Some elements can provide a clock in other states.

providesClock
int providesClock()

Query if the element provides a clock. A GstClock provided by an element can be used as the global GstClock for the pipeline. An element that can provide a clock is only required to do so in the PAUSED state, this means when it is fully negotiated and has allocated the resources to operate the clock.

query
int query(Query query)

Performs a query on the given element. For elements that don't implement a query handler, this function forwards the query to a random srcpad or to the peer of a random linked sinkpad of this element.

queryConvert
int queryConvert(GstFormat srcFormat, long srcVal, GstFormat destFormat, long* destVal)

Queries an element to convert src_val in src_format to dest_format.

queryDuration
long queryDuration()

Queries an element for the stream duration. This is a convenience function for gstreamerD.

queryDuration
int queryDuration(GstFormat format, long duration)

Queries an element for the total stream duration.

queryPosition
long queryPosition()

Queries an element for the stream position. This is a convenience function for gstreamerD.

queryPosition
int queryPosition(GstFormat format, long cur)

Queries an element for the stream position.

releaseRequestPad
void releaseRequestPad(Pad pad)

Makes the element free the previously requested pad as obtained with gst_element_get_request_pad(). MT safe.

removePad
int removePad(Pad pad)

Removes pad from element. pad will be destroyed if it has not been referenced elsewhere using gst_object_unparent(). This function is used by plugin developers and should not be used by applications. Pads that were dynamically requested from elements with gst_element_get_request_pad() should be released with the gst_element_release_request_pad() function instead. Pads are not automatically deactivated so elements should perform the needed steps to deactivate the pad in case this pad is removed in the PAUSED or PLAYING state. See gst_pad_set_active() for more information about deactivating pads. The pad and the element should be unlocked when calling this function. This function will emit the GstElement::pad-removed signal on the element.

requiresClock
int requiresClock()

Query if the element requires a clock.

seek
int seek(long time_nanoseconds)

For your convenience in gstreamerD: you can seek to the position of the pipeline measured in time_nanoseconds.

seek
int seek(double rate, GstFormat format, GstSeekFlags flags, GstSeekType curType, long cur, GstSeekType stopType, long stop)

Sends a seek event to an element. See gst_event_new_seek() for the details of the parameters. The seek event is sent to the element using gst_element_send_event().

seekSimple
int seekSimple(GstFormat format, GstSeekFlags seekFlags, long seekPos)

Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use gst_element_seek(). In a completely prerolled PAUSED or PLAYING pipeline, seeking is always guaranteed to return TRUE on a seekable media type or FALSE when the media type is certainly not seekable (such as a live stream). Some elements allow for seeking in the READY state, in this case they will store the seek event and execute it when they are put to PAUSED. If the element supports seek in READY, it will always return TRUE when it receives the event in the READY state.

sendEvent
int sendEvent(Event event)

Sends an event to an element. If the element doesn't implement an event handler, the event will be pushed on a random linked sink pad for upstream events or a random linked source pad for downstream events. This function takes owership of the provided event so you should gst_event_ref() it if you want to reuse the event after this call.

setBaseTime
void setBaseTime(GstClockTime time)

Set the base time of an element. See gst_element_get_base_time(). MT safe.

setBus
void setBus(Bus bus)

Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements. MT safe.

setClock
int setClock(Clock clock)

Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.

setIndex
void setIndex(Index index)

Set index on the element. The refcount of the index will be increased, any previously set index is unreffed. MT safe.

setLockedState
int setLockedState(int lockedState)

Locks the state of an element, so state changes of the parent don't affect this element anymore. MT safe.

setState
GstStateChangeReturn setState(GstState state)

Sets the state of the element. This function will try to set the requested state by going through all the intermediary states and calling the class's state change function for each. This function can return GST_STATE_CHANGE_ASYNC, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can use gst_element_get_state() to wait for the completion of the state change or it can wait for a state change message on the bus.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
syncStateWithParent
int syncStateWithParent()

Tries to change the state of the element to the same as its parent. If this function returns FALSE, the state of element is undefined.

unlink
void unlink(Element dest)

Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked. If the link has been made using gst_element_link(), it could have created an requestpad, which has to be released using gst_element_release_request_pad().

unlinkPads
void unlinkPads(string srcpadname, Element dest, string destpadname)

Unlinks the two named pads of the source and destination elements.

Static functions

callBackNoMorePads
void callBackNoMorePads(GstElement* gstelementStruct, Element _element)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPadAdded
void callBackPadAdded(GstElement* gstelementStruct, GstPad* newPad, Element _element)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPadRemoved
void callBackPadRemoved(GstElement* gstelementStruct, GstPad* oldPad, Element _element)
Undocumented in source. Be warned that the author may not have intended to support it.
classAddPadTemplate
void classAddPadTemplate(GstElementClass* klass, PadTemplate templ)

Adds a padtemplate to an element class. This is mainly used in the _base_init functions of classes.

classGetPadTemplate
PadTemplate classGetPadTemplate(GstElementClass* elementClass, string name)

Retrieves a padtemplate from element_class with the given name. Note If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.

classGetPadTemplateList
GList* classGetPadTemplateList(GstElementClass* elementClass)

Retrieves a list of the pad templates associated with element_class. The list must not be modified by the calling code. Note If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.

classSetDetails
void classSetDetails(GstElementClass* klass, GstElementDetails* details)

Sets the detailed information for a GstElementClass. Note This function is for use in _base_init functions only. The details are copied.

classSetDetailsSimple
void classSetDetailsSimple(GstElementClass* klass, string longname, string classification, string description, string author)

Sets the detailed information for a GstElementClass. Simpler version of gst_element_class_set_details() that generates less linker overhead. Note This function is for use in _base_init functions only. The detail parameter strings are copied into the GstElementDetails for the element class.

stateChangeReturnGetName
string stateChangeReturnGetName(GstStateChangeReturn stateRet)

Gets a string representing the given state change result.

stateGetName
string stateGetName(GstState state)

Gets a string representing the given state.

Variables

connectedSignals
int[string] connectedSignals;
gstElement
GstElement* gstElement;

the main Gtk struct

onNoMorePadsListeners
void delegate(Element)[] onNoMorePadsListeners;
Undocumented in source.
onPadAddedListeners
void delegate(Pad, Element)[] onPadAddedListeners;
Undocumented in source.
onPadRemovedListeners
void delegate(Pad, Element)[] onPadRemovedListeners;
Undocumented in source.

Inherited Members

From ObjectGst

gstObject
GstObject* gstObject;

the main Gtk struct

getObjectGstStruct
GstObject* getObjectGstStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
connectedSignals
int[string] connectedSignals;
onDeepNotifyListeners
void delegate(ObjectGst, ParamSpec, ObjectGst)[] onDeepNotifyListeners;
Undocumented in source.
addOnDeepNotify
void addOnDeepNotify(void delegate(ObjectGst, ParamSpec, ObjectGst) dlg, ConnectFlags connectFlags)

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

callBackDeepNotify
void callBackDeepNotify(GstObject* gstobjectStruct, GstObject* propObject, GParamSpec* prop, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onObjectSavedListeners
void delegate(void*, ObjectGst)[] onObjectSavedListeners;
Undocumented in source.
addOnObjectSaved
void addOnObjectSaved(void delegate(void*, ObjectGst) dlg, ConnectFlags connectFlags)

Trigered whenever a new object is saved to XML. You can connect to this signal to insert custom XML tags into the core XML.

callBackObjectSaved
void callBackObjectSaved(GstObject* gstobjectStruct, void* xmlNode, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onParentSetListeners
void delegate(ObjectG, ObjectGst)[] onParentSetListeners;
Undocumented in source.
addOnParentSet
void addOnParentSet(void delegate(ObjectG, ObjectGst) dlg, ConnectFlags connectFlags)

Emitted when the parent of an object is set.

callBackParentSet
void callBackParentSet(GstObject* gstobjectStruct, GObject* parent, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onParentUnsetListeners
void delegate(ObjectG, ObjectGst)[] onParentUnsetListeners;
Undocumented in source.
addOnParentUnset
void addOnParentUnset(void delegate(ObjectG, ObjectGst) dlg, ConnectFlags connectFlags)

Emitted when the parent of an object is unset.

callBackParentUnset
void callBackParentUnset(GstObject* gstobjectStruct, GObject* parent, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
setName
int setName(string name)

Sets the name of object, or gives object a guaranteed unique name (if name is NULL). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.

getName
string getName()

Returns a copy of the name of object. Caller should g_free() the return value after usage. For a nameless object, this returns NULL, which you can safely g_free() as well.

setParent
int setParent(ObjectGst parent)

Sets the parent of object to parent. The object's reference count will be incremented, and any floating reference will be removed (see gst_object_sink()). This function causes the parent-set signal to be emitted when the parent was successfully set.

getParent
ObjectGst getParent()

Returns the parent of object. This function increases the refcount of the parent object so you should gst_object_unref() it after usage.

unparent
void unparent()

Clear the parent of object, removing the associated reference. This function decreases the refcount of object. MT safe. Grabs and releases object's lock.

getNamePrefix
string getNamePrefix()

Returns a copy of the name prefix of object. Caller should g_free() the return value after usage. For a prefixless object, this returns NULL, which you can safely g_free() as well.

setNamePrefix
void setNamePrefix(string namePrefix)

Sets the name prefix of object to name_prefix. This function makes a copy of the provided name prefix, so the caller retains ownership of the name prefix it sent. MT safe. This function grabs and releases object's LOCK.

defaultDeepNotify
void defaultDeepNotify(ObjectG object, ObjectGst orig, ParamSpec pspec, string[] excludedProps)

A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print. MT safe. This function grabs and releases object's LOCK for getting its path string.

defaultError
void defaultError(ErrorG error, string dbug)

A default error function. The default handler will simply print the error string using g_print.

checkUniqueness
int checkUniqueness(ListG list, string name)

Checks to see if there is any object named name in list. This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock each GstObject in the list to compare the name, so be carefull when passing a list with a locked object.

hasAncestor
int hasAncestor(ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy.

doref
void* doref(void* object)

Increments the refence count on object. This function does not take the lock on object because it relies on atomic refcounting. This object returns the input parameter to ease writing

unref
void unref(void* object)

Decrements the refence count on object. If reference count hits zero, destroy object. This function does not take the lock on object as it relies on atomic refcounting. The unref method should never be called with the LOCK held since this might deadlock the dispose function.

sink
void sink(void* object)

If object was floating, the GST_OBJECT_FLOATING flag is removed and object is unreffed. When object was not floating, this function does nothing. Any newly created object has a refcount of 1 and is floating. This function should be used when creating a new object to symbolically 'take ownership' of object. This done by first doing a gst_object_ref() to keep a reference to object and then gst_object_sink() to remove and unref any floating references to object. Use gst_object_set_parent() to have this done for you. MT safe. This function grabs and releases object lock.

replace
void replace(ObjectGst oldobj, ObjectGst newobj)

Unrefs the GstObject pointed to by oldobj, refs newobj and puts newobj in *oldobj. Be carefull when calling this function, it does not take any locks. You might want to lock the object owning oldobj pointer before calling this function. Make sure not to LOCK oldobj because it might be unreffed which could cause a deadlock when it is disposed.

getPathString
string getPathString()

Generates a string describing the path of object in the object hierarchy. Only useful (or used) for debugging.

Meta