## GstElement

GstElement — Abstract base class for all pipeline elements

## Synopsis

    #include <gst/gst.h>

    struct              GstElement;
    struct              GstElementClass;
    enum                GstElementFlags;
    enum                GstState;
    enum                GstStateChange;
    enum                GstStateChangeReturn;
    #define             GST_STATE                           (elem)
    #define             GST_STATE_GET_NEXT                  (cur,
                                                             pending)
    #define             GST_STATE_NEXT                      (elem)
    #define             GST_STATE_PENDING                   (elem)
    #define             GST_STATE_RETURN                    (elem)
    #define             GST_STATE_TARGET                    (elem)
    #define             GST_STATE_TRANSITION                (cur,
                                                             next)
    #define             GST_STATE_TRANSITION_CURRENT        (trans)
    #define             GST_STATE_TRANSITION_NEXT           (trans)
    #define             GST_STATE_GET_LOCK                  (elem)
    #define             GST_STATE_GET_COND                  (elem)
    #define             GST_ELEMENT_NAME                    (elem)
    #define             GST_ELEMENT_PARENT                  (elem)
    #define             GST_ELEMENT_BUS                     (elem)
    #define             GST_ELEMENT_CLOCK                   (elem)
    #define             GST_ELEMENT_PADS                    (elem)
    #define             GST_ELEMENT_START_TIME              (elem)
    #define             GST_ELEMENT_ERROR                   (el,
                                                             domain,
                                                             code,
                                                             text,
                                                             debug)
    #define             GST_ELEMENT_WARNING                 (el,
                                                             domain,
                                                             code,
                                                             text,
                                                             debug)
    #define             GST_ELEMENT_INFO                    (el,
                                                             domain,
                                                             code,
                                                             text,
                                                             debug)
    #define             GST_ELEMENT_IS_LOCKED_STATE         (elem)

    void                gst_element_class_add_pad_template  (GstElementClass *klass,
                                                             GstPadTemplate *templ);
    GstPadTemplate *    gst_element_class_get_pad_template  (GstElementClass *element_class,
                                                             const gchar *name);
    GList *             gst_element_class_get_pad_template_list
                                                            (GstElementClass *element_class);
    void                gst_element_class_install_std_props (GstElementClass *klass,
                                                             const gchar *first_name,
                                                             ...);
    void                gst_element_class_set_details       (GstElementClass *klass,
                                                             const GstElementDetails *details);
    void                gst_element_class_set_details_simple
                                                            (GstElementClass *klass,
                                                             const gchar *longname,
                                                             const gchar *classification,
                                                             const gchar *description,
                                                             const gchar *author);
    void                gst_element_class_set_documentation_uri
                                                            (GstElementClass *klass,
                                                             const gchar *uri);
    void                gst_element_class_set_icon_name     (GstElementClass *klass,
                                                             const gchar *name);

    gboolean            gst_element_add_pad                 (GstElement *element,
                                                             GstPad *pad);
    GstPad *            gst_element_get_pad                 (GstElement *element,
                                                             const gchar *name);
    void                gst_element_create_all_pads         (GstElement *element);
    GstPad *            gst_element_get_compatible_pad      (GstElement *element,
                                                             GstPad *pad,
                                                             const GstCaps *caps);
    GstPadTemplate *    gst_element_get_compatible_pad_template
                                                            (GstElement *element,
                                                             GstPadTemplate *compattempl);
    GstPad *            gst_element_get_request_pad         (GstElement *element,
                                                             const gchar *name);
    GstPad *            gst_element_get_static_pad          (GstElement *element,
                                                             const gchar *name);
    GstPad *            gst_element_request_pad             (GstElement *element,
                                                             GstPadTemplate *templ,
                                                             const gchar *name,
                                                             const GstCaps *caps);
    void                gst_element_no_more_pads            (GstElement *element);
    void                gst_element_release_request_pad     (GstElement *element,
                                                             GstPad *pad);
    gboolean            gst_element_remove_pad              (GstElement *element,
                                                             GstPad *pad);
    GstIterator *       gst_element_iterate_pads            (GstElement *element);
    GstIterator *       gst_element_iterate_sink_pads       (GstElement *element);
    GstIterator *       gst_element_iterate_src_pads        (GstElement *element);

    gboolean            gst_element_link                    (GstElement *src,
                                                             GstElement *dest);
    void                gst_element_unlink                  (GstElement *src,
                                                             GstElement *dest);
    gboolean            gst_element_link_many               (GstElement *element_1,
                                                             GstElement *element_2,
                                                             ...);
    void                gst_element_unlink_many             (GstElement *element_1,
                                                             GstElement *element_2,
                                                             ...);
    gboolean            gst_element_link_pads               (GstElement *src,
                                                             const gchar *srcpadname,
                                                             GstElement *dest,
                                                             const gchar *destpadname);
    gboolean            gst_element_link_pads_full          (GstElement *src,
                                                             const gchar *srcpadname,
                                                             GstElement *dest,
                                                             const gchar *destpadname,
                                                             GstPadLinkCheck flags);
    void                gst_element_unlink_pads             (GstElement *src,
                                                             const gchar *srcpadname,
                                                             GstElement *dest,
                                                             const gchar *destpadname);
    gboolean            gst_element_link_pads_filtered      (GstElement *src,
                                                             const gchar *srcpadname,
                                                             GstElement *dest,
                                                             const gchar *destpadname,
                                                             GstCaps *filter);
    gboolean            gst_element_link_filtered           (GstElement *src,
                                                             GstElement *dest,
                                                             GstCaps *filter);

    void                gst_element_set_base_time           (GstElement *element,
                                                             GstClockTime time);
    GstClockTime        gst_element_get_base_time           (GstElement *element);
    void                gst_element_set_start_time          (GstElement *element,
                                                             GstClockTime time);
    GstClockTime        gst_element_get_start_time          (GstElement *element);
    void                gst_element_set_bus                 (GstElement *element,
                                                             GstBus *bus);
    GstBus *            gst_element_get_bus                 (GstElement *element);
    GstElementFactory * gst_element_get_factory             (GstElement *element);
    void                gst_element_set_index               (GstElement *element,
                                                             GstIndex *index);
    GstIndex *          gst_element_get_index               (GstElement *element);
    gboolean            gst_element_is_indexable            (GstElement *element);
    #define             gst_element_set_name                (elem,
                                                             name)
    #define             gst_element_get_name                (elem)
    #define             gst_element_set_parent              (elem,
                                                             parent)
    #define             gst_element_get_parent              (elem)

    gboolean            gst_element_requires_clock          (GstElement *element);
    gboolean            gst_element_set_clock               (GstElement *element,
                                                             GstClock *clock);
    GstClock *          gst_element_get_clock               (GstElement *element);
    gboolean            gst_element_provides_clock          (GstElement *element);
    GstClock *          gst_element_provide_clock           (GstElement *element);

    GstStateChangeReturn gst_element_set_state              (GstElement *element,
                                                             GstState state);
    GstStateChangeReturn gst_element_get_state              (GstElement *element,
                                                             GstState *state,
                                                             GstState *pending,
                                                             GstClockTime timeout);
    gboolean            gst_element_set_locked_state        (GstElement *element,
                                                             gboolean locked_state);
    gboolean            gst_element_is_locked_state         (GstElement *element);
    void                gst_element_abort_state             (GstElement *element);
    GstStateChangeReturn gst_element_continue_state         (GstElement *element,
                                                             GstStateChangeReturn ret);
    void                gst_element_lost_state              (GstElement *element);
    void                gst_element_lost_state_full         (GstElement *element,
                                                             gboolean new_base_time);
    const gchar *       gst_element_state_get_name          (GstState state);
    const gchar *       gst_element_state_change_return_get_name
                                                            (GstStateChangeReturn state_ret);
    gboolean            gst_element_sync_state_with_parent  (GstElement *element);
    GstStateChangeReturn gst_element_change_state           (GstElement *element,
                                                             GstStateChange transition);

    void                gst_element_found_tags              (GstElement *element,
                                                             GstTagList *list);
    void                gst_element_found_tags_for_pad      (GstElement *element,
                                                             GstPad *pad,
                                                             GstTagList *list);

    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);
    gboolean            gst_element_post_message            (GstElement *element,
                                                             GstMessage *message);

    const GstQueryType * gst_element_get_query_types        (GstElement *element);
    gboolean            gst_element_query                   (GstElement *element,
                                                             GstQuery *query);
    gboolean            gst_element_query_convert           (GstElement *element,
                                                             GstFormat src_format,
                                                             gint64 src_val,
                                                             GstFormat *dest_format,
                                                             gint64 *dest_val);
    gboolean            gst_element_query_position          (GstElement *element,
                                                             GstFormat *format,
                                                             gint64 *cur);
    gboolean            gst_element_query_duration          (GstElement *element,
                                                             GstFormat *format,
                                                             gint64 *duration);

    gboolean            gst_element_send_event              (GstElement *element,
                                                             GstEvent *event);
    gboolean            gst_element_seek_simple             (GstElement *element,
                                                             GstFormat format,
                                                             GstSeekFlags seek_flags,
                                                             gint64 seek_pos);
    gboolean            gst_element_seek                    (GstElement *element,
                                                             gdouble rate,
                                                             GstFormat format,
                                                             GstSeekFlags flags,
                                                             GstSeekType cur_type,
                                                             gint64 cur,
                                                             GstSeekType stop_type,
                                                             gint64 stop);

