## GstObject GstObject — Base class for the GStreamer object hierarchy |

## Functions

#define | GST_OBJECT_FLAGS()
#define | GST_OBJECT_FLAG_IS_SET()
#define | GST_OBJECT_FLAG_SET()
#define | GST_OBJECT_FLAG_UNSET()
#define | GST_OBJECT_NAME()
#define | GST_OBJECT_PARENT()
#define | GST_OBJECT_REFCOUNT()
#define | GST_OBJECT_REFCOUNT_VALUE()
#define | GST_OBJECT_LOCK()
#define | GST_OBJECT_TRYLOCK()
#define | GST_OBJECT_UNLOCK()
#define | GST_OBJECT_GET_LOCK()
gboolean | gst_object_set_name ()
gchar * | gst_object_get_name ()
gboolean | gst_object_set_parent ()
GstObject * | gst_object_get_parent ()
gboolean | gst_object_has_as_parent ()
void | gst_object_unparent ()
void | gst_object_default_deep_notify ()
void | gst_object_default_error ()
gboolean | gst_object_check_uniqueness ()
gboolean | gst_object_has_as_ancestor ()
gboolean | gst_object_has_ancestor ()
gpointer | gst_object_ref ()
void | gst_object_unref ()
gpointer | gst_object_ref_sink ()
gboolean | gst_object_replace ()
gchar * | gst_object_get_path_string ()
GstClockTime | gst_object_suggest_next_sync ()
gboolean | gst_object_sync_values ()
gboolean | gst_object_has_active_control_bindings ()
void | gst_object_set_control_bindings_disabled ()
void | gst_object_set_control_binding_disabled ()
gboolean | gst_object_add_control_binding ()
GstControlBinding * | gst_object_get_control_binding ()
gboolean | gst_object_remove_control_binding ()
GValue * | gst_object_get_value ()
gboolean | gst_object_get_value_array ()
gboolean | gst_object_get_g_value_array ()
GstClockTime | gst_object_get_control_rate ()
void | gst_object_set_control_rate ()

## Properties

gchar * | name | Read / Write / Construct
GstObject * | parent | Read / Write

## Signals

void | deep-notify | No Hooks

## Types and Values

struct | GstObject
struct | GstObjectClass
enum | GstObjectFlags

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ├── GstAllocator
                ├── GstPad
                ├── GstPadTemplate
                ├── GstPluginFeature
                ├── GstElement
                ├── GstBus
                ├── GstTask
                ├── GstTaskPool
                ├── GstClock
                ├── GstControlBinding
                ├── GstControlSource
                ├── GstPlugin
                ├── GstRegistry
                ├── GstBufferPool
                ├── GstTracer
                ╰── GstTracerRecord

## Includes

    #include <gst/gst.h>

## Description

GstObject provides a root for the object hierarchy tree filed in by the GStreamer library. It is currently a thin wrapper on top of GInitiallyUnowned. It is an abstract class that is not very usable on its own.

GstObject gives us basic refcounting, parenting functionality and locking. Most of the functions are just extended for special GStreamer needs and can be found under the same name in the base class of GstObject which is GObject (e.g. `g_object_ref()` becomes `gst_object_ref()`).

Since GstObject derives from GInitiallyUnowned, it also inherits the floating reference. Be aware that functions such as `gst_bin_add()` and `gst_element_add_pad()` take ownership of the floating reference.

In contrast to GObject instances, GstObject adds a name property. The functions `gst_object_set_name()` and `gst_object_get_name()` are used to set/get the name of the object.

#### controlled properties

Controlled properties offers a lightweight way to adjust gobject properties over stream-time. It works by using time-stamped value pairs that are queued for element-properties. At run-time the elements continuously pull value changes for the current stream-time.

What needs to be changed in a GstElement? Very little - it is just two steps to make a plugin controllable!

- mark gobject-properties paramspecs that make sense to be controlled, by GST_PARAM_CONTROLLABLE.

- when processing data (get, chain, loop function) at the beginning call gst_object_sync_values(element,timestamp). This will make the controller update all GObject properties that are under its control with the current values based on the timestamp.

What needs to be done in applications? Again it's not a lot to change.

- create a GstControlSource. csource = `gst_interpolation_control_source_new()`; g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);

- Attach the GstControlSource on the controller to a property. gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource));

- Set the control values gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1); gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);

- start your pipeline

## Functions

### GST_OBJECT_FLAGS()

    #define GST_OBJECT_FLAGS(obj)                  (GST_OBJECT_CAST (obj)->flags)

This macro returns the entire set of flags for the object.

#### Parameters

obj | a GstObject |

### GST_OBJECT_FLAG_IS_SET()

    #define GST_OBJECT_FLAG_IS_SET(obj,flag)       ((GST_OBJECT_FLAGS (obj) & (flag)) == (flag))

This macro checks to see if the given flag is set.

#### Parameters

obj | a GstObject |
flag | Flag to check for |

### GST_OBJECT_FLAG_SET()

    #define GST_OBJECT_FLAG_SET(obj,flag)          (GST_OBJECT_FLAGS (obj) |= (flag))

This macro sets the given bits.

#### Parameters

obj | a GstObject |
flag | Flag to set |

### GST_OBJECT_FLAG_UNSET()

    #define GST_OBJECT_FLAG_UNSET(obj,flag)        (GST_OBJECT_FLAGS (obj) &= ~(flag))

This macro unsets the given bits.

#### Parameters

obj | a GstObject |
flag | Flag to set |

### GST_OBJECT_NAME()

    #define GST_OBJECT_NAME(obj)            (GST_OBJECT_CAST(obj)->name)

Get the name of this object. This is not thread-safe by default (i.e. you will have to make sure the object lock is taken yourself). If in doubt use `gst_object_get_name()` instead.

#### Parameters

obj | a GstObject |

### GST_OBJECT_PARENT()

    #define GST_OBJECT_PARENT(obj)          (GST_OBJECT_CAST(obj)->parent)

Get the parent of this object. This is not thread-safe by default (i.e. you will have to make sure the object lock is taken yourself). If in doubt use `gst_object_get_parent()` instead.

#### Parameters

obj | a GstObject |

### GST_OBJECT_REFCOUNT()

    #define GST_OBJECT_REFCOUNT(obj)                (((GObject*)(obj))->ref_count)

Get access to the reference count field of the object.

#### Parameters

obj | a GstObject |

### GST_OBJECT_REFCOUNT_VALUE()

    #define GST_OBJECT_REFCOUNT_VALUE(obj)          g_atomic_int_get ((gint *) &GST_OBJECT_REFCOUNT(obj))

Get the reference count value of the object.

#### Parameters

obj | a GstObject |

### GST_OBJECT_LOCK()

    #define GST_OBJECT_LOCK(obj)                   g_mutex_lock(GST_OBJECT_GET_LOCK(obj))

This macro will obtain a lock on the object, making serialization possible. It blocks until the lock can be obtained.

#### Parameters

obj | a GstObject to lock |

### GST_OBJECT_TRYLOCK()

    #define GST_OBJECT_TRYLOCK(obj)                g_mutex_trylock(GST_OBJECT_GET_LOCK(obj))

This macro will try to obtain a lock on the object, but will return with `FALSE` if it can't get it immediately.

#### Parameters

obj | a GstObject. |

### GST_OBJECT_UNLOCK()

    #define GST_OBJECT_UNLOCK(obj)                 g_mutex_unlock(GST_OBJECT_GET_LOCK(obj))

This macro releases a lock on the object.

#### Parameters

obj | a GstObject to unlock. |

### GST_OBJECT_GET_LOCK()

    #define GST_OBJECT_GET_LOCK(obj)               (&GST_OBJECT_CAST(obj)->lock)

Acquire a reference to the mutex of this object.

#### Parameters

obj | a GstObject |

### gst_object_set_name ()

    gboolean
    gst_object_set_name (GstObject *object,
                         const gchar *name);

