GstBin

GstBin —

Synopsis


#include <gst/gst.h>


            GstBin;
            GstBinClass;
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,
                                             ...);

enum        GstBinFlags;
#define     GST_BIN_CHILDREN                (bin)
#define     GST_BIN_CHILDREN_COOKIE         (bin)
#define     GST_BIN_NUMCHILDREN             (bin)


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

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;
  GList         *messages;

  gboolean	 polling;
  gboolean       state_dirty;

  gboolean       clock_dirty;
  GstClock	*provided_clock;
  GstElement    *clock_provider;
} GstBin;

The GstBin base class. Subclasses can access these fields provided the LOCK is taken.

gint numchildren; the number of children in this bin
GList *children; the list of children in this bin
guint32 children_cookie; updated whenever children changes
GstBus *child_bus; internal bus for handling child messages
GList *messages; queued messages
gboolean polling; the bin is currently calculating its state
gboolean state_dirty; the bin needs to recalculate its state
gboolean clock_dirty; the bin needs to select a new clock
GstClock *provided_clock; the last clock selected
GstElement *clock_provider; the element that provided provided_clock

GstBinClass

typedef struct {
  GstElementClass parent_class;

  /* virtual methods for subclasses */
  gboolean	(*add_element)		(GstBin *bin, GstElement *element);
  gboolean	(*remove_element)	(GstBin *bin, GstElement *element);

  void		(*handle_message)	(GstBin *bin, GstMessage *message);
} GstBinClass;

Subclasses can override the add_element and remove_element to update the list of children in the bin.

The handle_message method can be overriden to implement custom message handling.

GstElementClass parent_class; bin parent class
add_element () method to add an element to a bin
remove_element () method to remove an element from a bin
handle_message () method to handle a message from the children

gst_bin_new ()

GstElement* gst_bin_new                     (const gchar *name);

Creates a new bin with the given name.

name : the name of the new bin
Returns : a new GstBin

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 : a GstBin
element : the GstElement to add
Returns : TRUE if the element could be added, FALSE if the bin does not want to accept the element.

gst_bin_remove ()

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

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.

bin : a GstBin
element : the GstElement to remove
Returns : TRUE if the element could be removed, FALSE if 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);

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.

bin : a GstBin
name : the element name to search for
Returns : the GstElement with the given name, or NULL

gst_bin_get_by_name_recurse_up ()

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

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

Returns NULL if: - no element with the given name is found in the bin

MT safe. Caller owns returned reference.

bin : a GstBin
name : the element name to search for
Returns : the GstElement with the given name, or NULL

gst_bin_get_by_interface ()

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

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.

bin : a GstBin
interface : the GType of an interface
Returns : A GstElement inside the bin implementing the interface

gst_bin_iterate_elements ()

GstIterator* gst_bin_iterate_elements       (GstBin *bin);

Gets an iterator for the elements in this bin.

Each element yielded by the iterator will have its refcount increased, so unref after use.

MT safe. Caller owns returned value.

bin : a GstBin
Returns : a GstIterator of GstElement, or NULL

gst_bin_iterate_recurse ()

GstIterator* gst_bin_iterate_recurse        (GstBin *bin);

Gets an iterator for the elements in this bin. This iterator recurses into GstBin children.

Each element yielded by the iterator will have its refcount increased, so unref after use.

MT safe. Caller owns returned value.

bin : a GstBin
Returns : a GstIterator of GstElement, or NULL

gst_bin_iterate_sinks ()

GstIterator* gst_bin_iterate_sinks          (GstBin *bin);

Gets an iterator for all elements in the bin that have the GST_ELEMENT_IS_SINK flag set.

Each element yielded by the iterator will have its refcount increased, so unref after use.

MT safe. Caller owns returned value.

bin : a GstBin
Returns : a GstIterator of GstElement, or NULL

gst_bin_iterate_sorted ()

GstIterator* gst_bin_iterate_sorted         (GstBin *bin);

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.

Each element yielded by the iterator will have its refcount increased, so unref after use.

MT safe. Caller owns returned value.

bin : a GstBin
Returns : a GstIterator of GstElement, or NULL

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

Each element yielded by the iterator will have its refcount increased, so unref after use.

MT safe. Caller owns returned value.

bin : a GstBin
interface : the GType of an interface
Returns : a GstIterator of GstElement for all elements in the bin implementing the given interface, or NULL

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 : a GstBin
element_1 : the GstElement 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 : a GstBin
element_1 : the first GstElement to remove from the bin
... : NULL-terminated list of elements to remove from the bin

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 in a bin.

bin : a GstBin

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 : a GstBin

GST_BIN_NUMCHILDREN()

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

Gets the number of children in a bin.

bin : a GstBin

Signals

The "element-added" signal

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

Will be emitted after the element was added to the bin.

bin : the GstBin
element : the GstElement 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 after the element was removed from the bin.

bin : the GstBin
element : the GstElement that was removed from the bin
user_data :user data set when the signal handler was connected.