GstElementFactory

GstElementFactory — Create GstElements from a factory

Synopsis

#include <gst/gst.h>

struct              GstElementFactory;
struct              GstElementDetails;
#define             GST_ELEMENT_DETAILS                 (longname,
                                                         klass,
                                                         description,
                                                         author)
#define             GST_IS_ELEMENT_DETAILS              (details)
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);
const gchar *            gst_element_factory_get_documentation_uri
                                                        (GstElementFactory *factory);
const gchar *            gst_element_factory_get_icon_name
                                                        (GstElementFactory *factory);
guint               gst_element_factory_get_num_pad_templates
                                                        (GstElementFactory *factory);
gint                gst_element_factory_get_uri_type    (GstElementFactory *factory);
gchar **                 gst_element_factory_get_uri_protocols
                                                        (GstElementFactory *factory);
gboolean            gst_element_factory_has_interface   (GstElementFactory *factory,
                                                         const gchar *interfacename);
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_sink_caps   (GstElementFactory *factory,
                                                         const GstCaps *caps);
gboolean            gst_element_factory_can_src_caps    (GstElementFactory *factory,
                                                         const GstCaps *caps);
gboolean            gst_element_factory_can_sink_all_caps
                                                        (GstElementFactory *factory,
                                                         const GstCaps *caps);
gboolean            gst_element_factory_can_src_all_caps
                                                        (GstElementFactory *factory,
                                                         const GstCaps *caps);
gboolean            gst_element_factory_can_sink_any_caps
                                                        (GstElementFactory *factory,
                                                         const GstCaps *caps);
gboolean            gst_element_factory_can_src_any_caps
                                                        (GstElementFactory *factory,
                                                         const GstCaps *caps);
const GList *            gst_element_factory_get_static_pad_templates
                                                        (GstElementFactory *factory);
typedef             GstElementFactoryListType;
#define             GST_ELEMENT_FACTORY_TYPE_ANY
#define             GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS
#define             GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER
#define             GST_ELEMENT_FACTORY_TYPE_DECODABLE
#define             GST_ELEMENT_FACTORY_TYPE_DECODER
#define             GST_ELEMENT_FACTORY_TYPE_DEMUXER
#define             GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER
#define             GST_ELEMENT_FACTORY_TYPE_ENCODER
#define             GST_ELEMENT_FACTORY_TYPE_FORMATTER
#define             GST_ELEMENT_FACTORY_TYPE_MAX_ELEMENTS
#define             GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO
#define             GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE
#define             GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA
#define             GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE
#define             GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO
#define             GST_ELEMENT_FACTORY_TYPE_MEDIA_ANY
#define             GST_ELEMENT_FACTORY_TYPE_MUXER
#define             GST_ELEMENT_FACTORY_TYPE_PARSER
#define             GST_ELEMENT_FACTORY_TYPE_PAYLOADER
#define             GST_ELEMENT_FACTORY_TYPE_SINK
#define             GST_ELEMENT_FACTORY_TYPE_SRC
#define             GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER
GList *             gst_element_factory_list_filter     (GList *list,
                                                         const GstCaps *caps,
                                                         GstPadDirection direction,
                                                         gboolean subsetonly);
GList *             gst_element_factory_list_get_elements
                                                        (GstElementFactoryListType type,
                                                         GstRank minrank);
gboolean            gst_element_factory_list_is_type    (GstElementFactory *factory,
                                                         GstElementFactoryListType type);

Object Hierarchy

  GObject
   +----GstObject
         +----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 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.

Example 9. Using an element factory

1
2
3
4
5
6
7
8
9
10
11
12
#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);
...


Last reviewed on 2005-11-23 (0.9.5)

Details

struct GstElementFactory

struct GstElementFactory;

The opaque GstElementFactory data structure.


struct GstElementDetails

struct GstElementDetails {
  gchar *longname;
  gchar *klass;
  gchar *description;
  gchar *author;
};

This struct defines the public information about a GstElement. It contains meta-data about the element that is mostly for the benefit of editors.

The klass member can be used by applications to filter elements based on functionality.

gchar *longname;

long, english name

gchar *klass;

string describing the type of element, as an unordered list separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types

gchar *description;

what the element is about

gchar *author;

who wrote this thing?

GST_ELEMENT_DETAILS()

#define             GST_ELEMENT_DETAILS(longname,klass,description,author)

Macro to initialize GstElementDetails.

longname :

long, english name

klass :

string describing the type of element, as an unordered list separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types

description :

what the element is about

author :

who wrote this element

GST_IS_ELEMENT_DETAILS()

#define             GST_IS_ELEMENT_DETAILS(details)

Tests if element details are initialized.

details :

the GstElementDetails to check

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 type and add the factory to plugin.

