## GstElementFactory

GstElementFactory — Create GstElements from a factory

## Synopsis

    #include <gst/gst.h>

                GstElementFactory;
    gboolean    gst_element_register            (GstPlugin *plugin,
                                                 const gchar *name,
                                                 guint rank,
                                                 GType type);
    GstElementFactory* gst_element_factory_find (const gchar *name);
    GType       gst_element_factory_get_element_type
                                                (GstElementFactory *factory);
    const gchar* gst_element_factory_get_longname
                                                (GstElementFactory *factory);
    const gchar* gst_element_factory_get_klass  (GstElementFactory *factory);
    const gchar* gst_element_factory_get_description
                                                (GstElementFactory *factory);
    const gchar* gst_element_factory_get_author (GstElementFactory *factory);
    guint       gst_element_factory_get_num_pad_templates
                                                (GstElementFactory *factory);
    const GList* gst_element_factory_get_pad_templates
                                                (GstElementFactory *factory);
    guint       gst_element_factory_get_uri_type
                                                (GstElementFactory *factory);
    gchar**     gst_element_factory_get_uri_protocols
                                                (GstElementFactory *factory);
    GstElement* gst_element_factory_create      (GstElementFactory *factory,
                                                 const gchar *name);
    GstElement* gst_element_factory_make        (const gchar *factoryname,
                                                 const gchar *name);
    gboolean    gst_element_factory_can_src_caps
                                                (GstElementFactory *factory,
                                                 const GstCaps *caps);
    gboolean    gst_element_factory_can_sink_caps
                                                (GstElementFactory *factory,
                                                 const GstCaps *caps);

## Object Hierarchy

      GObject
       +----GstPluginFeature
             +----GstElementFactory

## Description

GstElementFactory is used to create instances of elements. A GstElementfactory can be added to a GstPlugin as it is also a GstPluginFeature.

Use `gst_element_factory_new()` to create a new factory which can be added to a plugin with `gst_plugin_add_feature()`.

`gst_element_factory_add_pad_template()` is used to add a padtemplate to the factory. This function will enable the application to query for elementfactories that handle a specific media type.

Use the `gst_element_factory_find()` and `gst_element_factory_create()` functions to create element instances or use `gst_element_factory_make()` as a convenient shortcut.

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

      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);
      ...

An elementfactory can be assigned a rank with `gst_element_factory_set_rank()` so that the autopluggers can select a plugin more appropriatly

## Details

### GstElementFactory

    typedef struct _GstElementFactory GstElementFactory;

### gst_element_register ()

    gboolean    gst_element_register            (GstPlugin *plugin,
                                                 const gchar *name,
                                                 guint rank,
                                                 GType type);

Create a new elementfactory capable of instantiating objects of the given type.

`plugin` : | GstPlugin to register the element with
`name` : | name of elements of this type
`rank` : | rank of element (higher rank means more importance when autoplugging)
`type` : | GType of element to register
Returns : | TRUE, if the registering succeeded, FALSE on error

### gst_element_factory_find ()

    GstElementFactory* gst_element_factory_find (const gchar *name);

Search for an element factory of the given name.

`name` : | name of factory to find
Returns : | GstElementFactory if found, NULL otherwise

### gst_element_factory_get_element_type ()

    GType       gst_element_factory_get_element_type
                                                (GstElementFactory *factory);

Get the GType for elements managed by this factory

`factory` : | factory to get managed GType from
Returns : | the GType for elements managed by this factory

### gst_element_factory_get_longname ()

    const gchar* gst_element_factory_get_longname
                                                (GstElementFactory *factory);

Gets the longname for this factory

`factory` : | a GstElementFactory
Returns : | the longname

### gst_element_factory_get_klass ()

    const gchar* gst_element_factory_get_klass  (GstElementFactory *factory);

`factory` : |
Returns : |

### gst_element_factory_get_description ()

    const gchar* gst_element_factory_get_description
                                                (GstElementFactory *factory);

Gets the description for this factory.

`factory` : | a GstElementFactory
Returns : | the description

### gst_element_factory_get_author ()

    const gchar* gst_element_factory_get_author (GstElementFactory *factory);

Gets the author for this factory.

`factory` : | a GstElementFactory
Returns : | the author

### gst_element_factory_get_num_pad_templates ()

    guint       gst_element_factory_get_num_pad_templates
                                                (GstElementFactory *factory);

Gets the number of pad_templates in this factory.

`factory` : | a GstElementFactory
Returns : | the number of pad_templates

### gst_element_factory_get_pad_templates ()

    const GList* gst_element_factory_get_pad_templates
                                                (GstElementFactory *factory);

Gets the GList of padtemplates for this factory.

`factory` : | a GstElementFactory
Returns : | the padtemplates

### gst_element_factory_get_uri_type ()

    guint       gst_element_factory_get_uri_type
                                                (GstElementFactory *factory);

Gets the type of URIs the element supports or GST_URI_UNKNOWN if none.

`factory` : | a GstElementFactory
Returns : | type of URIs this element supports

### gst_element_factory_get_uri_protocols ()

    gchar**     gst_element_factory_get_uri_protocols
                                                (GstElementFactory *factory);

Gets a NULL-terminated array of protocols this element supports or NULL, if no protocols are supported. You may not change the contents of the returned array as it is still ownt by the element factory. Use `g_strdupv()` if you want to.

`factory` : | a GstElementFactory
Returns : | the supported protocols or NULL

### gst_element_factory_create ()

    GstElement* gst_element_factory_create      (GstElementFactory *factory,
                                                 const gchar *name);

Create a new element of the type defined by the given elementfactory. It will be given the name supplied, since all elements require a name as their first argument. This call may invalidate properties of the factory it works on, so make sure not to use any previously aquired properties of the factory after the call.

`factory` : | factory to instantiate
`name` : | name of new element
Returns : | new GstElement or NULL if the element couldn't be created

### gst_element_factory_make ()

    GstElement* gst_element_factory_make        (const gchar *factoryname,
                                                 const gchar *name);

Create a new element of the type defined by the given element factory. If name is NULL, then the element will receive a guaranteed unique name, consisting of the element factory name and a number. If name is given, it will be given the name supplied.

`factoryname` : | a named factory to instantiate
`name` : | name of new element
Returns : | new GstElement or NULL if unable to create element

### gst_element_factory_can_src_caps ()

    gboolean    gst_element_factory_can_src_caps
                                                (GstElementFactory *factory,
                                                 const GstCaps *caps);

Checks if the factory can source the given capability.

`factory` : | factory to query
`caps` : | the caps to check
Returns : | true if it can src the capabilities

### gst_element_factory_can_sink_caps ()

    gboolean    gst_element_factory_can_sink_caps
                                                (GstElementFactory *factory,
                                                 const GstCaps *caps);

Checks if the factory can sink the given capability.

`factory` : | factory to query
`caps` : | the caps to check
Returns : | true if it can sink the capabilities

## See Also

GstElement, GstPlugin, GstPluginFeature, GstPadTemplate.