Sets the name of `object` , or gives `object` a guaranteed unique name (if `name` is `NULL`). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.

#### Parameters

object | a GstObject |
name | new name of object. | [allow-none]

#### Returns

`TRUE` if the name could be set. Since Objects that have a parent cannot be renamed, this function returns `FALSE` in those cases.

MT safe. This function grabs and releases `object` 's LOCK.

### gst_object_get_name ()

    gchar *
    gst_object_get_name (GstObject *object);

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

Free-function: g_free

#### Parameters

object | a GstObject |

#### Returns

the name of `object` . `g_free()` after usage.

MT safe. This function grabs and releases `object` 's LOCK.

[transfer full][nullable]

### gst_object_set_parent ()

    gboolean
    gst_object_set_parent (GstObject *object,
                           GstObject *parent);

Sets the parent of `object` to `parent` . The object's reference count will be incremented, and any floating reference will be removed (see `gst_object_ref_sink()`).

#### Parameters

object | a GstObject. | [transfer floating]
parent | new parent of object |

#### Returns

`TRUE` if `parent` could be set or `FALSE` when `object` already had a parent or `object` and `parent` are the same.

MT safe. Grabs and releases `object` 's LOCK.

### gst_object_get_parent ()

    GstObject *
    gst_object_get_parent (GstObject *object);

Returns the parent of `object` . This function increases the refcount of the parent object so you should `gst_object_unref()` it after usage.

#### Parameters

object | a GstObject |

#### Returns

parent of `object` , this can be `NULL` if `object` has no parent. unref after usage.

MT safe. Grabs and releases `object` 's LOCK.

[transfer full][nullable]

### gst_object_has_as_parent ()

    gboolean
    gst_object_has_as_parent (GstObject *object,
                              GstObject *parent);

Check if `parent` is the parent of `object` . E.g. a GstElement can check if it owns a given GstPad.

#### Parameters

object | a GstObject to check |
parent | a GstObject to check as parent |

#### Returns

`FALSE` if either `object` or `parent` is `NULL`. `TRUE` if `parent` is the parent of `object` . Otherwise `FALSE`.

MT safe. Grabs and releases `object` 's locks.

Since: 1.6

### gst_object_unparent ()

    void
    gst_object_unparent (GstObject *object);

Clear the parent of `object` , removing the associated reference. This function decreases the refcount of `object` .

MT safe. Grabs and releases `object` 's lock.

#### Parameters

object | a GstObject to unparent |

### gst_object_default_deep_notify ()

    void
    gst_object_default_deep_notify (GObject *object,
                                    GstObject *orig,
                                    GParamSpec *pspec,
                                    gchar **excluded_props);

A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print.

MT safe. This function grabs and releases `object` 's LOCK for getting its path string.

#### Parameters

object | the GObject that signalled the notify. |
orig | a GstObject that initiated the notify. |
pspec | a GParamSpec of the property. |
excluded_props | a set of user-specified properties to exclude or `NULL` to show all changes. | [array zero-terminated=1][element-type gchar*][allow-none]

### gst_object_default_error ()

    void
    gst_object_default_error (GstObject *source,
                              const GError *error,
                              const gchar *debug);

A default error function that uses `g_printerr()` to display the error message and the optional debug sting..

The default handler will simply print the error string using g_print.

#### Parameters

source | the GstObject that initiated the error. |
error | the GError. | [in]
debug | an additional debug information string, or `NULL`. | [in][allow-none]

### gst_object_check_uniqueness ()

    gboolean
    gst_object_check_uniqueness (GList *list,
                                 const gchar *name);

Checks to see if there is any object named `name` in `list` . This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock each GstObject in the list to compare the name, so be careful when passing a list with a locked object.

#### Parameters

list | a list of GstObject to check through. | [transfer none][element-type Gst.Object]
name | the name to search for |

#### Returns

`TRUE` if a GstObject named `name` does not appear in `list` , `FALSE` if it does.

MT safe. Grabs and releases the LOCK of each object in the list.