## Object Hierarchy

      GObject
       +----GstObject
             +----GstElement
                   +----GstBin

## Known Derived Interfaces

GstElement is required by GstImplementsInterface and GstTagSetter.

## Signals

      "no-more-pads"                                   : Run Last
      "pad-added"                                      : Run Last
      "pad-removed"                                    : Run Last

## Description

GstElement is the abstract base class needed to construct an element that can be used in a GStreamer pipeline. Please refer to the plugin writers guide for more information on creating GstElement subclasses.

The name of a GstElement can be get with `gst_element_get_name()` and set with `gst_element_set_name()`. For speed, `GST_ELEMENT_NAME()` can be used in the core when using the appropriate locking. Do not use this in plug-ins or applications in order to retain ABI compatibility.

All elements have pads (of the type GstPad). These pads link to pads on other elements. GstBuffer flow between these linked pads. A GstElement has a GList of GstPad structures for all their input (or sink) and output (or source) pads. Core and plug-in writers can add and remove pads with `gst_element_add_pad()` and `gst_element_remove_pad()`.

An existing pad of an element can be retrieved by name with `gst_element_get_static_pad()`. A new dynamic pad can be created using `gst_element_request_pad()` with a GstPadTemplate or `gst_element_get_request_pad()` with the template name such as "src_%d". An iterator of all pads can be retrieved with `gst_element_iterate_pads()`.

Elements can be linked through their pads. If the link is straightforward, use the `gst_element_link()` convenience function to link two elements, or `gst_element_link_many()` for more elements in a row. Use `gst_element_link_filtered()` to link two elements constrained by a specified set of GstCaps. For finer control, use `gst_element_link_pads()` and `gst_element_link_pads_filtered()` to specify the pads to link on each element by name.

Each element has a state (see GstState). You can get and set the state of an element with `gst_element_get_state()` and `gst_element_set_state()`. Setting a state triggers a GstStateChange. To get a string representation of a GstState, use `gst_element_state_get_name()`.

You can get and set a GstClock on an element using `gst_element_get_clock()` and `gst_element_set_clock()`. Some elements can provide a clock for the pipeline if `gst_element_provides_clock()` returns `TRUE`. With the `gst_element_provide_clock()` method one can retrieve the clock provided by such an element. Not all elements require a clock to operate correctly. If `gst_element_requires_clock()` returns `TRUE`, a clock should be set on the element with `gst_element_set_clock()`.

Note that clock slection and distribution is normally handled by the toplevel GstPipeline so the clock functions are only to be used in very specific situations.

Last reviewed on 2009-05-29 (0.10.24)

## Details

### struct GstElement

    struct GstElement {
      GStaticRecMutex      *state_lock;

      /* element state */
      GCond                *state_cond;
      guint32               state_cookie;
      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 */

      /* 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;
    };

GStreamer element abstract base class.

GStaticRecMutex *`state_lock`; | Used to serialize execution of `gst_element_set_state()`
GCond *`state_cond`; | Used to signal completion of a state change
guint32 `state_cookie`; | Used to detect concurrent execution of `gst_element_set_state()` and `gst_element_get_state()`
GstState `current_state`; | the current state of an element
GstState `next_state`; | the next state of an element, can be GST_STATE_VOID_PENDING if the element is in the correct state.
GstState `pending_state`; | the final state the element should go to, can be GST_STATE_VOID_PENDING if the element is in the correct state
GstStateChangeReturn `last_return`; | the last return value of an element state change
GstBus *`bus`; | the bus of the element. This bus is provided to the element by the parent element or the application. A GstPipeline has a bus of its own.
GstClock *`clock`; | the clock of the element. This clock is usually provided to the element by the toplevel GstPipeline.
GstClockTimeDiff `base_time`; | the time of the clock right before the element is set to PLAYING. Subtracting `base_time` from the current clock time in the PLAYING state will yield the running_time against the clock.
guint16 `numpads`; | number of pads of the element, includes both source and sink pads.
GList *`pads`; | list of pads
guint16 `numsrcpads`; | number of source pads of the element.
GList *`srcpads`; | list of source pads
guint16 `numsinkpads`; | number of sink pads of the element.
GList *`sinkpads`; | list of sink pads
guint32 `pads_cookie`; | updated whenever the a pad is added or removed

### struct GstElementClass

    struct GstElementClass {
      GstObjectClass         parent_class;

      /* the element details */
      /* FIXME-0.11: deprecate this in favour of meta_data */
      GstElementDetails      details;

      /* 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 */
      GstPad*               (*request_new_pad)      (GstElement *element, GstPadTemplate *templ, const gchar* name);
      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);

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

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

      /* index */
      GstIndex*             (*get_index)            (GstElement *element);
      void                  (*set_index)            (GstElement *element, GstIndex *index);

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

      const GstQueryType*   (*get_query_types)      (GstElement *element);
      gboolean              (*query)                (GstElement *element, GstQuery *query);

      /* Virtual method for subclasses (additions) */
      /* FIXME-0.11 Make this the default behaviour */
      GstPad*		(*request_new_pad_full) (GstElement *element, GstPadTemplate *templ,
    						 const gchar* name, const GstCaps *caps);

      void                  (*state_changed)        (GstElement *element, GstState oldstate,
                                                     GstState newstate, GstState pending);
    };

GStreamer element class. Override the vmethods to implement the element functionality.

