GstElement: GStreamer 1.0 Core Reference Manual

## GstElement GstElement |

## Functions

#define | GST_STATE()
#define | GST_STATE_GET_NEXT()
#define | GST_STATE_NEXT()
#define | GST_STATE_PENDING()
#define | GST_STATE_RETURN()
#define | GST_STATE_TARGET()
#define | GST_STATE_TRANSITION()
#define | GST_STATE_TRANSITION_CURRENT()
#define | GST_STATE_TRANSITION_NEXT()
#define | GST_STATE_GET_LOCK()
#define | GST_STATE_GET_COND()
#define | GST_ELEMENT_NAME()
#define | GST_ELEMENT_PARENT()
#define | GST_ELEMENT_BUS()
#define | GST_ELEMENT_CLOCK()
#define | GST_ELEMENT_PADS()
#define | GST_ELEMENT_START_TIME()
#define | GST_ELEMENT_ERROR()
#define | GST_ELEMENT_WARNING()
#define | GST_ELEMENT_INFO()
#define | GST_ELEMENT_IS_LOCKED_STATE()
void | gst_element_class_add_pad_template ()
void | gst_element_class_add_static_pad_template ()
GstPadTemplate * | gst_element_class_get_pad_template ()
GList * | gst_element_class_get_pad_template_list ()
void | gst_element_class_set_metadata ()
void | gst_element_class_set_static_metadata ()
void | gst_element_class_add_metadata ()
void | gst_element_class_add_static_metadata ()
gboolean | gst_element_add_pad ()
void | gst_element_create_all_pads ()
GstPad * | gst_element_get_compatible_pad ()
GstPadTemplate * | gst_element_get_compatible_pad_template ()
GstPad * | gst_element_get_request_pad ()
GstPad * | gst_element_get_static_pad ()
GstPad * | gst_element_request_pad ()
void | gst_element_no_more_pads ()
void | gst_element_release_request_pad ()
gboolean | gst_element_remove_pad ()
GstIterator * | gst_element_iterate_pads ()
GstIterator * | gst_element_iterate_sink_pads ()
GstIterator * | gst_element_iterate_src_pads ()
gboolean | gst_element_link ()
void | gst_element_unlink ()
gboolean | gst_element_link_many ()
void | gst_element_unlink_many ()
gboolean | gst_element_link_pads ()
gboolean | gst_element_link_pads_full ()
void | gst_element_unlink_pads ()
gboolean | gst_element_link_pads_filtered ()
gboolean | gst_element_link_filtered ()
const gchar * | gst_element_class_get_metadata ()
void | gst_element_set_base_time ()
GstClockTime | gst_element_get_base_time ()
void | gst_element_set_start_time ()
GstClockTime | gst_element_get_start_time ()
void | gst_element_set_bus ()
GstBus * | gst_element_get_bus ()
void | gst_element_set_context ()
GstContext * | gst_element_get_context ()
GstContext * | gst_element_get_context_unlocked ()
GList * | gst_element_get_contexts ()
GstElementFactory * | gst_element_get_factory ()
#define | gst_element_set_name()
#define | gst_element_get_name()
#define | gst_element_set_parent()
#define | gst_element_get_parent()
gboolean | gst_element_set_clock ()
GstClock * | gst_element_get_clock ()
GstClock * | gst_element_provide_clock ()
GstStateChangeReturn | gst_element_set_state ()
GstStateChangeReturn | gst_element_get_state ()
gboolean | gst_element_set_locked_state ()
gboolean | gst_element_is_locked_state ()
void | gst_element_abort_state ()
GstStateChangeReturn | gst_element_continue_state ()
void | gst_element_lost_state ()
const gchar * | gst_element_state_get_name ()
const gchar * | gst_element_state_change_return_get_name ()
gboolean | gst_element_sync_state_with_parent ()
GstStateChangeReturn | gst_element_change_state ()
void | gst_element_message_full ()
gboolean | gst_element_post_message ()
gboolean | gst_element_query ()
gboolean | gst_element_query_convert ()
gboolean | gst_element_query_position ()
gboolean | gst_element_query_duration ()
gboolean | gst_element_send_event ()
gboolean | gst_element_seek_simple ()
gboolean | gst_element_seek ()
gulong | gst_element_add_property_notify_watch ()
gulong | gst_element_add_property_deep_notify_watch ()
void | gst_element_remove_property_notify_watch ()
void | (*GstElementCallAsyncFunc) ()
void | gst_element_call_async ()