### gst_object_has_as_ancestor ()

    gboolean
    gst_object_has_as_ancestor (GstObject *object,
                                GstObject *ancestor);

Check if `object` has an ancestor `ancestor` somewhere up in the hierarchy. One can e.g. check if a GstElement is inside a GstPipeline.

#### Parameters

object | a GstObject to check |
ancestor | a GstObject to check as ancestor |

#### Returns

`TRUE` if `ancestor` is an ancestor of `object` .

MT safe. Grabs and releases `object` 's locks.

### gst_object_has_ancestor ()

    gboolean
    gst_object_has_ancestor (GstObject *object,
                             GstObject *ancestor);

`gst_object_has_ancestor` is deprecated and should not be used in newly-written code.

Use `gst_object_has_as_ancestor()` instead.

MT safe. Grabs and releases `object` 's locks.

Check if `object` has an ancestor `ancestor` somewhere up in the hierarchy. One can e.g. check if a GstElement is inside a GstPipeline.

#### Parameters

object | a GstObject to check |
ancestor | a GstObject to check as ancestor |

#### Returns

`TRUE` if `ancestor` is an ancestor of `object` .

### gst_object_ref ()

    gpointer
    gst_object_ref (gpointer object);

Increments the reference count on `object` . This function does not take the lock on `object` because it relies on atomic refcounting.

This object returns the input parameter to ease writing constructs like : result = gst_object_ref (object->parent);

#### Parameters

object | a GstObject to reference. | [type Gst.Object]

#### Returns

A pointer to `object` .

[transfer full][type Gst.Object]

### gst_object_unref ()

    void
    gst_object_unref (gpointer object);

Decrements the reference count on `object` . If reference count hits zero, destroy `object` . This function does not take the lock on `object` as it relies on atomic refcounting.

The unref method should never be called with the LOCK held since this might deadlock the dispose function.

#### Parameters

object | a GstObject to unreference. | [type Gst.Object]

### gst_object_ref_sink ()

    gpointer
    gst_object_ref_sink (gpointer object);

Increase the reference count of `object` , and possibly remove the floating reference, if `object` has a floating reference.

In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

For more background on "floating references" please see the GObject documentation.

[skip]

#### Parameters

object | a GstObject to sink |

### gst_object_replace ()

    gboolean
    gst_object_replace (GstObject **oldobj,
                        GstObject *newobj);

Atomically modifies a pointer to point to a new object. The reference count of `oldobj` is decreased and the reference count of `newobj` is increased.

Either `newobj` and the value pointed to by `oldobj` may be `NULL`.

#### Parameters

oldobj | pointer to a place of a GstObject to replace. | [inout][transfer full][nullable]
newobj | a new GstObject. | [transfer none][allow-none]

#### Returns

`TRUE` if `newobj` was different from `oldobj`

### gst_object_get_path_string ()

    gchar *
    gst_object_get_path_string (GstObject *object);

Generates a string describing the path of `object` in the object hierarchy. Only useful (or used) for debugging.

Free-function: g_free

#### Parameters

object | a GstObject |

#### Returns

a string describing the path of `object` . You must `g_free()` the string after usage.

MT safe. Grabs and releases the GstObject's LOCK for all objects in the hierarchy.

[transfer full]

### gst_object_suggest_next_sync ()

    GstClockTime
    gst_object_suggest_next_sync (GstObject *object);

Returns a suggestion for timestamps where buffers should be split to get best controller results.

#### Parameters

object | the object that has controlled properties |

#### Returns

Returns the suggested timestamp or `GST_CLOCK_TIME_NONE` if no control-rate was set.

### gst_object_sync_values ()

    gboolean
    gst_object_sync_values (GstObject *object,
                            GstClockTime timestamp);

Sets the properties of the object, according to the GstControlSources that (maybe) handle them and for the given timestamp.

If this function fails, it is most likely the application developers fault. Most probably the control sources are not setup correctly.

#### Parameters