GstObjectClass `parent_class`; | the parent class structure
GstElementDetails `details`; | GstElementDetails for elements of this class
GstElementFactory *`elementfactory`; | the GstElementFactory that creates these elements
GList *`padtemplates`; | a GList of GstPadTemplate
gint `numpadtemplates`; | the number of padtemplates
guint32 `pad_templ_cookie`; | changed whenever the padtemplates change
`request_new_pad` () | called when a new pad is requested
`release_pad` () | called when a request pad is to be released
`get_state` () | get the state of the element
`set_state` () | set a new state on the element
`change_state` () | called by `set_state` to perform an incremental state change
`set_bus` () | set a GstBus on the element
`provide_clock` () | gets the GstClock provided by the element
`set_clock` () | set the GstClock on the element
`get_index` () | set a GstIndex on the element
`set_index` () | get the GstIndex of an element
`send_event` () | send a GstEvent to the element
`get_query_types` () | get the supported GstQueryType of this element
`query` () | perform a GstQuery on the element
`request_new_pad_full` () | called when a new pad is requested. Since: 0.10.32.
`state_changed` () | called immediately after a new state was set. Since: 0.10.36.

### enum GstElementFlags

    typedef enum {
      GST_ELEMENT_LOCKED_STATE      = (GST_OBJECT_FLAG_LAST << 0),
      GST_ELEMENT_IS_SINK           = (GST_OBJECT_FLAG_LAST << 1),
      GST_ELEMENT_UNPARENTING       = (GST_OBJECT_FLAG_LAST << 2),
      GST_ELEMENT_IS_SOURCE         = (GST_OBJECT_FLAG_LAST << 3),
      /* padding */
      GST_ELEMENT_FLAG_LAST         = (GST_OBJECT_FLAG_LAST << 16)
    } GstElementFlags;

The standard flags that an element may have.

`GST_ELEMENT_LOCKED_STATE` | ignore state changes from parent
`GST_ELEMENT_IS_SINK` | the element is a sink
`GST_ELEMENT_UNPARENTING` | Child is being removed from the parent bin. `gst_bin_remove()` on a child already being removed immediately returns FALSE
`GST_ELEMENT_IS_SOURCE` | the element is a source. Since 0.10.31
`GST_ELEMENT_FLAG_LAST` | offset to define more flags

### enum GstState

    typedef enum {
      GST_STATE_VOID_PENDING        = 0,
      GST_STATE_NULL                = 1,
      GST_STATE_READY               = 2,
      GST_STATE_PAUSED              = 3,
      GST_STATE_PLAYING             = 4
    } GstState;

The possible states an element can be in. States can be changed using `gst_element_set_state()` and checked using `gst_element_get_state()`.

`GST_STATE_VOID_PENDING` | no pending state.
`GST_STATE_NULL` | the NULL state or initial state of an element.
`GST_STATE_READY` | the element is ready to go to PAUSED.
`GST_STATE_PAUSED` | the element is PAUSED, it is ready to accept and process data. Sink elements however only accept one buffer and then block.
`GST_STATE_PLAYING` | the element is PLAYING, the GstClock is running and the data is flowing.

### enum GstStateChange

    typedef enum {
      GST_STATE_CHANGE_NULL_TO_READY        = (GST_STATE_NULL<<3) | GST_STATE_READY,
      GST_STATE_CHANGE_READY_TO_PAUSED      = (GST_STATE_READY<<3) | GST_STATE_PAUSED,
      GST_STATE_CHANGE_PAUSED_TO_PLAYING    = (GST_STATE_PAUSED<<3) | GST_STATE_PLAYING,
      GST_STATE_CHANGE_PLAYING_TO_PAUSED    = (GST_STATE_PLAYING<<3) | GST_STATE_PAUSED,
      GST_STATE_CHANGE_PAUSED_TO_READY      = (GST_STATE_PAUSED<<3) | GST_STATE_READY,
      GST_STATE_CHANGE_READY_TO_NULL        = (GST_STATE_READY<<3) | GST_STATE_NULL
    } GstStateChange;

These are the different state changes an element goes through. `GST_STATE_NULL` ⇒ `GST_STATE_PLAYING` is called an upwards state change and `GST_STATE_PLAYING` ⇒ `GST_STATE_NULL` a downwards state change.

`GST_STATE_CHANGE_NULL_TO_READY`

state change from NULL to READY.

- The element must check if the resources it needs are available. Device sinks and -sources typically try to probe the device to constrain their caps.

- The element opens the device (in case feature need to be probed).

`GST_STATE_CHANGE_READY_TO_PAUSED`

state change from READY to PAUSED.

- The element pads are activated in order to receive data in PAUSED. Streaming threads are started.

- Some elements might need to return `GST_STATE_CHANGE_ASYNC` and complete the state change when they have enough information. It is a requirement for sinks to return `GST_STATE_CHANGE_ASYNC` and complete the state change when they receive the first buffer or `GST_EVENT_EOS` (preroll). Sinks also block the dataflow when in PAUSED.

- A pipeline resets the running_time to 0.

- Live sources return `GST_STATE_CHANGE_NO_PREROLL` and don't generate data.

`GST_STATE_CHANGE_PAUSED_TO_PLAYING`

state change from PAUSED to PLAYING.

- Most elements ignore this state change.

- The pipeline selects a GstClock and distributes this to all the children before setting them to PLAYING. This means that it is only alowed to synchronize on the GstClock in the PLAYING state.

- The pipeline uses the GstClock and the running_time to calculate the base_time. The base_time is distributed to all children when performing the state change.

- Sink elements stop blocking on the preroll buffer or event and start rendering the data.

- Sinks can post `GST_MESSAGE_EOS` in the PLAYING state. It is not allowed to post `GST_MESSAGE_EOS` when not in the PLAYING state.

- While streaming in PAUSED or PLAYING elements can create and remove sometimes pads.

- Live sources start generating data and return `GST_STATE_CHANGE_SUCCESS`.

`GST_STATE_CHANGE_PLAYING_TO_PAUSED`

state change from PLAYING to PAUSED.

- Most elements ignore this state change.

- The pipeline calculates the running_time based on the last selected GstClock and the base_time. It stores this information to continue playback when going back to the PLAYING state.

- Sinks unblock any GstClock wait calls.

- When a sink does not have a pending buffer to play, it returns `GST_STATE_CHANGE_ASYNC` from this state change and completes the state change when it receives a new buffer or an `GST_EVENT_EOS`.

- Any queued `GST_MESSAGE_EOS` items are removed since they will be reposted when going back to the PLAYING state. The EOS messages are queued in GstBin containers.

- Live sources stop generating data and return `GST_STATE_CHANGE_NO_PREROLL`.

`GST_STATE_CHANGE_PAUSED_TO_READY`

state change from PAUSED to READY.

- Sinks unblock any waits in the preroll.

- Elements unblock any waits on devices

- Chain or get_range functions return `GST_FLOW_WRONG_STATE`.

- The element pads are deactivated so that streaming becomes impossible and all streaming threads are stopped.

- The sink forgets all negotiated formats

- Elements remove all sometimes pads

`GST_STATE_CHANGE_READY_TO_NULL`

state change from READY to NULL.

- Elements close devices

- Elements reset any internal state.

### enum GstStateChangeReturn

    typedef enum {
      GST_STATE_CHANGE_FAILURE             = 0,
      GST_STATE_CHANGE_SUCCESS             = 1,
      GST_STATE_CHANGE_ASYNC               = 2,
      GST_STATE_CHANGE_NO_PREROLL          = 3
    } GstStateChangeReturn;

