GstElement The most important object in GStreamer for the application programmer is the GstElement object. What is a GstElement The GstElement is the basic building block for the media pipeline. All the different components you are going to use are derived from this GstElement. This means that a lot of functions you are going to use operate on this object. Elements, from the perspective of GStreamer, are viewed as "black boxes" with a number of different aspects. One of these aspects is the presence of "pads", or connection points. This terminology arises from soldering; pads are where wires can be attached. Source elements Source elements generate data for use by a pipeline, for example reading from disk or from a sound card. Below you see how we will visualize the element. We always draw a src pad to the right of the element.
Visualisation of a source element
Source elements do not accept data, they only generate data. You can see this in the figure because it only has a src pad. A src pad can only generate buffers.
Filters and codecs Filter elements both have input and output pads. They operate on data they receive in their sink pads and produce data on their src pads. For example, MPEG decoders and volume filters would fall into this category. Elements are not constrained as to the number of pads they migh have; for example, a video mixer might have two input pads (the images of the two different video streams) and one output pad.
Visualisation of a filter element
The above figure shows the visualisation of a filter element. This element has one sink (input) pad and one src (output) pad. Sink pads are drawn on the left of the element.
Visualisation of a filter element with more than one output pad
The above figure shows the visualisation of a filter element with more than one output pad. An example of such a filter is the AVI splitter (demuxer). This element will parse the input data and extracts the audio and video data. Most of these filters dynamically send out a signal when a new pad is created so that the application programmer can connect an arbitrary element to the newly created pad.
Sink elements Sink elements are terminal points in a media pipeline. They accept data but do not produce anything. Disk writing, soundcard playback, and video output woul all be implemented by sink elements.
Visualisation of a sink element
Creating a GstElement GstElements are created from factories. To create an element, one has to get access the a GstElementFactory using a unique factoryname. The following code example is used to get a factory that can be used to create the 'mad' element, an mp3 decoder. GstElementFactory *factory; factory = gst_element_factory_find ("mad"); Once you have the handle to the elementfactory, you can create a real element with the following code fragment: GstElement *element; element = gst_element_factory_create (factory, "decoder"); gst_element_factory_create () will use the elementfactory to create an element with the given name. The name of the element is something you can use later on to lookup the element in a bin, for example. You can pass NULL as the name argument to get a unique, default name. A simple shortcut exists for creating an element from a factory. The following example creates an element, named "decoder" from the elementfactory named "mad". This convenient function is most widely used to create an element. GstElement *element; element = gst_element_factory_make ("mad", "decoder"); An element can be destroyed with: FIXME talk about refcounting GstElement *element; ... gst_element_destroy (element);