object | the object that has controlled properties |
timestamp | the time that should be processed |

#### Returns

`TRUE` if the controller values could be applied to the object properties, `FALSE` otherwise

### gst_object_has_active_control_bindings ()

    gboolean
    gst_object_has_active_control_bindings
                                   (GstObject *object);

Check if the `object` has active controlled properties.

#### Parameters

object | the object that has controlled properties |

#### Returns

`TRUE` if the object has active controlled properties

### gst_object_set_control_bindings_disabled ()

    void
    gst_object_set_control_bindings_disabled
                                   (GstObject *object,
                                    gboolean disabled);

This function is used to disable all controlled properties of the `object` for some time, i.e. `gst_object_sync_values()` will do nothing.

#### Parameters

object | the object that has controlled properties |
disabled | boolean that specifies whether to disable the controller or not. |

### gst_object_set_control_binding_disabled ()

    void
    gst_object_set_control_binding_disabled
                                   (GstObject *object,
                                    const gchar *property_name,
                                    gboolean disabled);

This function is used to disable the control bindings on a property for some time, i.e. `gst_object_sync_values()` will do nothing for the property.

#### Parameters

object | the object that has controlled properties |
property_name | property to disable |
disabled | boolean that specifies whether to disable the controller or not. |

### gst_object_add_control_binding ()

    gboolean
    gst_object_add_control_binding (GstObject *object,
                                    GstControlBinding *binding);

Attach the GstControlBinding to the object. If there already was a GstControlBinding for this property it will be replaced.

The object's reference count will be incremented, and any floating reference will be removed (see `gst_object_ref_sink()`)

#### Parameters

object | the controller object |
binding | the GstControlBinding that should be used. | [transfer floating]

#### Returns

`FALSE` if the given `binding` has not been setup for this object or has been setup for a non suitable property, `TRUE` otherwise.

### gst_object_get_control_binding ()

    GstControlBinding *
    gst_object_get_control_binding (GstObject *object,
                                    const gchar *property_name);

Gets the corresponding GstControlBinding for the property. This should be unreferenced again after use.

#### Parameters

object | the object |
property_name | name of the property |

#### Returns

the GstControlBinding for `property_name` or `NULL` if the property is not controlled.

[transfer full][nullable]

### gst_object_remove_control_binding ()

    gboolean
    gst_object_remove_control_binding (GstObject *object,
                                       GstControlBinding *binding);

Removes the corresponding GstControlBinding. If it was the last ref of the binding, it will be disposed.

#### Parameters

object | the object |
binding | the binding |

#### Returns

`TRUE` if the binding could be removed.

### gst_object_get_value ()

    GValue *
    gst_object_get_value (GstObject *object,
                          const gchar *property_name,
                          GstClockTime timestamp);

Gets the value for the given controlled property at the requested time.

#### Parameters

object | the object that has controlled properties |
property_name | the name of the property to get |
timestamp | the time the control-change should be read from |

#### Returns

the GValue of the property at the given time, or `NULL` if the property isn't controlled.

[nullable]

### gst_object_get_value_array ()

    gboolean
    gst_object_get_value_array (GstObject *object,
                                const gchar *property_name,
                                GstClockTime timestamp,
                                GstClockTime interval,
                                guint n_values,
                                gpointer values);

Gets a number of values for the given controlled property starting at the requested time. The array `values` need to hold enough space for `n_values` of the same type as the objects property's type.

This function is useful if one wants to e.g. draw a graph of the control curve or apply a control curve sample by sample.

The values are unboxed and ready to be used. The similar function `gst_object_get_g_value_array()` returns the array as GValues and is better suites for bindings.

[skip]

#### Parameters

object | the object that has controlled properties |
property_name | the name of the property to get |
timestamp | the time that should be processed |
interval | the time spacing between subsequent values |
n_values | the number of values |
values | array to put control-values in |

#### Returns

`TRUE` if the given array could be filled, `FALSE` otherwise