## Signals

void | no-more-pads | Run Last
void | pad-added | Run Last
void | pad-removed | Run Last

## Types and Values

struct | GstElement
struct | GstElementClass
enum | GstElementFlags
enum | GstState
enum | GstStateChange
enum | GstStateChangeReturn
#define | GST_ELEMENT_METADATA_AUTHOR
#define | GST_ELEMENT_METADATA_DESCRIPTION
#define | GST_ELEMENT_METADATA_DOC_URI
#define | GST_ELEMENT_METADATA_ICON_NAME
#define | GST_ELEMENT_METADATA_KLASS
#define | GST_ELEMENT_METADATA_LONGNAME

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstElement
                    ╰── GstBin

## Known Derived Interfaces

GstElement is required by GstTagSetter.

## Includes

    #include <gst/gst.h>

## Description

## Functions

### GST_STATE()

    #define GST_STATE(elem)                 (GST_ELEMENT_CAST(elem)->current_state)

### GST_STATE_GET_NEXT()

    #define GST_STATE_GET_NEXT(cur,pending)         ((GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur))))

### GST_STATE_NEXT()

    #define GST_STATE_NEXT(elem)            (GST_ELEMENT_CAST(elem)->next_state)

### GST_STATE_PENDING()

    #define GST_STATE_PENDING(elem)         (GST_ELEMENT_CAST(elem)->pending_state)

### GST_STATE_RETURN()

    #define GST_STATE_RETURN(elem)          (GST_ELEMENT_CAST(elem)->last_return)

### GST_STATE_TARGET()

    #define GST_STATE_TARGET(elem)          (GST_ELEMENT_CAST(elem)->target_state)

### GST_STATE_TRANSITION()

    #define GST_STATE_TRANSITION(cur,next)          ((GstStateChange)(((cur)<<3)|(next)))

### GST_STATE_TRANSITION_CURRENT()

    #define GST_STATE_TRANSITION_CURRENT(trans)     ((GstState)((trans)>>3))

### GST_STATE_TRANSITION_NEXT()

    #define GST_STATE_TRANSITION_NEXT(trans)        ((GstState)((trans)&0x7))

### GST_STATE_GET_LOCK()

    #define GST_STATE_GET_LOCK(elem)               (&(GST_ELEMENT_CAST(elem)->state_lock))

### GST_STATE_GET_COND()

    #define GST_STATE_GET_COND(elem)               (&GST_ELEMENT_CAST(elem)->state_cond)

### GST_ELEMENT_NAME()

    #define GST_ELEMENT_NAME(elem)                  (GST_OBJECT_NAME(elem))

### GST_ELEMENT_PARENT()

    #define GST_ELEMENT_PARENT(elem)                (GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem)))

### GST_ELEMENT_BUS()

    #define GST_ELEMENT_BUS(elem)                   (GST_ELEMENT_CAST(elem)->bus)

### GST_ELEMENT_CLOCK()

    #define GST_ELEMENT_CLOCK(elem)                 (GST_ELEMENT_CAST(elem)->clock)

### GST_ELEMENT_PADS()

    #define GST_ELEMENT_PADS(elem)                  (GST_ELEMENT_CAST(elem)->pads)

### GST_ELEMENT_START_TIME()

    #define GST_ELEMENT_START_TIME(elem)            (GST_ELEMENT_CAST(elem)->start_time)

### GST_ELEMENT_ERROR()

    #define             GST_ELEMENT_ERROR(el, domain, code, text, debug)

### GST_ELEMENT_WARNING()

    #define             GST_ELEMENT_WARNING(el, domain, code, text, debug)

### GST_ELEMENT_INFO()

    #define             GST_ELEMENT_INFO(el, domain, code, text, debug)

