GstElementFactory

Name

GstElementFactory -- Create GstElements from a factory

Synopsis


#include <gst/gst.h>


struct      GstElementDetails;
GstElementFactory* gst_element_factory_new  (const gchar *name,
                                             GType type,
                                             GstElementDetails *details);
GstElementFactory* gst_element_factory_find (const gchar *name);
void        gst_element_factory_add_pad_template
                                            (GstElementFactory *elementfactory,
                                             GstPadTemplate *templ);
gboolean    gst_element_factory_can_src_caps
                                            (GstElementFactory *factory,
                                             GstCaps *caps);
gboolean    gst_element_factory_can_sink_caps
                                            (GstElementFactory *factory,
                                             GstCaps *caps);
GstElement* gst_element_factory_create      (GstElementFactory *factory,
                                             const gchar *name);
GstElement* gst_element_factory_make        (const gchar *factoryname,
                                             const gchar *name);
GstElement* gst_element_factory_make_or_warn
                                            (const gchar *factoryname,
                                             const gchar *name);
void        gst_element_factory_set_rank    (GstElementFactory *factory,
                                             guint16 rank);
#define     GST_ELEMENT_RANK_MARGINAL
#define     GST_ELEMENT_RANK_NONE
#define     GST_ELEMENT_RANK_PRIMARY
#define     GST_ELEMENT_RANK_SECONDARY

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

struct GstElementDetails

struct GstElementDetails {

  gchar *longname;              /* long, english name */
  gchar *klass;                 /* type of element, as hierarchy */
  gchar *license;               /* license element is under */
  gchar *description;           /* insights of one form or another */
  gchar *version;               /* version of the element */
  gchar *author;                /* who wrote this thing? */
  gchar *copyright;             /* copyright details (year, etc.) */
};

This struct is used to define public information about the element. It describes the element, mostly for the benefit of editors.


gst_element_factory_new ()

GstElementFactory* gst_element_factory_new  (const gchar *name,
                                             GType type,
                                             GstElementDetails *details);

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

name :

name of new elementfactory

type :

GType of new element

details :

GstElementDetails structure with element details

Returns :

new elementfactory


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_add_pad_template ()

void        gst_element_factory_add_pad_template
                                            (GstElementFactory *elementfactory,
                                             GstPadTemplate *templ);

Add the given padtemplate to this elementfactory.

elementfactory :

factory to add the src id to

templ :

the padtemplate to add


gst_element_factory_can_src_caps ()

gboolean    gst_element_factory_can_src_caps
                                            (GstElementFactory *factory,
                                             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,
                                             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


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.

factory :

factory to instantiate

name :

name of new element

Returns :

new GstElement


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_make_or_warn ()

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

Create a new element of the type defined by the given element factory using gst_element_factory_make. Will use g_warning if the element could not be created.

factoryname :

a named factory to instantiate

name :

name of new element

Returns :

new GstElement (or NULL if unable to create element)


gst_element_factory_set_rank ()

void        gst_element_factory_set_rank    (GstElementFactory *factory,
                                             guint16 rank);

Specifies a rank for the element so that autoplugging uses the most appropriate elements.

factory :

factory to rank

rank :

rank value - higher number means more priority rank


GST_ELEMENT_RANK_MARGINAL

#define GST_ELEMENT_RANK_MARGINAL   64

The element is only marginally usefull for autoplugging


GST_ELEMENT_RANK_NONE

#define GST_ELEMENT_RANK_NONE       0

The plugin may not be used in autoplugging


GST_ELEMENT_RANK_PRIMARY

#define GST_ELEMENT_RANK_PRIMARY    256

The plugin is well suited for autoplugging


GST_ELEMENT_RANK_SECONDARY

#define GST_ELEMENT_RANK_SECONDARY  128

The plugin is suited for autoplugging but only as a second candidate.

See Also

GstElement, GstPlugin, GstPluginFeature, GstPadTemplate.