plugin :

GstPlugin to register the element with, or NULL for a static element (note that passing NULL only works in GStreamer 0.10.13 and later). [allow-none]

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. Refs the returned element factory; caller is responsible for unreffing.

name :

name of factory to find

Returns :

GstElementFactory if found, NULL otherwise. [transfer full]

gst_element_factory_get_element_type ()

GType               gst_element_factory_get_element_type
                                                        (GstElementFactory *factory);

Get the GType for elements managed by this factory. The type can only be retrieved if the element factory is loaded, which can be assured with gst_plugin_feature_load().

factory :

factory to get managed GType from

Returns :

the GType for elements managed by this factory or 0 if the factory is not loaded.

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

Gets the class for this factory.

factory :

a GstElementFactory

Returns :

the class

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

const gchar *            gst_element_factory_get_documentation_uri
                                                        (GstElementFactory *factory);

Gets documentation uri for this factory if set.

factory :

a GstElementFactory

Returns :

the documentation uri

Since 0.10.31


gst_element_factory_get_icon_name ()

const gchar *            gst_element_factory_get_icon_name
                                                        (GstElementFactory *factory);

Gets icon name for this factory if set.

factory :

a GstElementFactory

Returns :

the icon name

Since 0.10.31


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

gint                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 owned by the element factory. Use g_strdupv() to make a copy of the protocol string array if you need to.

factory :

a GstElementFactory

Returns :

the supported protocols or NULL. [transfer none][array zero-terminated=1]

gst_element_factory_has_interface ()

gboolean            gst_element_factory_has_interface   (GstElementFactory *factory,
                                                         const gchar *interfacename);

Check if factory implements the interface with name interfacename.

factory :

a GstElementFactory

interfacename :

an interface name

Returns :

TRUE when factory implement the interface.

Since 0.10.14


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 or NULL if the element couldn't be created. [transfer full]

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. [allow-none]

Returns :

new GstElement or NULL if unable to create element. [transfer full]

gst_element_factory_can_sink_caps ()

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

Warning

gst_element_factory_can_sink_caps is deprecated and should not be used in newly-written code. use gst_element_factory_can_sink_all_caps() instead.

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

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

Warning

gst_element_factory_can_src_caps is deprecated and should not be used in newly-written code. use gst_element_factory_can_src_all_caps() instead.

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

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

Checks if the factory can sink all possible capabilities.

factory :

factory to query

caps :

the caps to check

Returns :

TRUE if the caps are fully compatible.

Since 0.10.33


gst_element_factory_can_src_all_caps ()

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

Checks if the factory can src all possible capabilities.

factory :

factory to query

caps :

the caps to check

Returns :

TRUE if the caps are fully compatible.

Since 0.10.33


gst_element_factory_can_sink_any_caps ()

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

Checks if the factory can sink any possible capability.

factory :

factory to query

caps :

the caps to check

Returns :

TRUE if the caps have a common subset.

Since 0.10.33


gst_element_factory_can_src_any_caps ()

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

Checks if the factory can src any possible capability.

factory :

factory to query

caps :

the caps to check

Returns :

TRUE if the caps have a common subset.

Since 0.10.33


gst_element_factory_get_static_pad_templates ()

const GList *            gst_element_factory_get_static_pad_templates
                                                        (GstElementFactory *factory);

Gets the GList of GstStaticPadTemplate for this factory.

factory :

a GstElementFactory

Returns :

the static pad templates. [transfer none][element-type Gst.StaticPadTemplate]

GstElementFactoryListType

typedef guint64 GstElementFactoryListType;

GST_ELEMENT_FACTORY_TYPE_ANY

#define  GST_ELEMENT_FACTORY_TYPE_ANY ((G_GUINT64_CONSTANT (1) << 49) - 1)

Elements of any of the defined GST_ELEMENT_FACTORY_LIST types

Since 0.10.31


GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS

#define GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS (GST_ELEMENT_FACTORY_TYPE_SINK | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO | GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO | GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)

All sinks handling audio, video or image media types

Since 0.10.31


GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER

#define GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER (GST_ELEMENT_FACTORY_TYPE_ENCODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO)

All encoders handling audio media types

Since 0.10.31


GST_ELEMENT_FACTORY_TYPE_DECODABLE

#define             GST_ELEMENT_FACTORY_TYPE_DECODABLE

All elements used to 'decode' streams (decoders, demuxers, parsers, depayloaders)

Since 0.10.31


GST_ELEMENT_FACTORY_TYPE_DECODER

#define  GST_ELEMENT_FACTORY_TYPE_DECODER        (G_GUINT64_CONSTANT (1) << 0)

GST_ELEMENT_FACTORY_TYPE_DEMUXER