### GST_ELEMENT_IS_LOCKED_STATE()

    #define GST_ELEMENT_IS_LOCKED_STATE(elem)        (GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_FLAG_LOCKED_STATE))

### gst_element_class_add_pad_template ()

    void
    gst_element_class_add_pad_template (GstElementClass *klass,
                                        GstPadTemplate *templ);

### gst_element_class_add_static_pad_template ()

    void
    gst_element_class_add_static_pad_template
                                   (GstElementClass *klass,
                                    GstStaticPadTemplate *static_templ);

### gst_element_class_get_pad_template ()

    GstPadTemplate *
    gst_element_class_get_pad_template (GstElementClass *element_class,
                                        const gchar *name);

### gst_element_class_get_pad_template_list ()

    GList *
    gst_element_class_get_pad_template_list
                                   (GstElementClass *element_class);

### gst_element_class_set_metadata ()

    void
    gst_element_class_set_metadata (GstElementClass *klass,
                                    const gchar *longname,
                                    const gchar *classification,
                                    const gchar *description,
                                    const gchar *author);

### gst_element_class_set_static_metadata ()

    void
    gst_element_class_set_static_metadata (GstElementClass *klass,
                                           const gchar *longname,
                                           const gchar *classification,
                                           const gchar *description,
                                           const gchar *author);

### gst_element_class_add_metadata ()

    void
    gst_element_class_add_metadata (GstElementClass *klass,
                                    const gchar *key,
                                    const gchar *value);

### gst_element_class_add_static_metadata ()

    void
    gst_element_class_add_static_metadata (GstElementClass *klass,
                                           const gchar *key,
                                           const gchar *value);

### gst_element_add_pad ()

    gboolean
    gst_element_add_pad (GstElement *element,
                         GstPad *pad);

### gst_element_create_all_pads ()

    void
    gst_element_create_all_pads (GstElement *element);

### gst_element_get_compatible_pad ()

    GstPad *
    gst_element_get_compatible_pad (GstElement *element,
                                    GstPad *pad,
                                    GstCaps *caps);

### gst_element_get_compatible_pad_template ()

    GstPadTemplate *
    gst_element_get_compatible_pad_template
                                   (GstElement *element,
                                    GstPadTemplate *compattempl);

### gst_element_get_request_pad ()

    GstPad *
    gst_element_get_request_pad (GstElement *element,
                                 const gchar *name);

### gst_element_get_static_pad ()

    GstPad *
    gst_element_get_static_pad (GstElement *element,
                                const gchar *name);

### gst_element_request_pad ()

    GstPad *
    gst_element_request_pad (GstElement *element,
                             GstPadTemplate *templ,
                             const gchar *name,
                             const GstCaps *caps);

### gst_element_no_more_pads ()

    void
    gst_element_no_more_pads (GstElement *element);

### gst_element_release_request_pad ()

    void
    gst_element_release_request_pad (GstElement *element,
                                     GstPad *pad);

### gst_element_remove_pad ()

    gboolean
    gst_element_remove_pad (GstElement *element,
                            GstPad *pad);

### gst_element_iterate_pads ()

    GstIterator *
    gst_element_iterate_pads (GstElement *element);

### gst_element_iterate_sink_pads ()

    GstIterator *
    gst_element_iterate_sink_pads (GstElement *element);

### gst_element_iterate_src_pads ()

    GstIterator *
    gst_element_iterate_src_pads (GstElement *element);

### gst_element_link ()

    gboolean
    gst_element_link (GstElement *src,
                      GstElement *dest);

### gst_element_unlink ()

    void
    gst_element_unlink (GstElement *src,
                        GstElement *dest);

### gst_element_link_many ()

    gboolean
    gst_element_link_many (GstElement *element_1,
                           GstElement *element_2,
                           ...);

### gst_element_unlink_many ()

    void
    gst_element_unlink_many (GstElement *element_1,
                             GstElement *element_2,
                             ...);

### gst_element_link_pads ()

    gboolean
    gst_element_link_pads (GstElement *src,
                           const gchar *srcpadname,
                           GstElement *dest,
                           const gchar *destpadname);