The possible return values from a state change function such as `gst_element_set_state()`. Only `GST_STATE_CHANGE_FAILURE` is a real failure.

`GST_STATE_CHANGE_FAILURE` | the state change failed
`GST_STATE_CHANGE_SUCCESS` | the state change succeeded
`GST_STATE_CHANGE_ASYNC` | the state change will happen asynchronously
`GST_STATE_CHANGE_NO_PREROLL` | the state change succeeded but the element cannot produce data in `GST_STATE_PAUSED`. This typically happens with live sources.

### GST_STATE()

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

This macro returns the current GstState of the element.

`elem` : | a GstElement to return state for.

### GST_STATE_GET_NEXT()

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

Given a current state `cur` and a target state `pending`, calculate the next (intermediate) GstState.

`cur` : | A starting GstState
`pending` : | A target GstState

### GST_STATE_NEXT()

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

This macro returns the next GstState of the element.

`elem` : | a GstElement to return the next state for.

### GST_STATE_PENDING()

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

This macro returns the currently pending GstState of the element.

`elem` : | a GstElement to return the pending state for.

### GST_STATE_RETURN()

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

This macro returns the last GstStateChangeReturn value.

`elem` : | a GstElement to return the last state result for.

### GST_STATE_TARGET()

    #define GST_STATE_TARGET(elem)          (GST_ELEMENT_CAST(elem)->abidata.ABI.target_state)

This macro returns the target GstState of the element.

`elem` : | a GstElement to return the target state for.

Since 0.10.13

### GST_STATE_TRANSITION()

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

Given a current state `cur` and a next state `next`, calculate the associated GstStateChange transition.

`cur` : | A current state
`next` : | A next state

### GST_STATE_TRANSITION_CURRENT()

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

Given a state transition `trans`, extract the current GstState.

`trans` : | A GstStateChange

### GST_STATE_TRANSITION_NEXT()

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

Given a state transition `trans`, extract the next GstState.

`trans` : | A GstStateChange

### GST_STATE_GET_LOCK()

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

Get a reference to the state lock of `elem`. This lock is used by the core. It is taken while getting or setting the state, during state changes, and while finalizing.

`elem` : | a GstElement

### GST_STATE_GET_COND()

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

Get the conditional used to signal the completion of a state change.

`elem` : | a GstElement

### GST_ELEMENT_NAME()

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

Gets the name of this element. Use only in core as this is not ABI-compatible. Others use `gst_element_get_name()`

`elem` : | A GstElement to query

### GST_ELEMENT_PARENT()

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

Get the parent object of this element.

`elem` : | A GstElement to query

### GST_ELEMENT_BUS()

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

Get the message bus of this element.

`elem` : | A GstElement to query

### GST_ELEMENT_CLOCK()

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

Get the clock of this element

`elem` : | A GstElement to query

### GST_ELEMENT_PADS()

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

Get the pads of this elements.

`elem` : | A GstElement to query

### GST_ELEMENT_START_TIME()

    #define GST_ELEMENT_START_TIME(elem)            (GST_ELEMENT_CAST(elem)->abidata.ABI.start_time)

This macro returns the start_time of the `elem`. The start_time is the running_time of the pipeline when the element went to PAUSED.

`elem` : | a GstElement to return the start time for.

Since 0.10.24

### GST_ELEMENT_ERROR()

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

Utility function that elements can use in case they encountered a fatal data processing error. The pipeline will post an error message and the application will be requested to stop further media processing.

`el` : | the element that generates the error
`domain` : | like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError)
`code` : | error code defined for that domain (see gstreamer-GstGError)
`text` : | the message to display (format string and args enclosed in parentheses)
`debug` : | debugging information for the message (format string and args enclosed in parentheses)

### GST_ELEMENT_WARNING()

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

Utility function that elements can use in case they encountered a non-fatal data processing problem. The pipeline will post a warning message and the application will be informed.

`el` : | the element that generates the warning
`domain` : | like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError)
`code` : | error code defined for that domain (see gstreamer-GstGError)
`text` : | the message to display (format string and args enclosed in parentheses)
`debug` : | debugging information for the message (format string and args enclosed in parentheses)

### GST_ELEMENT_INFO()

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

Utility function that elements can use in case they want to inform the application of something noteworthy that is not an error. The pipeline will post a info message and the application will be informed.

`el` : | the element that generates the information
`domain` : | like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError)
`code` : | error code defined for that domain (see gstreamer-GstGError)
`text` : | the message to display (format string and args enclosed in parentheses)
`debug` : | debugging information for the message (format string and args enclosed in parentheses)

Since 0.10.12

### GST_ELEMENT_IS_LOCKED_STATE()

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

Check if the element is in the locked state and therefore will ignore state changes from its parent object.

`elem` : | A GstElement to query

### gst_element_class_add_pad_template ()

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

Adds a padtemplate to an element class. This is mainly used in the _base_init functions of classes.

`klass` : | the GstElementClass to add the pad template to.
`templ` : | a GstPadTemplate to add to the element class. [transfer none]

### gst_element_class_get_pad_template ()

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

Retrieves a padtemplate from `element_class` with the given name.

### Note

If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.

`element_class` : | a GstElementClass to get the pad template of.
`name` : | the name of the GstPadTemplate to get.
Returns : | the GstPadTemplate with the given name, or `NULL` if none was found. No unreferencing is necessary. [transfer none]

### gst_element_class_get_pad_template_list ()

    GList *             gst_element_class_get_pad_template_list
                                                            (GstElementClass *element_class);

Retrieves a list of the pad templates associated with `element_class`. The list must not be modified by the calling code.

### Note

If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.

`element_class` : | a GstElementClass to get pad templates of.
Returns : | the GList of pad templates. [transfer none][element-type Gst.PadTemplate]

### gst_element_class_install_std_props ()

    void                gst_element_class_install_std_props (GstElementClass *klass,
                                                             const gchar *first_name,
                                                             ...);

Adds a list of standardized properties with types to the `klass`. the id is for the property switch in your get_prop method, and the flags determine readability / writeability.

`klass` : | the GstElementClass to add the properties to.
`first_name` : | the name of the first property. in a NULL terminated
`...` : | the id and flags of the first property, followed by further 'name', 'id', 'flags' triplets and terminated by NULL.

### gst_element_class_set_details ()

    void                gst_element_class_set_details       (GstElementClass *klass,
                                                             const GstElementDetails *details);

### Warning

`gst_element_class_set_details` is deprecated and should not be used in newly-written code. Use `gst_element_class_set_details_simple()` instead.

Sets the detailed information for a GstElementClass.

### Note

This function is for use in _base_init functions only.

The `details` are copied.

`klass` : | class to set details for
`details` : | details to set

### gst_element_class_set_details_simple ()

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

Sets the detailed information for a GstElementClass. Simpler version of `gst_element_class_set_details()` that generates less linker overhead.

### Note

This function is for use in _base_init functions only.

The detail parameter strings are copied into the GstElementDetails for the element class.

`klass` : | class to set details for
`longname` : | The long English name of the element. E.g. "File Sink"
`classification` : | 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. E.g: "Sink/File"
`description` : | Sentence describing the purpose of the element. E.g: "Write stream to a file"
`author` : | Name and contact details of the author(s). Use \n to separate multiple author details. E.g: "Joe Bloggs <joe.blogs at foo.com>"

Since 0.10.14

### gst_element_class_set_documentation_uri ()

    void                gst_element_class_set_documentation_uri
                                                            (GstElementClass *klass,
                                                             const gchar *uri);

Set uri pointing to user documentation. Applications can use this to show help for e.g. effects to users.

`klass` : | class to set details for
`uri` : | uri of element documentation

Since 0.10.31

### gst_element_class_set_icon_name ()

    void                gst_element_class_set_icon_name     (GstElementClass *klass,
                                                             const gchar *name);

Elements that bridge to certain other products can include an icon of that used product. Application can show the icon in menus/selectors to help identifying specific elements.

`klass` : | class to set details for
`name` : | name of an icon

Since 0.10.31

### gst_element_add_pad ()

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

Adds a pad (link point) to `element`. `pad`'s parent will be set to `element`; see `gst_object_set_parent()` for refcounting information.

Pads are not automatically activated so elements should perform the needed steps to activate the pad in case this pad is added in the PAUSED or PLAYING state. See `gst_pad_set_active()` for more information about activating pads.

The pad and the element should be unlocked when calling this function.

This function will emit the "pad-added" signal on the element.

`element` : | a GstElement to add the pad to.
`pad` : | the GstPad to add to the element. [transfer full]
Returns : | `TRUE` if the pad could be added. This function can fail when a pad with the same name already existed or the pad already had another parent. MT safe.

### gst_element_get_pad ()

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

### Warning

`gst_element_get_pad` is deprecated and should not be used in newly-written code. This function is deprecated as it's unclear if the reference to the result pad should be released with `gst_object_unref()` in case of a static pad or `gst_element_release_request_pad()` in case of a request pad. Use `gst_element_get_static_pad()` or `gst_element_get_request_pad()` instead.

Retrieves a pad from `element` by name. Tries `gst_element_get_static_pad()` first, then `gst_element_get_request_pad()`.

`element` : | a GstElement.
`name` : | the name of the pad to retrieve.
Returns : | the GstPad if found, otherwise `NULL`. Unref or Release after usage, depending on the type of the pad. [transfer full]

### gst_element_create_all_pads ()

    void                gst_element_create_all_pads         (GstElement *element);

Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of GstElement.

`element` : | a GstElement to create pads for. [transfer none]

### gst_element_get_compatible_pad ()

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

Looks for an unlinked pad to which the given pad can link. It is not guaranteed that linking the pads will work, though it should work in most cases.

This function will first attempt to find a compatible unlinked ALWAYS pad, and if none can be found, it will request a compatible REQUEST pad by looking at the templates of `element`.

`element` : | a GstElement in which the pad should be found. [transfer none]
`pad` : | the GstPad to find a compatible one for. [transfer none]
`caps` : | the GstCaps to use as a filter.
Returns : | the GstPad to which a link can be made, or `NULL` if one cannot be found. `gst_object_unref()` after usage. [transfer full]

### gst_element_get_compatible_pad_template ()

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

Retrieves a pad template from `element` that is compatible with `compattempl`. Pads from compatible templates can be linked together.

`element` : | a GstElement to get a compatible pad template for. [transfer none]
`compattempl` : | the GstPadTemplate to find a compatible template for. [transfer none]
Returns : | a compatible GstPadTemplate, or NULL if none was found. No unreferencing is necessary. [transfer none]

### gst_element_get_request_pad ()

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

Retrieves a pad from the element by name (e.g. "src_%d"). This version only retrieves request pads. The pad should be released with `gst_element_release_request_pad()`.

This method is slow and will be deprecated in the future. New code should use `gst_element_request_pad()` with the requested template.

`element` : | a GstElement to find a request pad of.
`name` : | the name of the request GstPad to retrieve.
Returns : | requested GstPad if found, otherwise `NULL`. Release after usage. [transfer full]

### gst_element_get_static_pad ()

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

Retrieves a pad from `element` by name. This version only retrieves already-existing (i.e. 'static') pads.

`element` : | a GstElement to find a static pad of.
`name` : | the name of the static GstPad to retrieve.
Returns : | the requested GstPad if found, otherwise `NULL`. unref after usage. MT safe. [transfer full]

### gst_element_request_pad ()

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

Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using `gst_element_factory_get_static_pad_templates()`.

If the `caps` are specified and the element implements thew new request_new_pad_full virtual method, the element will use them to select which pad to create.

The pad should be released with `gst_element_release_request_pad()`.

`element` : | a GstElement to find a request pad of.
`templ` : | a GstPadTemplate of which we want a pad of.
`name` : | the name of the request GstPad to retrieve. Can be `NULL`. [transfer none][allow-none]
`caps` : | the caps of the pad we want to request. Can be `NULL`. [transfer none][allow-none]
Returns : | requested GstPad if found, otherwise `NULL`. Release after usage. [transfer full]

Since 0.10.32

### gst_element_no_more_pads ()

    void                gst_element_no_more_pads            (GstElement *element);

Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with GST_PAD_SOMETIMES pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.

This function emits the "no-more-pads" signal.

MT safe.

`element` : | a GstElement

### gst_element_release_request_pad ()

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

Makes the element free the previously requested pad as obtained with `gst_element_get_request_pad()`.

This does not unref the pad. If the pad was created by using `gst_element_get_request_pad()`, `gst_element_release_request_pad()` needs to be followed by `gst_object_unref()` to free the `pad`.

MT safe.

`element` : | a GstElement to release the request pad of.
`pad` : | the GstPad to release.

### gst_element_remove_pad ()

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

Removes `pad` from `element`. `pad` will be destroyed if it has not been referenced elsewhere using `gst_object_unparent()`.

This function is used by plugin developers and should not be used by applications. Pads that were dynamically requested from elements with `gst_element_get_request_pad()` should be released with the `gst_element_release_request_pad()` function instead.

Pads are not automatically deactivated so elements should perform the needed steps to deactivate the pad in case this pad is removed in the PAUSED or PLAYING state. See `gst_pad_set_active()` for more information about deactivating pads.

The pad and the element should be unlocked when calling this function.

This function will emit the "pad-removed" signal on the element.

`element` : | a GstElement to remove pad from.
`pad` : | the GstPad to remove from the element. [transfer none]
Returns : | `TRUE` if the pad could be removed. Can return `FALSE` if the pad does not belong to the provided element. MT safe.

### gst_element_iterate_pads ()

    GstIterator *       gst_element_iterate_pads            (GstElement *element);

Retrieves an iterator of `element`'s pads. The iterator should be freed after usage. Also more specialized iterators exists such as `gst_element_iterate_src_pads()` or `gst_element_iterate_sink_pads()`.

`element` : | a GstElement to iterate pads of.
Returns : | the GstIterator of GstPad. Unref each pad after use. MT safe. [transfer full]

### gst_element_iterate_sink_pads ()

    GstIterator *       gst_element_iterate_sink_pads       (GstElement *element);

Retrieves an iterator of `element`'s sink pads.

`element` : | a GstElement.
Returns : | the GstIterator of GstPad. Unref each pad after use. MT safe. [transfer full]

### gst_element_iterate_src_pads ()

    GstIterator *       gst_element_iterate_src_pads        (GstElement *element);

Retrieves an iterator of `element`'s source pads.

`element` : | a GstElement.
Returns : | the GstIterator of GstPad. Unref each pad after use. MT safe. [transfer full]

### gst_element_link ()

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

Links `src` to `dest`. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. Such pads need to be released manually when unlinking. If multiple links are possible, only one is established.

