GstBin

GstBin — Base class for elements that contain other elements

Synopsis


#include <gst/gst.h>


            GstBin;
enum        GstBinFlags;
#define     GST_BIN_CHILDREN                (bin)
#define     GST_BIN_CHILDREN_COOKIE         (bin)
#define     GST_BIN_NUMCHILDREN             (bin)
GstElement* gst_bin_new                     (const gchar *name);
gboolean    gst_bin_add                     (GstBin *bin,
                                             GstElement *element);
gboolean    gst_bin_remove                  (GstBin *bin,
                                             GstElement *element);
GstElement* gst_bin_get_by_name             (GstBin *bin,
                                             const gchar *name);
GstElement* gst_bin_get_by_name_recurse_up  (GstBin *bin,
                                             const gchar *name);
GstElement* gst_bin_get_by_interface        (GstBin *bin,
                                             GType interface);
GstIterator* gst_bin_iterate_elements       (GstBin *bin);
GstIterator* gst_bin_iterate_recurse        (GstBin *bin);
GstIterator* gst_bin_iterate_sinks          (GstBin *bin);
GstIterator* gst_bin_iterate_sorted         (GstBin *bin);
GstIterator* gst_bin_iterate_all_by_interface
                                            (GstBin *bin,
                                             GType interface);

void        gst_bin_add_many                (GstBin *bin,
                                             GstElement *element_1,
                                             ...);
void        gst_bin_remove_many             (GstBin *bin,
                                             GstElement *element_1,
                                             ...);


Object Hierarchy


  GObject
   +----GstObject
         +----GstElement
               +----GstBin
                     +----GstPipeline

Implemented Interfaces

GstBin implements

Signal Prototypes


"element-added"
            void        user_function      (GstBin *bin,
                                            GstElement *element,
                                            gpointer user_data);
"element-removed"
            void        user_function      (GstBin *bin,
                                            GstElement *element,
                                            gpointer user_data);

Description

GstBin is the simplest of the container elements, allowing elements to become children of itself. Pads from the child elements can be ghosted to the bin, making the bin itself look transparently like any other element, allowing for deep nesting of predefined sub-pipelines.

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.

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.

gst_object_unref() is used to destroy the bin.

Details

GstBin

typedef struct {
  /* our children, subclass are supposed to update these
   * fields to reflect their state with _iterate_*() */
  gint		 numchildren;
  GList		*children;
  guint32	 children_cookie;

  GstBus        *child_bus;	/* Bus we set on our children */
  GList         *messages;      /* list of queued messages */

  gboolean	 polling;
  gboolean       state_dirty;

  gboolean       clock_dirty;
  GstClock	*provided_clock;
} GstBin;


enum GstBinFlags

typedef enum {
  /* padding */
  GST_BIN_FLAG_LAST		= (GST_ELEMENT_FLAG_LAST << 5)
} GstBinFlags;

GstBinFlags are a set of flags specific to bins. Most are set/used internally. They can be checked using the GST_OBJECT_FLAG_IS_SET() macro, and (un)set using GST_OBJECT_FLAG_SET() and GST_OBJECT_FLAG_UNSET().

GST_BIN_FLAG_LAST the last enum in the series of flags for bins. Derived classes can use this as first value in a list of flags.

GST_BIN_CHILDREN()

#define GST_BIN_CHILDREN(bin)		(GST_BIN_CAST(bin)->children)

Gets the list with children a bin manages.

bin : the bin to get the list with children from

GST_BIN_CHILDREN_COOKIE()

#define GST_BIN_CHILDREN_COOKIE(bin)	(GST_BIN_CAST(bin)->children_cookie)

Gets the children cookie that watches the children list.

bin : the bin to get the children cookie from

GST_BIN_NUMCHILDREN()

#define GST_BIN_NUMCHILDREN(bin)	(GST_BIN_CAST(bin)->numchildren)

Gets the number of children a bin manages.

bin : the bin to get the number of children from

gst_bin_new ()

GstElement* gst_bin_new                     (const gchar *name);

Create a new bin with given name.

name : name of new bin
Returns : new bin

gst_bin_add ()

gboolean    gst_bin_add                     (GstBin *bin,
                                             GstElement *element);

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.

MT safe.

bin : GstBin to add element to
element : GstElement to add to bin
Returns : TRUE if the element could be added, FALSE on wrong parameters or the bin does not want to accept the element.

gst_bin_remove ()

gboolean    gst_bin_remove                  (GstBin *bin,
                                             GstElement *element);

Remove the element from its associated 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.

bin : GstBin to remove element from
element : GstElement to remove
Returns : TRUE if the element could be removed, FALSE on wrong parameters or the bin does not want to remove the element.

gst_bin_get_by_name ()

GstElement* gst_bin_get_by_name             (GstBin *bin,
                                             const gchar *name);

Get the element with the given name from this bin. This function recurses into subbins.

MT safe.

bin : Gstbin to search
name : the element name to search for
Returns : the element with the given name. Returns NULL if the element is not found or when bad parameters were given. Unref after use.

gst_bin_get_by_name_recurse_up ()

GstElement* gst_bin_get_by_name_recurse_up  (GstBin *bin,
                                             const gchar *name);

MT safe.

Get the element with the given name from this bin. If the element is not found, a recursion is performed on the parent bin.

bin : Gstbin to search
name : the element name to search for
Returns : the element with the given name or NULL when the element was not found or bad parameters were given. Unref after use.

gst_bin_get_by_interface ()

GstElement* gst_bin_get_by_interface        (GstBin *bin,
                                             GType interface);

Looks for the first 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(). The function recurses inside bins.

MT safe.

bin : bin to find element in
interface : interface to be implemented by interface
Returns : An GstElement inside the bin implementing the interface. Unref after use.

gst_bin_iterate_elements ()

GstIterator* gst_bin_iterate_elements       (GstBin *bin);

Get an iterator for the elements in this bin. Each element will have its refcount increased, so unref after use.

MT safe.

bin : Gstbin to iterate the elements of
Returns : a GstIterator of GstElements. gst_iterator_free after use. returns NULL when passing bad parameters.

gst_bin_iterate_recurse ()

GstIterator* gst_bin_iterate_recurse        (GstBin *bin);

Get an iterator for the elements in this bin. Each element will have its refcount increased, so unref after use. This iterator recurses into GstBin children.

MT safe.

bin : Gstbin to iterate the elements of
Returns : a GstIterator of GstElements. gst_iterator_free after use. returns NULL when passing bad parameters.

gst_bin_iterate_sinks ()

GstIterator* gst_bin_iterate_sinks          (GstBin *bin);

Get an iterator for the sink elements in this bin. Each element will have its refcount increased, so unref after use.

The sink elements are those with the GST_ELEMENT_IS_SINK flag set.

MT safe.

bin : Gstbin to iterate on
Returns : a GstIterator of GstElements. gst_iterator_free after use.

gst_bin_iterate_sorted ()

GstIterator* gst_bin_iterate_sorted         (GstBin *bin);

Get 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.

Each element will have its refcount increased, so unref after use.

MT safe.

bin : Gstbin to iterate on
Returns : a GstIterator of GstElements. gst_iterator_free after use.

gst_bin_iterate_all_by_interface ()

GstIterator* gst_bin_iterate_all_by_interface
                                            (GstBin *bin,
                                             GType interface);

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 bins inside bins. The iterator will return a series of GstElement that should be unreffed after use.

MT safe.

bin : bin to find elements in
interface : interface to be implemented by interface
Returns : A GstIterator for the elements inside the bin implementing the given interface.

gst_bin_add_many ()

void        gst_bin_add_many                (GstBin *bin,
                                             GstElement *element_1,
                                             ...);

Adds a NULL-terminated list of elements to a bin. This function is equivalent to calling gst_bin_add() for each member of the list.

bin : the bin to add the elements to
element_1 : the first element to add to the bin
... : additional elements to add to the bin

gst_bin_remove_many ()

void        gst_bin_remove_many             (GstBin *bin,
                                             GstElement *element_1,
                                             ...);

Remove a list of elements from a bin. This function is equivalent to calling gst_bin_remove() with each member of the list.

bin : the bin to remove the elements from
element_1 : the first element to remove from the bin
... : NULL-terminated list of elements to remove from the bin

Signals

The "element-added" signal

void        user_function                  (GstBin *bin,
                                            GstElement *element,
                                            gpointer user_data);

Will be emitted if a new element was removed/added to this bin.

bin : the object which emitted the signal.
element : the element that was added to the bin
user_data : user data set when the signal handler was connected.

The "element-removed" signal

void        user_function                  (GstBin *bin,
                                            GstElement *element,
                                            gpointer user_data);

Will be emitted if an element was removed from this bin.

bin : the object which emitted the signal.
element : the element that was removed from the bin
user_data : user data set when the signal handler was connected.