### gst_element_link_pads_full ()

    gboolean
    gst_element_link_pads_full (GstElement *src,
                                const gchar *srcpadname,
                                GstElement *dest,
                                const gchar *destpadname,
                                GstPadLinkCheck flags);

### gst_element_unlink_pads ()

    void
    gst_element_unlink_pads (GstElement *src,
                             const gchar *srcpadname,
                             GstElement *dest,
                             const gchar *destpadname);

### gst_element_link_pads_filtered ()

    gboolean
    gst_element_link_pads_filtered (GstElement *src,
                                    const gchar *srcpadname,
                                    GstElement *dest,
                                    const gchar *destpadname,
                                    GstCaps *filter);

### gst_element_link_filtered ()

    gboolean
    gst_element_link_filtered (GstElement *src,
                               GstElement *dest,
                               GstCaps *filter);

### gst_element_class_get_metadata ()

    const gchar *
    gst_element_class_get_metadata (GstElementClass *klass,
                                    const gchar *key);

### gst_element_set_base_time ()

    void
    gst_element_set_base_time (GstElement *element,
                               GstClockTime time);

### gst_element_get_base_time ()

    GstClockTime
    gst_element_get_base_time (GstElement *element);

### gst_element_set_start_time ()

    void
    gst_element_set_start_time (GstElement *element,
                                GstClockTime time);

### gst_element_get_start_time ()

    GstClockTime
    gst_element_get_start_time (GstElement *element);

### gst_element_set_bus ()

    void
    gst_element_set_bus (GstElement *element,
                         GstBus *bus);

### gst_element_get_bus ()

    GstBus *
    gst_element_get_bus (GstElement *element);

### gst_element_set_context ()

    void
    gst_element_set_context (GstElement *element,
                             GstContext *context);

### gst_element_get_context ()

    GstContext *
    gst_element_get_context (GstElement *element,
                             const gchar *context_type);

### gst_element_get_context_unlocked ()

    GstContext *
    gst_element_get_context_unlocked (GstElement *element,
                                      const gchar *context_type);

### gst_element_get_contexts ()

    GList *
    gst_element_get_contexts (GstElement *element);

### gst_element_get_factory ()

    GstElementFactory *
    gst_element_get_factory (GstElement *element);

### gst_element_set_name()

    #define                 gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT_CAST(elem),name)

### gst_element_get_name()

    #define                 gst_element_get_name(elem)      gst_object_get_name(GST_OBJECT_CAST(elem))

### gst_element_set_parent()

    #define                 gst_element_set_parent(elem,parent)     gst_object_set_parent(GST_OBJECT_CAST(elem),parent)

### gst_element_get_parent()

    #define                 gst_element_get_parent(elem)    gst_object_get_parent(GST_OBJECT_CAST(elem))

### gst_element_set_clock ()

    gboolean
    gst_element_set_clock (GstElement *element,
                           GstClock *clock);

### gst_element_get_clock ()

    GstClock *
    gst_element_get_clock (GstElement *element);

### gst_element_provide_clock ()

    GstClock *
    gst_element_provide_clock (GstElement *element);

### gst_element_set_state ()

    GstStateChangeReturn
    gst_element_set_state (GstElement *element,
                           GstState state);

### gst_element_get_state ()

    GstStateChangeReturn
    gst_element_get_state (GstElement *element,
                           GstState *state,
                           GstState *pending,
                           GstClockTime timeout);

### gst_element_set_locked_state ()

    gboolean
    gst_element_set_locked_state (GstElement *element,
                                  gboolean locked_state);

### gst_element_is_locked_state ()

    gboolean
    gst_element_is_locked_state (GstElement *element);

### gst_element_abort_state ()

    void
    gst_element_abort_state (GstElement *element);

### gst_element_continue_state ()

    GstStateChangeReturn
    gst_element_continue_state (GstElement *element,
                                GstStateChangeReturn ret);

### gst_element_lost_state ()

    void
    gst_element_lost_state (GstElement *element);

### gst_element_state_get_name ()

    const gchar *
    gst_element_state_get_name (GstState state);

### gst_element_state_change_return_get_name ()

    const gchar *
    gst_element_state_change_return_get_name
                                   (GstStateChangeReturn state_ret);

### gst_element_sync_state_with_parent ()

    gboolean
    gst_element_sync_state_with_parent (GstElement *element);

### gst_element_change_state ()

    GstStateChangeReturn
    gst_element_change_state (GstElement *element,
                              GstStateChange transition);

### gst_element_message_full ()

    void
    gst_element_message_full (GstElement *element,
                              GstMessageType type,
                              GQuark domain,
                              gint code,
                              gchar *text,
                              gchar *debug,
                              const gchar *file,
                              const gchar *function,
                              gint line);

### gst_element_post_message ()

    gboolean
    gst_element_post_message (GstElement *element,
                              GstMessage *message);

### gst_element_query ()

    gboolean
    gst_element_query (GstElement *element,
                       GstQuery *query);

### gst_element_query_convert ()

    gboolean
    gst_element_query_convert (GstElement *element,
                               GstFormat src_format,
                               gint64 src_val,
                               GstFormat dest_format,
                               gint64 *dest_val);

### gst_element_query_position ()

    gboolean
    gst_element_query_position (GstElement *element,
                                GstFormat format,
                                gint64 *cur);

### gst_element_query_duration ()

    gboolean
    gst_element_query_duration (GstElement *element,
                                GstFormat format,
                                gint64 *duration);

### gst_element_send_event ()

    gboolean
    gst_element_send_event (GstElement *element,
                            GstEvent *event);

### gst_element_seek_simple ()

    gboolean
    gst_element_seek_simple (GstElement *element,
                             GstFormat format,
                             GstSeekFlags seek_flags,
                             gint64 seek_pos);

### gst_element_seek ()

    gboolean
    gst_element_seek (GstElement *element,
                      gdouble rate,
                      GstFormat format,
                      GstSeekFlags flags,
                      GstSeekType start_type,
                      gint64 start,
                      GstSeekType stop_type,
                      gint64 stop);

### gst_element_add_property_notify_watch ()

    gulong
    gst_element_add_property_notify_watch (GstElement *element,
                                           const gchar *property_name,
                                           gboolean include_value);

### gst_element_add_property_deep_notify_watch ()

    gulong
    gst_element_add_property_deep_notify_watch
                                   (GstElement *element,
                                    const gchar *property_name,
                                    gboolean include_value);

### gst_element_remove_property_notify_watch ()

    void
    gst_element_remove_property_notify_watch
                                   (GstElement *element,
                                    gulong watch_id);

### GstElementCallAsyncFunc ()

    void
    (*GstElementCallAsyncFunc) (GstElement *element,
                                gpointer user_data);

### gst_element_call_async ()

    void
    gst_element_call_async (GstElement *element,
                            GstElementCallAsyncFunc func,
                            gpointer user_data,
                            GDestroyNotify destroy_notify);

## Types and Values

### struct GstElement

    struct GstElement {
      GRecMutex             state_lock;

      /* element state */
      GCond                 state_cond;
      guint32               state_cookie;
      GstState              target_state;
      GstState              current_state;
      GstState              next_state;
      GstState              pending_state;
      GstStateChangeReturn  last_return;

      GstBus               *bus;

      /* allocated clock */
      GstClock             *clock;
      GstClockTimeDiff      base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
      GstClockTime          start_time;

      /* element pads, these lists can only be iterated while holding
       * the LOCK or checking the cookie after each LOCK. */
      guint16               numpads;
      GList                *pads;
      guint16               numsrcpads;
      GList                *srcpads;
      guint16               numsinkpads;
      GList                *sinkpads;
      guint32               pads_cookie;

      /* with object LOCK */
      GList                *contexts;
    };