### gst_object_get_g_value_array ()

    gboolean
    gst_object_get_g_value_array (GstObject *object,
                                  const gchar *property_name,
                                  GstClockTime timestamp,
                                  GstClockTime interval,
                                  guint n_values,
                                  GValue *values);

Gets a number of GValues for the given controlled property starting at the requested time. The array `values` need to hold enough space for `n_values` of GValue.

This function is useful if one wants to e.g. draw a graph of the control curve or apply a control curve sample by sample.

#### Parameters

object | the object that has controlled properties |
property_name | the name of the property to get |
timestamp | the time that should be processed |
interval | the time spacing between subsequent values |
n_values | the number of values |
values | array to put control-values in. | [array length=n_values]

#### Returns

`TRUE` if the given array could be filled, `FALSE` otherwise

### gst_object_get_control_rate ()

    GstClockTime
    gst_object_get_control_rate (GstObject *object);

Obtain the control-rate for this `object` . Audio processing GstElement objects will use this rate to sub-divide their processing loop and call `gst_object_sync_values()` inbetween. The length of the processing segment should be up to `control` -rate nanoseconds.

If the `object` is not under property control, this will return `GST_CLOCK_TIME_NONE`. This allows the element to avoid the sub-dividing.

The control-rate is not expected to change if the element is in `GST_STATE_PAUSED` or `GST_STATE_PLAYING`.

#### Parameters

object | the object that has controlled properties |

#### Returns

the control rate in nanoseconds

### gst_object_set_control_rate ()

    void
    gst_object_set_control_rate (GstObject *object,
                                 GstClockTime control_rate);

Change the control-rate for this `object` . Audio processing GstElement objects will use this rate to sub-divide their processing loop and call `gst_object_sync_values()` inbetween. The length of the processing segment should be up to `control` -rate nanoseconds.

The control-rate should not change if the element is in `GST_STATE_PAUSED` or `GST_STATE_PLAYING`.

#### Parameters

object | the object that has controlled properties |
control_rate | the new control-rate in nanoseconds. |

## Types and Values

### struct GstObject

    struct GstObject {
      GMutex         lock;        /* object LOCK */
      gchar         *name;        /* object name */
      GstObject     *parent;      /* this object's parent, weak ref */
      guint32        flags;
    };

GStreamer base object class.

#### Members

GMutex `lock`; | object LOCK |
gchar *`name`; | The name of the object |
GstObject *`parent`; | this object's parent, weak ref |
guint32 `flags`; | flags for this object |

### struct GstObjectClass

    struct GstObjectClass {
      GInitiallyUnownedClass parent_class;

      const gchar *path_string_separator;

      /* signals */
      void          (*deep_notify)      (GstObject * object, GstObject * orig, GParamSpec * pspec);

      /* virtual methods for subclasses */
    };

GStreamer base object class.

#### Members

const gchar *`path_string_separator`; | separator used by `gst_object_get_path_string()` |
`deep_notify` () | default signal handler |

### enum GstObjectFlags

The standard flags that an gstobject may have.

#### Members

GST_OBJECT_FLAG_MAY_BE_LEAKED | the object is expected to stay alive even after `gst_deinit()` has been called and so should be ignored by leak detection tools. (Since 1.10) |
GST_OBJECT_FLAG_LAST | subclasses can add additional flags starting from this flag |

## Property Details

### The `“name”` property

      “name”                     gchar *

The name of the object.

Flags: Read / Write / Construct

Default value: NULL

### The `“parent”` property

      “parent”                   GstObject *

The parent of the object. Please note, that when changing the 'parent' property, we don't emit “notify” and “deep-notify” signals due to locking issues. In some cases one can use “element-added” or “element-removed” signals on the parent to achieve a similar effect.

Flags: Read / Write

## Signal Details

### The `“deep-notify”` signal

    void
    user_function (GstObject  *gstobject,
                   GstObject  *prop_object,
                   GParamSpec *prop,
                   gpointer    user_data)

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

#### Parameters

gstobject | a GstObject |
prop_object | the object that originated the signal |
prop | the property that changed |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks