Object Hierarchy:

Object hierarchy for ElementFactory


[ CCode ( type_id = "gst_element_factory_get_type ()" ) ]
public class ElementFactory : PluginFeature

ElementFactory is used to create instances of elements.

A GstElementFactory can be added to a Plugin as it is also a PluginFeature.

Use the find and create functions to create element instances or use make as a convenient shortcut.

The following code example shows you how to create a GstFileSrc element.

typeof (unichar2) typeof (unichar2) Using an element factory

  #include <gst/gst.h>

GstElement *src;
GstElementFactory *srcfactory;

gst_init (&argc, &argv);

srcfactory = gst_element_factory_find ("filesrc");
g_return_if_fail (srcfactory != NULL);
src = gst_element_factory_create (srcfactory, "src");
g_return_if_fail (src != NULL);

Example: GStreamer concepts:

// See http://docs.gstreamer.com/x/ZgAF
// 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 (source.link (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", msg.src.name, 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

Namespace: Gst
Package: gstreamer-1.0


Static methods:

Creation methods:


Inherited Members: