Bins are created in the same way that other elements are created,
i.e. using an element factory. There are also convenience functions
available (gst_bin_new ()
and
gst_pipeline_new ()
).
To add elements to a bin or remove elements from a
bin, you can use gst_bin_add ()
and
gst_bin_remove ()
. Note that the bin that you
add an element to will take ownership of that element. If you
destroy the bin, the element will be dereferenced with it. If you
remove an element from a bin, it will be dereferenced automatically.
#include <gst/gst.h> int main (int argc, char *argv[]) { GstElement *bin, *pipeline, *source, *sink; /* init */ gst_init (&argc, &argv); /* create */ pipeline = gst_pipeline_new ("my_pipeline"); bin = gst_pipeline_new ("my_bin"); source = gst_element_factory_make ("fakesrc", "source"); sink = gst_element_factory_make ("fakesink", "sink"); /* set up pipeline */ gst_bin_add_many (GST_BIN (bin), source, sink, NULL); gst_bin_add (GST_BIN (pipeline), bin); gst_element_link (source, sink); [..] }
There are various functions to lookup elements in a bin. You can
also get a list of all elements that a bin contains using the function
gst_bin_get_list ()
. See the API references of
GstBin
for details.