GstBin

GstBin — Base class for elements that contain other elements

Synopsis


#include <gst/gst.h>


struct      GstBin;
enum        GstBinFlags;
GstElement* gst_bin_new                     (const gchar *name);
gboolean    gst_bin_add                     (GstBin *bin,
                                             GstElement *element);
void        gst_bin_add_many                (GstBin *bin,
                                             GstElement *element_1,
                                             ...);
gboolean    gst_bin_remove                  (GstBin *bin,
                                             GstElement *element);
void        gst_bin_remove_many             (GstBin *bin,
                                             GstElement *element_1,
                                             ...);
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);


Object Hierarchy


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

Signal Prototypes


"element-added"
            void        user_function      (GstBin *gstbin,
                                            GstElement *arg1,
                                            gpointer user_data);
"element-removed"
            void        user_function      (GstBin *gstbin,
                                            GstElement *arg1,
                                            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 scheduler 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.

The list of elements in a bin can be retrieved with gst_bin_get_list().

After the bin has been set to the PLAYING state (with gst_element_set_state()), gst_bin_iterate() is used to process the elements in the bin.

The "element_added" signal is fired whenever a new element is added to the bin.

The "element_removed" signal is fired whenever an element is removed from the bin.

gst_bin_destroy() is used to destroy the bin.

To control the selection of the clock in a bin, you can use the following methods: gst_bin_auto_clock() to let the bin select a clock automatically, gst_bin_get_clock() to get the current clock of the bin and gst_bin_use_clock() to specify a clock explicitly. Note that the default behaviour is to automatically select a clock from one of the clock providers in the bin.

Details

struct GstBin

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

};


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_FLAG_IS_SET() macro, and (un)set using GST_FLAG_SET() and GST_FLAG_UNSET().

GST_BIN_FLAG_LAST the last enum in the series of flags in a bin, derived classes can use this as first value in a list of flags.

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.

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. MT safe.

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 ()

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.

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. MT safe.

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

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.

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 usage. MT safe.

gst_bin_get_by_name_recurse_up ()

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

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 usage. MT safe.

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 bins inside bins.

bin : bin to find element in
interface : interface to be implemented by interface
Returns : An element inside the bin implementing the interface. Unref after usage. MT safe.

Signals

The "element-added" signal

void        user_function                  (GstBin *gstbin,
                                            GstElement *arg1,
                                            gpointer user_data);

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

gstbin :the object which received the signal.
arg1 :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 *gstbin,
                                            GstElement *arg1,
                                            gpointer user_data);

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

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