### struct GstElementClass

    struct GstElementClass {
      GstObjectClass         parent_class;

      /* the element metadata */
      gpointer		 metadata;

      /* factory that the element was created from */
      GstElementFactory     *elementfactory;

      /* templates for our pads */
      GList                 *padtemplates;
      gint                   numpadtemplates;
      guint32                pad_templ_cookie;

      /* virtual methods for subclasses */

      /* request/release pads */
      /* FIXME 2.0 harmonize naming with gst_element_request_pad */
      GstPad*               (*request_new_pad)      (GstElement *element, GstPadTemplate *templ,
                                                     const gchar* name, const GstCaps *caps);

      void                  (*release_pad)          (GstElement *element, GstPad *pad);

      /* state changes */
      GstStateChangeReturn (*get_state)             (GstElement * element, GstState * state,
                                                     GstState * pending, GstClockTime timeout);
      GstStateChangeReturn (*set_state)             (GstElement *element, GstState state);
      GstStateChangeReturn (*change_state)          (GstElement *element, GstStateChange transition);
      void                 (*state_changed)         (GstElement *element, GstState oldstate,
                                                     GstState newstate, GstState pending);

      /* bus */
      void                  (*set_bus)              (GstElement * element, GstBus * bus);

      /* set/get clocks */
      GstClock*             (*provide_clock)        (GstElement *element);
      gboolean              (*set_clock)            (GstElement *element, GstClock *clock);

      /* query functions */
      gboolean              (*send_event)           (GstElement *element, GstEvent *event);

      gboolean              (*query)                (GstElement *element, GstQuery *query);

      gboolean              (*post_message)         (GstElement *element, GstMessage *message);

      void                  (*set_context)          (GstElement *element, GstContext *context);
    };

### enum GstElementFlags

#### Members

GST_ELEMENT_FLAG_LOCKED_STATE |  |
GST_ELEMENT_FLAG_SINK |  |
GST_ELEMENT_FLAG_SOURCE |  |
GST_ELEMENT_FLAG_PROVIDE_CLOCK |  |
GST_ELEMENT_FLAG_REQUIRE_CLOCK |  |
GST_ELEMENT_FLAG_INDEXABLE |  |
GST_ELEMENT_FLAG_LAST |  |

### enum GstState

#### Members

GST_STATE_VOID_PENDING |  |
GST_STATE_NULL |  |
GST_STATE_READY |  |
GST_STATE_PAUSED |  |
GST_STATE_PLAYING |  |

### enum GstStateChange

#### Members

GST_STATE_CHANGE_NULL_TO_READY |  |
GST_STATE_CHANGE_READY_TO_PAUSED |  |
GST_STATE_CHANGE_PAUSED_TO_PLAYING |  |
GST_STATE_CHANGE_PLAYING_TO_PAUSED |  |
GST_STATE_CHANGE_PAUSED_TO_READY |  |
GST_STATE_CHANGE_READY_TO_NULL |  |

### enum GstStateChangeReturn

#### Members

GST_STATE_CHANGE_FAILURE |  |
GST_STATE_CHANGE_SUCCESS |  |
GST_STATE_CHANGE_ASYNC |  |
GST_STATE_CHANGE_NO_PREROLL |  |

### GST_ELEMENT_METADATA_AUTHOR

    #define GST_ELEMENT_METADATA_AUTHOR        "author"

### GST_ELEMENT_METADATA_DESCRIPTION

    #define GST_ELEMENT_METADATA_DESCRIPTION   "description"

### GST_ELEMENT_METADATA_DOC_URI

    #define GST_ELEMENT_METADATA_DOC_URI       "doc-uri"

### GST_ELEMENT_METADATA_ICON_NAME

    #define GST_ELEMENT_METADATA_ICON_NAME     "icon-name"

### GST_ELEMENT_METADATA_KLASS

    #define GST_ELEMENT_METADATA_KLASS         "klass"

### GST_ELEMENT_METADATA_LONGNAME

    #define GST_ELEMENT_METADATA_LONGNAME      "long-name"

## Signal Details

### The `“no-more-pads”` signal

    void
    user_function (GstElement *gstelement,
                   gpointer    user_data)

Flags: Run Last

### The `“pad-added”` signal

    void
    user_function (GstElement *gstelement,
                   GstPad     *arg1,
                   gpointer    user_data)

Flags: Run Last

### The `“pad-removed”` signal

    void
    user_function (GstElement *gstelement,
                   GstPad     *arg1,
                   gpointer    user_data)

Flags: Run Last