#define  GST_ELEMENT_FACTORY_TYPE_DEMUXER        (G_GUINT64_CONSTANT (1) << 5)

GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER

#define  GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER    (G_GUINT64_CONSTANT (1) << 8)

GST_ELEMENT_FACTORY_TYPE_ENCODER

#define  GST_ELEMENT_FACTORY_TYPE_ENCODER        (G_GUINT64_CONSTANT (1) << 1)

GST_ELEMENT_FACTORY_TYPE_FORMATTER

#define  GST_ELEMENT_FACTORY_TYPE_FORMATTER      (G_GUINT64_CONSTANT (1) << 9)

GST_ELEMENT_FACTORY_TYPE_MAX_ELEMENTS

#define  GST_ELEMENT_FACTORY_TYPE_MAX_ELEMENTS   (G_GUINT64_CONSTANT (1) << 48)

GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO

#define  GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO    (G_GUINT64_CONSTANT (1) << 50)

GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE

#define  GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE    (G_GUINT64_CONSTANT (1) << 51)

GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA

#define  GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA (G_GUINT64_CONSTANT (1) << 53)

GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE

#define  GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE (G_GUINT64_CONSTANT (1) << 52)

GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO

#define  GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO    (G_GUINT64_CONSTANT (1) << 49)

GST_ELEMENT_FACTORY_TYPE_MEDIA_ANY

#define GST_ELEMENT_FACTORY_TYPE_MEDIA_ANY (~G_GUINT64_CONSTANT (0) << 48)

Elements matching any of the defined GST_ELEMENT_FACTORY_TYPE_MEDIA types

Note: Do not use this if you wish to not filter against any of the defined media types. If you wish to do this, simply don't specify any GST_ELEMENT_FACTORY_TYPE_MEDIA flag.

Since 0.10.31


GST_ELEMENT_FACTORY_TYPE_MUXER

#define  GST_ELEMENT_FACTORY_TYPE_MUXER          (G_GUINT64_CONSTANT (1) << 4)

GST_ELEMENT_FACTORY_TYPE_PARSER

#define  GST_ELEMENT_FACTORY_TYPE_PARSER         (G_GUINT64_CONSTANT (1) << 6)

GST_ELEMENT_FACTORY_TYPE_PAYLOADER

#define  GST_ELEMENT_FACTORY_TYPE_PAYLOADER      (G_GUINT64_CONSTANT (1) << 7)

GST_ELEMENT_FACTORY_TYPE_SINK

#define  GST_ELEMENT_FACTORY_TYPE_SINK           (G_GUINT64_CONSTANT (1) << 2)

GST_ELEMENT_FACTORY_TYPE_SRC

#define  GST_ELEMENT_FACTORY_TYPE_SRC            (G_GUINT64_CONSTANT (1) << 3)

GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER

#define GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER (GST_ELEMENT_FACTORY_TYPE_ENCODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO | GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)

All encoders handling video or image media types

Since 0.10.31


gst_element_factory_list_filter ()

GList *             gst_element_factory_list_filter     (GList *list,
                                                         const GstCaps *caps,
                                                         GstPadDirection direction,
                                                         gboolean subsetonly);

Filter out all the elementfactories in list that can handle caps in the given direction.

If subsetonly is TRUE, then only the elements whose pads templates are a complete superset of caps will be returned. Else any element whose pad templates caps can intersect with caps will be returned.

list :

a GList of GstElementFactory to filter. [transfer none][element-type Gst.ElementFactory]

caps :

a GstCaps

direction :

a GstPadDirection to filter on

subsetonly :

whether to filter on caps subsets or not.

Returns :

a GList of GstElementFactory elements that match the given requisits. Use gst_plugin_feature_list_free after usage. [transfer full][element-type Gst.ElementFactory]

Since 0.10.31


gst_element_factory_list_get_elements ()

GList *             gst_element_factory_list_get_elements
                                                        (GstElementFactoryListType type,
                                                         GstRank minrank);

Get a list of factories that match the given type. Only elements with a rank greater or equal to minrank will be returned. The list of factories is returned by decreasing rank.

type :

a GstElementFactoryListType

minrank :

Minimum rank

Returns :

a GList of GstElementFactory elements. Use gst_plugin_feature_list_free() after usage. [transfer full][element-type Gst.ElementFactory]

Since 0.10.31


gst_element_factory_list_is_type ()

gboolean            gst_element_factory_list_is_type    (GstElementFactory *factory,
                                                         GstElementFactoryListType type);

Check if factory if of the given types.

factory :

a GstElementFactory

type :

a GstElementFactoryListType

Returns :

TRUE if factory is of type.

Since 0.10.31

See Also

GstElement, GstPlugin, GstPluginFeature, GstPadTemplate.