Make sure you have added your elements to a bin or pipeline with `gst_bin_add()` before trying to link them.

`src` : | a GstElement containing the source pad. [transfer none]
`dest` : | the GstElement containing the destination pad. [transfer none]
Returns : | TRUE if the elements could be linked, FALSE otherwise.

### gst_element_unlink ()

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

Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked.

If the link has been made using `gst_element_link()`, it could have created an requestpad, which has to be released using `gst_element_release_request_pad()`.

`src` : | the source GstElement to unlink. [transfer none]
`dest` : | the sink GstElement to unlink. [transfer none]

### gst_element_link_many ()

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

Chain together a series of elements. Uses `gst_element_link()`. Make sure you have added your elements to a bin or pipeline with `gst_bin_add()` before trying to link them.

`element_1` : | the first GstElement in the link chain. [transfer none]
`element_2` : | the second GstElement in the link chain. [transfer none]
`...` : | the NULL-terminated list of elements to link in order.
Returns : | TRUE on success, FALSE otherwise.

### gst_element_unlink_many ()

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

Unlinks a series of elements. Uses `gst_element_unlink()`.

`element_1` : | the first GstElement in the link chain. [transfer none]
`element_2` : | the second GstElement in the link chain. [transfer none]
`...` : | the NULL-terminated list of elements to unlink in order.

### gst_element_link_pads ()

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

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

`src` : | a GstElement containing the source pad.
`srcpadname` : | the name of the GstPad in source element or NULL for any pad. [allow-none]
`dest` : | the GstElement containing the destination pad. [transfer none]
`destpadname` : | the name of the GstPad in destination element, or NULL for any pad. [allow-none]
Returns : | TRUE if the pads could be linked, FALSE otherwise.

### gst_element_link_pads_full ()

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

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

Calling `gst_element_link_pads_full()` with `flags` == `GST_PAD_LINK_CHECK_DEFAULT` is the same as calling `gst_element_link_pads()` and the recommended way of linking pads with safety checks applied.

This is a convenience function for `gst_pad_link_full()`.

`src` : | a GstElement containing the source pad.
`srcpadname` : | the name of the GstPad in source element or NULL for any pad. [allow-none]
`dest` : | the GstElement containing the destination pad. [transfer none]
`destpadname` : | the name of the GstPad in destination element, or NULL for any pad. [allow-none]
`flags` : | the GstPadLinkCheck to be performed when linking pads.
Returns : | TRUE if the pads could be linked, FALSE otherwise.

Since 0.10.30

### gst_element_unlink_pads ()

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

Unlinks the two named pads of the source and destination elements.

This is a convenience function for `gst_pad_unlink()`.

`src` : | a (transfer none): GstElement containing the source pad.
`srcpadname` : | the name of the GstPad in source element.
`dest` : | a GstElement containing the destination pad. [transfer none]
`destpadname` : | the name of the GstPad in destination element.

### gst_element_link_pads_filtered ()

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

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. If `caps` is not NULL, makes sure that the caps of the link is a subset of `caps`.

`src` : | a GstElement containing the source pad.
`srcpadname` : | the name of the GstPad in source element or NULL for any pad. [allow-none]
`dest` : | the GstElement containing the destination pad. [transfer none]
`destpadname` : | the name of the GstPad in destination element or NULL for any pad. [allow-none]
`filter` : | the GstCaps to filter the link, or NULL for no filter. [transfer none][allow-none]
Returns : | TRUE if the pads could be linked, FALSE otherwise.

### gst_element_link_filtered ()

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

Links `src` to `dest` using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. If multiple links are possible, only one is established.

Make sure you have added your elements to a bin or pipeline with `gst_bin_add()` before trying to link them.

`src` : | a GstElement containing the source pad.
`dest` : | the GstElement containing the destination pad. [transfer none]
`filter` : | the GstCaps to filter the link, or NULL for no filter. [transfer none][allow-none]
Returns : | TRUE if the pads could be linked, FALSE otherwise.

### gst_element_set_base_time ()

    void                gst_element_set_base_time           (GstElement *element,
                                                             GstClockTime time);

Set the base time of an element. See `gst_element_get_base_time()`.

MT safe.

`element` : | a GstElement.
`time` : | the base time to set.

### gst_element_get_base_time ()

    GstClockTime        gst_element_get_base_time           (GstElement *element);

Returns the base time of the element. The base time is the absolute time of the clock when this element was last put to PLAYING. Subtracting the base time from the clock time gives the running time of the element.

`element` : | a GstElement.
Returns : | the base time of the element. MT safe.

### gst_element_set_start_time ()

    void                gst_element_set_start_time          (GstElement *element,
                                                             GstClockTime time);

Set the start time of an element. The start time of the element is the running time of the element when it last went to the PAUSED state. In READY or after a flushing seek, it is set to 0.

Toplevel elements like GstPipeline will manage the start_time and base_time on its children. Setting the start_time to GST_CLOCK_TIME_NONE on such a toplevel element will disable the distribution of the base_time to the children and can be useful if the application manages the base_time itself, for example if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock.

MT safe.

`element` : | a GstElement.
`time` : | the base time to set.

Since 0.10.24

### gst_element_get_start_time ()

    GstClockTime        gst_element_get_start_time          (GstElement *element);

Returns the start time of the element. The start time is the running time of the clock when this element was last put to PAUSED.

Usually the start_time is managed by a toplevel element such as GstPipeline.

MT safe.

`element` : | a GstElement.
Returns : | the start time of the element.

Since 0.10.24

### gst_element_set_bus ()

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

Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements.

MT safe.

`element` : | a GstElement to set the bus of.
`bus` : | the GstBus to set. [transfer none]

### gst_element_get_bus ()

    GstBus *            gst_element_get_bus                 (GstElement *element);

Returns the bus of the element. Note that only a GstPipeline will provide a bus for the application.

`element` : | a GstElement to get the bus of.
Returns : | the element's GstBus. unref after usage. MT safe. [transfer full]

### gst_element_get_factory ()

    GstElementFactory * gst_element_get_factory             (GstElement *element);

Retrieves the factory that was used to create this element.

`element` : | a GstElement to request the element factory of.
Returns : | the GstElementFactory used for creating this element. no refcounting is needed. [transfer none]

### gst_element_set_index ()

    void                gst_element_set_index               (GstElement *element,
                                                             GstIndex *index);

Set `index` on the element. The refcount of the index will be increased, any previously set index is unreffed.

MT safe.

`element` : | a GstElement.
`index` : | a GstIndex. [transfer none]

### gst_element_get_index ()

    GstIndex *          gst_element_get_index               (GstElement *element);

Gets the index from the element.

`element` : | a GstElement.
Returns : | a GstIndex or `NULL` when no index was set on the element. unref after usage. MT safe. [transfer full]

### gst_element_is_indexable ()

    gboolean            gst_element_is_indexable            (GstElement *element);

Queries if the element can be indexed.

`element` : | a GstElement.
Returns : | TRUE if the element can be indexed. MT safe.

### gst_element_set_name()

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

Sets the name of the element, getting rid of the old name if there was one.

`elem` : | a GstElement to set the name of.
`name` : | the new name

### gst_element_get_name()

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

Returns a copy of the name of `elem`. Caller should `g_free()` the return value after usage. For a nameless element, this returns NULL, which you can safely `g_free()` as well.

`elem` : | a GstElement to get the name of `elem`.
Returns : | the name of `elem`. `g_free()` after usage. MT safe. [transfer full]

### gst_element_set_parent()

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

Sets the parent of an element.

`elem` : | a GstElement to set the parent of.
`parent` : | the new parent GstObject of the element.

### gst_element_get_parent()

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

Get the parent of an element.

`elem` : | a GstElement to get the parent of.
Returns : | the parent of an element. [transfer full]

### gst_element_requires_clock ()

    gboolean            gst_element_requires_clock          (GstElement *element);

Query if the element requires a clock.

`element` : | a GstElement to query
Returns : | `TRUE` if the element requires a clock MT safe.

### gst_element_set_clock ()

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

Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.

`element` : | a GstElement to set the clock for.
`clock` : | the GstClock to set for the element.
Returns : | `TRUE` if the element accepted the clock. An element can refuse a clock when it, for example, is not able to slave its internal clock to the `clock` or when it requires a specific clock to operate. MT safe.

### gst_element_get_clock ()

    GstClock *          gst_element_get_clock               (GstElement *element);

Gets the currently configured clock of the element. This is the clock as was last set with `gst_element_set_clock()`.

`element` : | a GstElement to get the clock of.
Returns : | the GstClock of the element. unref after usage. MT safe. [transfer full]

### gst_element_provides_clock ()

    gboolean            gst_element_provides_clock          (GstElement *element);

Query if the element provides a clock. A GstClock provided by an element can be used as the global GstClock for the pipeline. An element that can provide a clock is only required to do so in the PAUSED state, this means when it is fully negotiated and has allocated the resources to operate the clock.

`element` : | a GstElement to query
Returns : | `TRUE` if the element provides a clock MT safe.

### gst_element_provide_clock ()

    GstClock *          gst_element_provide_clock           (GstElement *element);

Get the clock provided by the given element.

### Note

An element is only required to provide a clock in the PAUSED state. Some elements can provide a clock in other states.

`element` : | a GstElement to query
Returns : | the GstClock provided by the element or `NULL` if no clock could be provided. Unref after usage. MT safe. [transfer full]

### gst_element_set_state ()

    GstStateChangeReturn gst_element_set_state              (GstElement *element,
                                                             GstState state);

Sets the state of the element. This function will try to set the requested state by going through all the intermediary states and calling the class's state change function for each.

This function can return GST_STATE_CHANGE_ASYNC, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can use `gst_element_get_state()` to wait for the completion of the state change or it can wait for a state change message on the bus.

State changes to `GST_STATE_READY` or `GST_STATE_NULL` never return GST_STATE_CHANGE_ASYNC.

`element` : | a GstElement to change state of.
`state` : | the element's new GstState.
Returns : | Result of the state change using GstStateChangeReturn. MT safe.

### gst_element_get_state ()

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

Gets the state of the element.

For elements that performed an ASYNC state change, as reported by `gst_element_set_state()`, this function will block up to the specified timeout value for the state change to complete. If the element completes the state change or goes into an error, this function returns immediately with a return value of `GST_STATE_CHANGE_SUCCESS` or `GST_STATE_CHANGE_FAILURE` respectively.

For elements that did not return `GST_STATE_CHANGE_ASYNC`, this function returns the current and pending state immediately.

This function returns `GST_STATE_CHANGE_NO_PREROLL` if the element successfully changed its state but is not able to provide data yet. This mostly happens for live sources that only produce data in `GST_STATE_PLAYING`. While the state change return is equivalent to `GST_STATE_CHANGE_SUCCESS`, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start.

`element` : | a GstElement to get the state of.
`state` : | a pointer to GstState to hold the state. Can be `NULL`. [out][allow-none]
`pending` : | a pointer to GstState to hold the pending state. Can be `NULL`. [out][allow-none]
`timeout` : | a GstClockTime to specify the timeout for an async state change or `GST_CLOCK_TIME_NONE` for infinite timeout.
Returns : | `GST_STATE_CHANGE_SUCCESS` if the element has no more pending state and the last state change succeeded, `GST_STATE_CHANGE_ASYNC` if the element is still performing a state change or `GST_STATE_CHANGE_FAILURE` if the last state change failed. MT safe.

### gst_element_set_locked_state ()

    gboolean            gst_element_set_locked_state        (GstElement *element,
                                                             gboolean locked_state);

Locks the state of an element, so state changes of the parent don't affect this element anymore.

MT safe.

`element` : | a GstElement
`locked_state` : | TRUE to lock the element's state
Returns : | TRUE if the state was changed, FALSE if bad parameters were given or the elements state-locking needed no change.

### gst_element_is_locked_state ()

    gboolean            gst_element_is_locked_state         (GstElement *element);

Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don't affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from GST_STATE_NULL.

MT safe.

`element` : | a GstElement.
Returns : | TRUE, if the element's state is locked.

### gst_element_abort_state ()

    void                gst_element_abort_state             (GstElement *element);

Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong.

This function should be called with the STATE_LOCK held.

MT safe.

`element` : | a GstElement to abort the state of.

### gst_element_continue_state ()

    GstStateChangeReturn gst_element_continue_state         (GstElement *element,
                                                             GstStateChangeReturn ret);

Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned `GST_STATE_CHANGE_SUCCESS` from the state change function.

If after calling this method the element still has not reached the pending state, the next state change is performed.

This method is used internally and should normally not be called by plugins or applications.

`element` : | a GstElement to continue the state change of.
`ret` : | The previous state return value
Returns : | The result of the commit state change. MT safe.

### gst_element_lost_state ()

    void                gst_element_lost_state              (GstElement *element);

Brings the element to the lost state. This function calls `gst_element_lost_state_full()` with the new_base_time set to `TRUE`.

This function is used internally and should normally not be called from plugins or applications.

MT safe.

`element` : | a GstElement the state is lost of

### gst_element_lost_state_full ()

    void                gst_element_lost_state_full         (GstElement *element,
                                                             gboolean new_base_time);

Brings the element to the lost state. The current state of the element is copied to the pending state so that any call to `gst_element_get_state()` will return `GST_STATE_CHANGE_ASYNC`.

An ASYNC_START message is posted with indication to distribute a new base_time to the element when `new_base_time` is `TRUE`. If the element was PLAYING, it will go to PAUSED. The element will be restored to its PLAYING state by the parent pipeline when it prerolls again.

This is mostly used for elements that lost their preroll buffer in the `GST_STATE_PAUSED` or `GST_STATE_PLAYING` state after a flush, they will go to their pending state again when a new preroll buffer is queued. This function can only be called when the element is currently not in error or an async state change.

This function is used internally and should normally not be called from plugins or applications.

MT safe.

`element` : | a GstElement the state is lost of
`new_base_time` : | if a new base time should be distributed

Since 0.10.24

### gst_element_state_get_name ()

    const gchar *       gst_element_state_get_name          (GstState state);

Gets a string representing the given state.

`state` : | a GstState to get the name of.
Returns : | a string with the name of the state. [transfer none]

### gst_element_state_change_return_get_name ()

    const gchar *       gst_element_state_change_return_get_name
                                                            (GstStateChangeReturn state_ret);

Gets a string representing the given state change result.

`state_ret` : | a GstStateChangeReturn to get the name of.
Returns : | a string with the name of the state result. [transfer none]

Since 0.10.11

### gst_element_sync_state_with_parent ()

    gboolean            gst_element_sync_state_with_parent  (GstElement *element);

Tries to change the state of the element to the same as its parent. If this function returns FALSE, the state of element is undefined.

