In the previous section, we briefly introduced the GstElementFactory
object already as a way to create instances of an element. Element
factories, however, are much more than just that. Element factories
are the basic types retrieved from the GStreamer registry, they
describe all plugins and elements that GStreamer can create. This
means that element factories are useful for automated element
instancing, such as what autopluggers do, and for creating lists
of available elements, such as what pipeline editing applications
(e.g. GStreamer
Editor) do.
Tools like gst-inspect will provide some generic
information about an element, such as the person that wrote the
plugin, a descriptive name (and a shortname), a rank and a category.
The category can be used to get the type of the element that can
be created using this element factory. Examples of categories include
Codec/Decoder/Video
(video decoder),
Codec/Encoder/Video
(video encoder),
Source/Video
(a video generator),
Sink/Video
(a video output), and all these
exist for audio as well, of course. Then, there's also
Codec/Demuxer
and
Codec/Muxer
and a whole lot more.
gst-inspect will give a list of all factories, and
gst-inspect <factory-name> will list all
of the above information, and a lot more.
#include <gst/gst.h> int main (int argc, char *argv[]) { GstElementFactory *factory; /* init GStreamer */ gst_init (&argc, &argv); /* get factory */ factory = gst_element_factory_find ("audiotestsrc"); if (!factory) { g_print ("You don't have the 'audiotestsrc' element installed!\n"); return -1; } /* display information */ g_print ("The '%s' element is a member of the category %s.\n" "Description: %s\n", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), gst_element_factory_get_klass (factory), gst_element_factory_get_description (factory)); return 0; }
You can use gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY)
to get a list of all the element factories that GStreamer knows
about.
Perhaps the most powerful feature of element factories is that
they contain a full description of the pads that the element
can generate, and the capabilities of those pads (in layman words:
what types of media can stream over those pads), without actually
having to load those plugins into memory. This can be used
to provide a codec selection list for encoders, or it can be used
for autoplugging purposes for media players. All current
GStreamer-based media players and autopluggers work this way.
We'll look closer at these features as we learn about
GstPad
and GstCaps
in the next chapter: Pads and capabilities