Sets our main struct and passes it to the parent class
Creates a new bin with the given name.
Adds the given element to the bin. Sets the element's parent, and thus takes ownership of the element. An element can only be added to one bin. If the element's pads are linked to other pads, the pads will be unlinked before the element is added to the bin. Note When you add an element to an already-running pipeline, you will have to take care to set the state of the newly-added element to the desired state (usually PLAYING or PAUSED, same you set the pipeline to originally) with gst_element_set_state(), or use gst_element_sync_state_with_parent(). The bin or pipeline will not take care of this for you. MT safe.
Will be emitted when the bin needs to perform latency calculations. This signal is only emited for toplevel bins or when async-handling is enabled. Only one signal handler is invoked. If no signals are connected, the default handler is invoked, which will query and distribute the lowest possible latency to all sinks. Connect to this signal if the default latency calculations are not sufficient, like when you need different latencies for different sinks in the same pipeline.
Will be emitted after the element was added to the bin.
Will be emitted after the element was removed from the bin.
Recursively looks for elements with an unlinked pad of the given direction within the specified bin and returns an unlinked pad if one is found, or NULL otherwise. If a pad is found, the caller owns a reference to it and should use gst_object_unref() on the pad when it is not needed any longer.
Get the main Gtk struct
Looks for an element inside the bin that implements the given interface. If such an element is found, it returns the element. You can cast this element to the given interface afterwards. If you want all elements that implement the interface, use gst_bin_iterate_all_by_interface(). This function recurses into child bins. MT safe. Caller owns returned reference.
Gets the element with the given name from a bin. This function recurses into child bins. Returns NULL if no element with the given name is found in the bin. MT safe. Caller owns returned reference.
Gets the element with the given name from this bin. If the element is not found, a recursion is performed on the parent bin.
the main Gtk struct as a void*
Looks for all elements inside the bin that implements the given interface. You can safely cast all returned elements to the given interface. The function recurses inside child bins. The iterator will yield a series of GstElement that should be unreffed after use. MT safe. Caller owns returned value.
Gets an iterator for the elements in this bin. MT safe. Caller owns returned value.
Gets an iterator for the elements in this bin. This iterator recurses into GstBin children. MT safe. Caller owns returned value.
Gets an iterator for all elements in the bin that have the GST_ELEMENT_FLAG_SINK flag set. MT safe. Caller owns returned value.
Gets an iterator for the elements in this bin in topologically sorted order. This means that the elements are returned from the most downstream elements (sinks) to the sources. This function is used internally to perform the state changes of the bin elements and for clock selection. MT safe. Caller owns returned value.
Gets an iterator for all elements in the bin that have the GST_ELEMENT_FLAG_SOURCE flag set. MT safe. Caller owns returned value.
Query bin for the current latency using and reconfigures this latency to all the elements with a LATENCY event. This method is typically called on the pipeline when a GST_MESSAGE_LATENCY is posted on the bus. This function simply emits the 'do-latency' signal so any custom latency calculations will be performed.
Removes the element from the bin, unparenting it as well. Unparenting the element means that the element will be dereferenced, so if the bin holds the only reference to the element, the element will be freed in the process of removing it from the bin. If you want the element to still exist after removing, you need to call gst_object_ref() before removing it from the bin. If the element's pads are linked to other pads, the pads will be unlinked before the element is removed from the bin. MT safe.
the main Gtk struct
the main Gtk struct
Get the main Gtk struct
the main Gtk struct as a void*
Queries an element for the stream position. This is a convenience function for gstreamerD.
Queries an element for the stream duration. This is a convenience function for gstreamerD.
This set's the filename for a filesrc element.
Set the caps property of an Element.
For your convenience in gstreamerD: you can seek to the position of the pipeline measured in time_nanoseconds.
Get's all the pads from an element in a Pad[].
This signals that the element will not generate more dynamic pads. Note that this signal will usually be emitted from the context of the streaming thread.
a new GstPad has been added to the element. Note that this signal will usually be emitted from the context of the streaming thread. Also keep in mind that if you add new elements to the pipeline in the signal handler you will need to set them to the desired target state with gst_element_set_state() or gst_element_sync_state_with_parent().
a GstPad has been removed from the element See Also GstElementFactory, GstPad
Adds a padtemplate to an element class. This is mainly used in the _class_init functions of classes. If a pad template with the same name as an already existing one is added the old one is replaced by the new one.
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.
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.
Sets the detailed information for a GstElementClass. Note This function is for use in _class_init functions only.
Sets the detailed information for a GstElementClass. Note This function is for use in _class_init functions only. Same as gst_element_class_set_metadata(), but longname, classification, description, and author must be static strings or inlined strings, as they will not be copied. (GStreamer plugins will be made resident once loaded, so this function can be used even from dynamically loaded plugins.)
Set key with value as metadata in klass.
Set key with value as metadata in klass. Same as gst_element_class_add_metadata(), but value must be a static string or an inlined string, as it will not be copied. (GStreamer plugins will be made resident once loaded, so this function can be used even from dynamically loaded plugins.)
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 "pad-added" signal on the element.
Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of GstElement.
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. This function will first attempt to find a compatible unlinked ALWAYS pad, and if none can be found, it will request a compatible REQUEST pad by looking at the templates of element.
Retrieves a pad template from element that is compatible with compattempl. Pads from compatible templates can be linked together.
Retrieves a pad from the element by name (e.g. "src_%d"). This version only retrieves request pads. The pad should be released with gst_element_release_request_pad(). This method is slow and will be deprecated in the future. New code should use gst_element_request_pad() with the requested template.
Retrieves a pad from element by name. This version only retrieves already-existing (i.e. 'static') pads.
Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using gst_element_factory_get_static_pad_templates(). The pad should be released with gst_element_release_request_pad().
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 "no-more-pads" signal. MT safe.
Makes the element free the previously requested pad as obtained with gst_element_get_request_pad(). This does not unref the pad. If the pad was created by using gst_element_get_request_pad(), gst_element_release_request_pad() needs to be followed by gst_object_unref() to free the pad. MT safe.
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 "pad-removed" signal on the element.
Retrieves an iterator of element's pads. The iterator should be freed after usage. Also more specialized iterators exists such as gst_element_iterate_src_pads() or gst_element_iterate_sink_pads(). The order of pads returned by the iterator will be the order in which the pads were added to the element.
Retrieves an iterator of element's sink pads. The order of pads returned by the iterator will be the order in which the pads were added to the element.
Retrieves an iterator of element's source pads. The order of pads returned by the iterator will be the order in which the pads were added to the element.
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 manually 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.
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().
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.
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. Calling gst_element_link_pads_full() with flags == GST_PAD_LINK_CHECK_DEFAULT is the same as calling gst_element_link_pads() and the recommended way of linking pads with safety checks applied. This is a convenience function for gst_pad_link_full().
Unlinks the two named pads of the source and destination elements. This is a convenience function for gst_pad_unlink().
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.
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.
Get metadata with key in klass.
Set the base time of an element. See gst_element_get_base_time(). MT safe.
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 running time of the element.
Set the start time of an element. The start time of the element is the running time of the element when it last went to the PAUSED state. In READY or after a flushing seek, it is set to 0. Toplevel elements like GstPipeline will manage the start_time and base_time on its children. Setting the start_time to GST_CLOCK_TIME_NONE on such a toplevel element will disable the distribution of the base_time to the children and can be useful if the application manages the base_time itself, for example if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock. MT safe.
Returns the start time of the element. The start time is the running time of the clock when this element was last put to PAUSED. Usually the start_time is managed by a toplevel element such as GstPipeline. MT safe.
Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements. MT safe.
Returns the bus of the element. Note that only a GstPipeline will provide a bus for the application.
Sets the context of the element. Increases the refcount of the context. MT safe.
Retrieves the factory that was used to create this element.
Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.
Gets the currently configured clock of the element. This is the clock as was last set with gst_element_set_clock().
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.
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 GST_MESSAGE_ASYNC_DONE or GST_MESSAGE_STATE_CHANGED on the bus. State changes to GST_STATE_READY or GST_STATE_NULL never return GST_STATE_CHANGE_ASYNC.
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 GST_STATE_PLAYING. 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.
Locks the state of an element, so state changes of the parent don't affect this element anymore. MT safe.
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.
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.
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.
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. 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.
Gets a string representing the given state.
Gets a string representing the given state change result.
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.
Perform transition on element. This function must be called with STATE_LOCK held and is mainly used internally.
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.
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.
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. Please note that some queries might need a running pipeline to work.
Queries an element to convert src_val in src_format to dest_format.
Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds. This will be a value between 0 and the stream duration (if the stream duration is known). This query will usually only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case. If one repeatedly calls this function one can also create a query and reuse it in gst_element_query().
Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds. This query will only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case. If the duration changes for some reason, you will get a DURATION_CHANGED message on the pipeline bus, in which case you should re-query the duration using this function.
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. MT safe.
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.
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(). MT safe.
GstBin is an element that can contain other GstElement, allowing them to be managed as a group. Pads from the child elements can be ghosted to the bin, see GstGhostPad. This makes the bin look like any other elements and enables creation of higher-level abstraction elements.
A new GstBin is created with gst_bin_new(). Use a GstPipeline instead if you want to create a toplevel bin because a normal bin doesn't have a bus or handle clock distribution of its own.
After the bin has been created you will typically add elements to it with gst_bin_add(). You can remove elements with gst_bin_remove().
An element can be retrieved from a bin with gst_bin_get_by_name(), using the elements name. gst_bin_get_by_name_recurse_up() is mainly used for internal purposes and will query the parent bins when the element is not found in the current bin.
An iterator of elements in a bin can be retrieved with gst_bin_iterate_elements(). Various other iterators exist to retrieve the elements in a bin.
gst_object_unref() is used to drop your reference to the bin.
The "element-added" signal is fired whenever a new element is added to the bin. Likewise the "element-removed" signal is fired whenever an element is removed from the bin.
Notes
A GstBin internally intercepts every GstMessage posted by its children and implements the following default behaviour for each of them:
GST_MESSAGE_EOS
This message is only posted by sinks in the PLAYING state. If all sinks posted the EOS message, this bin will post and EOS message upwards.
GST_MESSAGE_SEGMENT_START
just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.
GST_MESSAGE_SEGMENT_DONE
Is posted by GstBin when all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.
GST_MESSAGE_DURATION_CHANGED
Is posted by an element that detected a change in the stream duration. The default bin behaviour is to clear any cached duration values so that the next duration query will perform a full duration recalculation. The duration change is posted to the application so that it can refetch the new duration with a duration query. Note that these messages can be posted before the bin is prerolled, in which case the duration query might fail.
GST_MESSAGE_CLOCK_LOST
This message is posted by an element when it can no longer provide a clock. The default bin behaviour is to check if the lost clock was the one provided by the bin. If so and the bin is currently in the PLAYING state, the message is forwarded to the bin parent. This message is also generated when a clock provider is removed from the bin. If this message is received by the application, it should PAUSE the pipeline and set it back to PLAYING to force a new clock distribution.
GST_MESSAGE_CLOCK_PROVIDE
This message is generated when an element can provide a clock. This mostly happens when a new clock provider is added to the bin. The default behaviour of the bin is to mark the currently selected clock as dirty, which will perform a clock recalculation the next time the bin is asked to provide a clock. This message is never sent tot the application but is forwarded to the parent of the bin.
OTHERS
posted upwards.
A GstBin implements the following default behaviour for answering to a GstQuery:
GST_QUERY_DURATION
If the query has been asked before with the same format and the bin is a toplevel bin (ie. has no parent), use the cached previous value. If no previous value was cached, the query is sent to all sink elements in the bin and the MAXIMUM of all values is returned. If the bin is a toplevel bin the value is cached. If no sinks are available in the bin, the query fails.
GST_QUERY_POSITION
The query is sent to all sink elements in the bin and the MAXIMUM of all values is returned. If no sinks are available in the bin, the query fails.
OTHERS
the query is forwarded to all sink elements, the result of the first sink that answers the query successfully is returned. If no sink is in the bin, the query fails.
A GstBin will by default forward any event sent to it to all sink elements. If all the sinks return TRUE, the bin will also return TRUE, else FALSE is returned. If no sinks are in the bin, the event handler will return TRUE.
Last reviewed on 2012-03-28 (0.11.3)