`element` : | a GstElement.
Returns : | TRUE, if the element's state could be synced to the parent's state. MT safe.

### gst_element_change_state ()

    GstStateChangeReturn gst_element_change_state           (GstElement *element,
                                                             GstStateChange transition);

Perform `transition` on `element`.

This function must be called with STATE_LOCK held and is mainly used internally.

`element` : | a GstElement
`transition` : | the requested transition
Returns : | the GstStateChangeReturn of the state transition.

### gst_element_found_tags ()

    void                gst_element_found_tags              (GstElement *element,
                                                             GstTagList *list);

Posts a message to the bus that new tags were found, and pushes an event to all sourcepads. Takes ownership of the `list`.

This is a utility method for elements. Applications should use the GstTagSetter interface.

`element` : | element for which we found the tags.
`list` : | list of tags. [transfer full]

### gst_element_found_tags_for_pad ()

    void                gst_element_found_tags_for_pad      (GstElement *element,
                                                             GstPad *pad,
                                                             GstTagList *list);

Posts a message to the bus that new tags were found and pushes the tags as event. Takes ownership of the `list`.

This is a utility method for elements. Applications should use the GstTagSetter interface.

`element` : | element for which to post taglist to bus.
`pad` : | pad on which to push tag-event. [transfer none]
`list` : | the taglist to post on the bus and create event from. [transfer full]

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

Post an error, warning or info message on the bus from inside an element.

`type` must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or GST_MESSAGE_INFO.

MT safe.

`element` : | a GstElement to send message from
`type` : | the GstMessageType
`domain` : | the GStreamer GError domain this message belongs to
`code` : | the GError code belonging to the domain
`text` : | an allocated text string to be used as a replacement for the default message connected to code, or `NULL`. [allow-none][transfer full]
`debug` : | an allocated debug message to be used as a replacement for the default debugging information, or `NULL`. [allow-none][transfer full]
`file` : | the source code file where the error was generated
`function` : | the source code function where the error was generated
`line` : | the source code line where the error was generated

### gst_element_post_message ()

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

Post a message on the element's GstBus. This function takes ownership of the message; if you want to access the message after this call, you should add an additional reference before calling.

`element` : | a GstElement posting the message
`message` : | a GstMessage to post. [transfer full]
Returns : | `TRUE` if the message was successfully posted. The function returns `FALSE` if the element did not have a bus. MT safe.

### gst_element_get_query_types ()

    const GstQueryType * gst_element_get_query_types        (GstElement *element);

Get an array of query types from the element. If the element doesn't implement a query types function, the query will be forwarded to the peer of a random linked sink pad.

`element` : | a GstElement to query
Returns : | An array of GstQueryType elements that should not be freed or modified. MT safe.

### gst_element_query ()

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

Performs a query on the given element.

For elements that don't implement a query handler, this function forwards the query to a random srcpad or to the peer of a random linked sinkpad of this element.

Please note that some queries might need a running pipeline to work.

`element` : | a GstElement to perform the query on.
`query` : | the GstQuery. [transfer none]
Returns : | TRUE if the query could be performed. MT safe.

### gst_element_query_convert ()

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

Queries an element to convert `src_val` in `src_format` to `dest_format`.

`element` : | a GstElement to invoke the convert query on.
`src_format` : | a GstFormat to convert from. [inout]
`src_val` : | a value to convert.
`dest_format` : | a pointer to the GstFormat to convert to. [inout]
`dest_val` : | a pointer to the result. [out]
Returns : | TRUE if the query could be performed.

### gst_element_query_position ()

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

Queries an element for the stream position. If one repeatedly calls this function one can also create and reuse it in `gst_element_query()`.

`element` : | a GstElement to invoke the position query on.
`format` : | a pointer to the GstFormat asked for. On return contains the GstFormat used. [inout]
`cur` : | a location in which to store the current position, or NULL. [out][allow-none]
Returns : | TRUE if the query could be performed.

### gst_element_query_duration ()

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

Queries an element for the total stream duration.

`element` : | a GstElement to invoke the duration query on.
`format` : | a pointer to the GstFormat asked for. On return contains the GstFormat used. [inout]
`duration` : | A location in which to store the total duration, or NULL. [out]
Returns : | TRUE if the query could be performed.

### gst_element_send_event ()

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

Sends an event to an element. If the element doesn't implement an event handler, the event will be pushed on a random linked sink pad for upstream events or a random linked source pad for downstream events.

This function takes owership of the provided event so you should `gst_event_ref()` it if you want to reuse the event after this call.

`element` : | a GstElement to send the event to.
`event` : | the GstEvent to send to the element. [transfer full]
Returns : | `TRUE` if the event was handled. MT safe.

### gst_element_seek_simple ()

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

Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use `gst_element_seek()`.

In a completely prerolled PAUSED or PLAYING pipeline, seeking is always guaranteed to return `TRUE` on a seekable media type or `FALSE` when the media type is certainly not seekable (such as a live stream).

Some elements allow for seeking in the READY state, in this case they will store the seek event and execute it when they are put to PAUSED. If the element supports seek in READY, it will always return `TRUE` when it receives the event in the READY state.

`element` : | a GstElement to seek on
`format` : | a GstFormat to execute the seek in, such as GST_FORMAT_TIME
`seek_flags` : | seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here
`seek_pos` : | position to seek to (relative to the start); if you are doing a seek in GST_FORMAT_TIME this value is in nanoseconds - multiply with GST_SECOND to convert seconds to nanoseconds or with GST_MSECOND to convert milliseconds to nanoseconds.
Returns : | `TRUE` if the seek operation succeeded (the seek might not always be executed instantly though)

Since 0.10.7

### gst_element_seek ()

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

Sends a seek event to an element. See `gst_event_new_seek()` for the details of the parameters. The seek event is sent to the element using `gst_element_send_event()`.

`element` : | a GstElement to send the event to.
`rate` : | The new playback rate
`format` : | The format of the seek values
`flags` : | The optional seek flags.
`cur_type` : | The type and flags for the new current position
`cur` : | The value of the new current position
`stop_type` : | The type and flags for the new stop position
`stop` : | The value of the new stop position
Returns : | `TRUE` if the event was handled. MT safe.

## Signal Details

### The `"no-more-pads"` signal

    void                user_function                      (GstElement *gstelement,
                                                            gpointer    user_data)       : Run Last

This signals that the element will not generate more dynamic pads. Note that this signal will usually be emitted from the context of the streaming thread.

`gstelement` : | the object which received the signal
`user_data` : | user data set when the signal handler was connected.

### The `"pad-added"` signal

    void                user_function                      (GstElement *gstelement,
                                                            GstPad     *new_pad,
                                                            gpointer    user_data)       : Run Last

a new GstPad has been added to the element. Note that this signal will usually be emitted from the context of the streaming thread. Also keep in mind that if you add new elements to the pipeline in the signal handler you will need to set them to the desired target state with `gst_element_set_state()` or `gst_element_sync_state_with_parent()`.

`gstelement` : | the object which received the signal
`new_pad` : | the pad that has been added
`user_data` : | user data set when the signal handler was connected.

### The `"pad-removed"` signal

    void                user_function                      (GstElement *gstelement,
                                                            GstPad     *old_pad,
                                                            gpointer    user_data)       : Run Last

a GstPad has been removed from the element

`gstelement` : | the object which received the signal
`old_pad` : | the pad that has been removed
`user_data` : | user data set when the signal handler was connected.

## See Also

GstElementFactory, GstPad