public void add_many (Element[] elements)

Adds a null-terminated list of elements to a bin.

This function is equivalent to calling add for each member of the list. The return value of each add is ignored.

Example: GStreamer concepts:

// See
// for a detailed description

public static int main (string[] args) {

// Initialize GStreamer:
Gst.init (ref args);

// Create the elements:
Gst.Element source = Gst.ElementFactory.make ("videotestsrc", "source");
Gst.Element sink = Gst.ElementFactory.make ("autovideosink", "sink");

// Create the empty pipeline:
Gst.Pipeline pipeline = new Gst.Pipeline ("test-pipeline");

if (source == null || sink == null || pipeline == null) {
stderr.puts ("Not all elements could be created.\n");
return -1;

// Build the pipeline:
pipeline.add_many (source, sink);

if ( (sink) != true) {
stderr.puts ("Elements could not be linked.\n");
return -1;

// Modify the source's properties:
source.set ("pattern", 0);

// Start playing:
Gst.StateChangeReturn ret = pipeline.set_state (Gst.State.PLAYING);
if (ret == Gst.StateChangeReturn.FAILURE) {
stderr.puts ("Unable to set the pipeline to the playing state.\n");
return -1;

// Wait until error or EOS:
Gst.Bus bus = pipeline.get_bus ();
Gst.Message msg = bus.timed_pop_filtered (Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS);

// Parse message:
if (msg != null) {
switch (msg.type) {
case Gst.MessageType.ERROR:
GLib.Error err;
string debug_info;

msg.parse_error (out err, out debug_info);
stderr.printf ("Error received from element %s: %s\n",, err.message);
stderr.printf ("Debugging information: %s\n", (debug_info != null)? debug_info : "none");

case Gst.MessageType.EOS:
print ("End-Of-Stream reached.\n");

// We should not reach here because we only asked for ERRORs and EOS:
assert_not_reached ();

// Free resources:
pipeline.set_state (Gst.State.NULL);

return 0;

valac --pkg gstreamer-1.0 concepts.vala



a Bin


the Element element to add to the bin


additional elements to add to the bin