3 * Copyright (C) 2005 Stefan Kost <ensonic at users dot sf dot net>
4 * 2007 Sebastian Dröge <slomo@circular-chaos.org>
5 * 2011 Stefan Sauer <ensonic at users dot sf dot net>
7 * gstcontroller.c: dynamic parameter control subsystem
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 * SECTION:gstcontroller
27 * @short_description: dynamic parameter control subsystem
29 * The controller subsystem offers a lightweight way to adjust gobject
30 * properties over stream-time. It works by using time-stamped value pairs that
31 * are queued for element-properties. At run-time the elements continously pull
32 * values changes for the current stream-time.
34 * What needs to be changed in a #GstElement?
35 * Very little - it is just two steps to make a plugin controllable!
38 * mark gobject-properties paramspecs that make sense to be controlled,
39 * by GST_PARAM_CONTROLLABLE.
42 * when processing data (get, chain, loop function) at the beginning call
43 * gst_object_sync_values(element,timestamp).
44 * This will made the controller to update all gobject properties that are under
45 * control with the current values based on timestamp.
49 * What needs to be done in applications?
50 * Again its not a lot to change.
53 * first put some properties under control, by calling
54 * controller = gst_object_control_properties (object, "prop1", "prop2",...);
57 * create a #GstControlSource.
58 * csource = gst_interpolation_control_source_new ();
59 * gst_interpolation_control_source_set_interpolation_mode(csource, mode);
62 * Attach the #GstControlSource on the controller to a property.
63 * gst_controller_set_control_source (controller, "prop1", csource);
66 * Set the control values
67 * gst_interpolation_control_source_set (csource,0 * GST_SECOND, value1);
68 * gst_interpolation_control_source_set (csource,1 * GST_SECOND, value2);
76 #include "gst_private.h"
78 #include "gstobject.h"
81 #include "gstcontroller.h"
82 #include "gstcontrolsource.h"
83 #include "gstparamspecs.h"
85 #define GST_CAT_DEFAULT controller_debug
86 GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
88 static GObjectClass *parent_class = NULL;
96 struct _GstControllerPrivate
98 GstClockTime control_rate;
99 GstClockTime last_sync;
105 * GstControlledProperty:
107 typedef struct _GstControlledProperty
109 GParamSpec *pspec; /* GParamSpec for this property */
110 const gchar *name; /* name of the property */
111 GstControlSource *csource; /* GstControlSource for this property */
114 } GstControlledProperty;
116 #define GST_CONTROLLED_PROPERTY(obj) ((GstControlledProperty *)(obj))
119 * gst_controlled_property_new:
120 * @object: for which object the controlled property should be set up
121 * @name: the name of the property to be controlled
123 * Private method which initializes the fields of a new controlled property
126 * Returns: a freshly allocated structure or %NULL
128 static GstControlledProperty *
129 gst_controlled_property_new (GstObject * object, const gchar * name)
131 GstControlledProperty *prop = NULL;
134 GST_INFO ("trying to put property '%s' under control", name);
136 /* check if the object has a property of that name */
138 g_object_class_find_property (G_OBJECT_GET_CLASS (object), name))) {
139 GST_DEBUG (" psec->flags : 0x%08x", pspec->flags);
141 /* check if this param is witable && controlable && !construct-only */
142 g_return_val_if_fail ((pspec->flags & (G_PARAM_WRITABLE |
143 GST_PARAM_CONTROLLABLE | G_PARAM_CONSTRUCT_ONLY)) ==
144 (G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE), NULL);
146 if ((prop = g_slice_new (GstControlledProperty))) {
148 prop->name = pspec->name;
149 prop->csource = NULL;
150 prop->disabled = FALSE;
151 memset (&prop->last_value, 0, sizeof (GValue));
152 g_value_init (&prop->last_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
155 GST_WARNING ("class '%s' has no property '%s'", G_OBJECT_TYPE_NAME (object),
162 * gst_controlled_property_free:
163 * @prop: the object to free
165 * Private method which frees all data allocated by a #GstControlledProperty
169 gst_controlled_property_free (GstControlledProperty * prop)
172 g_object_unref (prop->csource);
173 g_value_unset (&prop->last_value);
174 g_slice_free (GstControlledProperty, prop);
178 * gst_controller_find_controlled_property:
179 * @self: the controller object to search for a property in
180 * @name: the gobject property name to look for
182 * Searches the list of properties under control.
184 * Returns: a #GstControlledProperty object of %NULL if the property is not
187 static GstControlledProperty *
188 gst_controller_find_controlled_property (GstController * self,
191 GstControlledProperty *prop;
194 for (node = self->properties; node; node = g_list_next (node)) {
196 /* FIXME: eventually use GQuark to speed it up */
197 if (!strcmp (prop->name, name)) {
201 GST_DEBUG ("controller does not (yet) manage property '%s'", name);
207 * gst_controller_add_property:
208 * @self: the controller object
209 * @name: name of projecty in @object
211 * Creates a new #GstControlledProperty if there is none for property @name yet.
213 * Returns: %TRUE if the property has been added to the controller
216 gst_controller_add_property (GstController * self, const gchar * name)
220 /* test if this property isn't yet controlled */
221 if (!gst_controller_find_controlled_property (self, name)) {
222 GstControlledProperty *prop;
224 /* create GstControlledProperty and add to self->properties list */
225 if ((prop = gst_controlled_property_new (self->object, name))) {
226 self->properties = g_list_prepend (self->properties, prop);
227 GST_DEBUG_OBJECT (self->object, "property %s added", name);
231 GST_WARNING_OBJECT (self->object, "trying to control property %s again",
238 * gst_controller_remove_property:
239 * @self: the controller object
240 * @name: name of projecty in @object
242 * Removes a #GstControlledProperty for property @name.
244 * Returns: %TRUE if the property has been removed from the controller
247 gst_controller_remove_property (GstController * self, const gchar * name)
250 GstControlledProperty *prop;
252 if ((prop = gst_controller_find_controlled_property (self, name))) {
253 self->properties = g_list_remove (self->properties, prop);
254 //g_signal_handler_disconnect (self->object, prop->notify_handler_id);
255 gst_controlled_property_free (prop);
256 GST_DEBUG_OBJECT (self->object, "property %s removed", name);
266 * gst_controller_new_valist:
267 * @object: the object of which some properties should be controlled
268 * @var_args: %NULL terminated list of property names that should be controlled
270 * Creates a new GstController for the given object's properties
272 * Returns: the new controller.
275 gst_controller_new_valist (GstObject * object, va_list var_args)
280 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
282 /* FIXME: storing the controller into the object is ugly
283 * we'd like to make the controller object completely internal
285 self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
286 self->object = g_object_ref (object);
287 object->ctrl = g_object_ref (self);
289 /* create GstControlledProperty for each property */
290 while ((name = va_arg (var_args, gchar *))) {
291 gst_controller_add_property (self, name);
299 * gst_controller_new_list:
300 * @object: the object of which some properties should be controlled
301 * @list: (transfer none) (element-type utf8): list of property names
302 * that should be controlled
304 * Creates a new GstController for the given object's properties
306 * Rename to: gst_controller_new
308 * Returns: the new controller.
311 gst_controller_new_list (GstObject * object, GList * list)
317 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
319 self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
320 self->object = g_object_ref (object);
321 object->ctrl = g_object_ref (self);
323 /* create GstControlledProperty for each property */
324 for (node = list; node; node = g_list_next (node)) {
325 name = (gchar *) node->data;
326 gst_controller_add_property (self, name);
333 * gst_controller_new:
334 * @object: the object of which some properties should be controlled
335 * @...: %NULL terminated list of property names that should be controlled
337 * Creates a new GstController for the given object's properties
339 * Returns: the new controller.
342 gst_controller_new (GstObject * object, ...)
347 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
349 va_start (var_args, object);
350 self = gst_controller_new_valist (object, var_args);
358 gst_controller_add_properties_valist (GstController * self, va_list var_args)
363 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
365 while ((name = va_arg (var_args, gchar *))) {
366 /* find the property in the properties list of the controller, remove and free it */
367 g_mutex_lock (self->lock);
368 res &= gst_controller_add_property (self, name);
369 g_mutex_unlock (self->lock);
377 gst_controller_add_properties_list (GstController * self, GList * list)
383 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
385 for (tmp = list; tmp; tmp = g_list_next (tmp)) {
386 name = (gchar *) tmp->data;
388 /* find the property in the properties list of the controller, remove and free it */
389 g_mutex_lock (self->lock);
390 res &= gst_controller_add_property (self, name);
391 g_mutex_unlock (self->lock);
399 gst_controller_add_properties (GstController * self, ...)
404 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
406 va_start (var_args, self);
407 res = gst_controller_add_properties_valist (self, var_args);
414 * gst_controller_remove_properties_valist:
415 * @self: the controller object from which some properties should be removed
416 * @var_args: %NULL terminated list of property names that should be removed
418 * Removes the given object properties from the controller
420 * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
423 gst_controller_remove_properties_valist (GstController * self, va_list var_args)
428 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
430 while ((name = va_arg (var_args, gchar *))) {
431 /* find the property in the properties list of the controller, remove and free it */
432 g_mutex_lock (self->lock);
433 res &= gst_controller_remove_property (self, name);
434 g_mutex_unlock (self->lock);
441 * gst_controller_remove_properties_list:
442 * @self: the controller object from which some properties should be removed
443 * @list: (transfer none) (element-type utf8): #GList of property names that
446 * Removes the given object properties from the controller
448 * Rename to: gst_controller_remove_properties
450 * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
453 gst_controller_remove_properties_list (GstController * self, GList * list)
459 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
461 for (tmp = list; tmp; tmp = g_list_next (tmp)) {
462 name = (gchar *) tmp->data;
464 /* find the property in the properties list of the controller, remove and free it */
465 g_mutex_lock (self->lock);
466 res &= gst_controller_remove_property (self, name);
467 g_mutex_unlock (self->lock);
474 * gst_controller_remove_properties:
475 * @self: the controller object from which some properties should be removed
476 * @...: %NULL terminated list of property names that should be removed
478 * Removes the given object properties from the controller
480 * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
483 gst_controller_remove_properties (GstController * self, ...)
488 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
490 va_start (var_args, self);
491 res = gst_controller_remove_properties_valist (self, var_args);
498 * gst_controller_is_active:
499 * @self: the #GstController which should be disabled
501 * Check if the controller is active. It is active if it has at least one
502 * controlled property that is not disabled.
504 * Returns: %TRUE if the controller is active
507 gst_controller_is_active (GstController * self)
509 gboolean active = FALSE;
511 GstControlledProperty *prop;
513 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
515 g_mutex_lock (self->lock);
516 for (node = self->properties; node; node = node->next) {
518 active |= !prop->disabled;
520 g_mutex_unlock (self->lock);
526 * gst_controller_set_property_disabled:
527 * @self: the #GstController which should be disabled
528 * @property_name: property to disable
529 * @disabled: boolean that specifies whether to disable the controller
532 * This function is used to disable the #GstController on a property for
533 * some time, i.e. gst_controller_sync_values() will do nothing for the
537 gst_controller_set_property_disabled (GstController * self,
538 const gchar * property_name, gboolean disabled)
540 GstControlledProperty *prop;
542 g_return_if_fail (GST_IS_CONTROLLER (self));
543 g_return_if_fail (property_name);
545 g_mutex_lock (self->lock);
546 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
547 prop->disabled = disabled;
549 g_mutex_unlock (self->lock);
553 * gst_controller_set_disabled:
554 * @self: the #GstController which should be disabled
555 * @disabled: boolean that specifies whether to disable the controller
558 * This function is used to disable all properties of the #GstController
559 * for some time, i.e. gst_controller_sync_values() will do nothing.
563 gst_controller_set_disabled (GstController * self, gboolean disabled)
566 GstControlledProperty *prop;
568 g_return_if_fail (GST_IS_CONTROLLER (self));
570 g_mutex_lock (self->lock);
571 for (node = self->properties; node; node = node->next) {
573 prop->disabled = disabled;
575 g_mutex_unlock (self->lock);
579 * gst_controller_set_control_source:
580 * @self: the controller object
581 * @property_name: name of the property for which the #GstControlSource should be set
582 * @csource: the #GstControlSource that should be used for the property
584 * Sets the #GstControlSource for @property_name. If there already was a #GstControlSource
585 * for this property it will be unreferenced.
587 * Returns: %FALSE if the given property isn't handled by the controller or the new #GstControlSource
588 * couldn't be bound to the property, %TRUE if everything worked as expected.
591 gst_controller_set_control_source (GstController * self,
592 const gchar * property_name, GstControlSource * csource)
594 GstControlledProperty *prop;
595 gboolean ret = FALSE;
597 g_mutex_lock (self->lock);
598 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
599 GstControlSource *old = prop->csource;
601 if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) {
602 g_object_ref (csource);
603 prop->csource = csource;
604 } else if (!csource) {
606 prop->csource = NULL;
610 g_object_unref (old);
612 g_mutex_unlock (self->lock);
618 * gst_controller_get_control_source:
619 * @self: the controller object
620 * @property_name: name of the property for which the #GstControlSource should be get
622 * Gets the corresponding #GstControlSource for the property. This should be unreferenced
625 * Returns: (transfer full): the #GstControlSource for @property_name or NULL if
626 * the property is not controlled by this controller or no #GstControlSource was
630 gst_controller_get_control_source (GstController * self,
631 const gchar * property_name)
633 GstControlledProperty *prop;
634 GstControlSource *ret = NULL;
636 g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL);
637 g_return_val_if_fail (property_name, NULL);
639 g_mutex_lock (self->lock);
640 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
643 g_mutex_unlock (self->lock);
652 * gst_controller_get:
653 * @self: the controller object which handles the properties
654 * @property_name: the name of the property to get
655 * @timestamp: the time the control-change should be read from
657 * Gets the value for the given controller-handled property at the requested
660 * Returns: the GValue of the property at the given time, or %NULL if the
661 * property isn't handled by the controller
664 gst_controller_get (GstController * self, const gchar * property_name,
665 GstClockTime timestamp)
667 GstControlledProperty *prop;
670 g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL);
671 g_return_val_if_fail (property_name, NULL);
672 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), NULL);
674 g_mutex_lock (self->lock);
675 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
676 val = g_new0 (GValue, 1);
677 g_value_init (val, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
681 /* get current value via control source */
682 res = gst_control_source_get_value (prop->csource, timestamp, val);
688 g_object_get_property ((GObject *) self->object, prop->name, val);
691 g_mutex_unlock (self->lock);
697 * gst_controller_suggest_next_sync:
698 * @self: the controller that handles the values
700 * Returns a suggestion for timestamps where buffers should be split
701 * to get best controller results.
703 * Returns: Returns the suggested timestamp or %GST_CLOCK_TIME_NONE
704 * if no control-rate was set.
707 gst_controller_suggest_next_sync (GstController * self)
711 g_return_val_if_fail (GST_IS_CONTROLLER (self), GST_CLOCK_TIME_NONE);
712 g_return_val_if_fail (self->priv->control_rate != GST_CLOCK_TIME_NONE,
713 GST_CLOCK_TIME_NONE);
715 g_mutex_lock (self->lock);
717 /* TODO: Implement more logic, depending on interpolation mode
719 * FIXME: we need playback direction
721 ret = self->priv->last_sync + self->priv->control_rate;
723 g_mutex_unlock (self->lock);
729 * gst_controller_sync_values:
730 * @self: the controller that handles the values
731 * @timestamp: the time that should be processed
733 * Sets the properties of the element, according to the controller that (maybe)
734 * handles them and for the given timestamp.
736 * If this function fails, it is most likely the application developers fault.
737 * Most probably the control sources are not setup correctly.
739 * Returns: %TRUE if the controller values could be applied to the object
740 * properties, %FALSE otherwise
743 gst_controller_sync_values (GstController * self, GstClockTime timestamp)
745 GstControlledProperty *prop;
747 gboolean ret = TRUE, val_ret;
748 GValue value = { 0, };
750 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
751 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
753 GST_LOG ("sync_values");
755 g_mutex_lock (self->lock);
756 g_object_freeze_notify ((GObject *) self->object);
757 /* go over the controlled properties of the controller */
758 for (node = self->properties; node; node = g_list_next (node)) {
761 if (!prop->csource || prop->disabled)
764 GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
766 /* we can make this faster
767 * http://bugzilla.gnome.org/show_bug.cgi?id=536939
769 g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
770 val_ret = gst_control_source_get_value (prop->csource, timestamp, &value);
771 if (G_LIKELY (val_ret)) {
772 /* always set the value for first time, but then only if it changed
773 * this should limit g_object_notify invocations.
774 * FIXME: can we detect negative playback rates?
776 if ((timestamp < self->priv->last_sync) ||
777 gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) {
778 g_object_set_property ((GObject *) self->object, prop->name, &value);
779 g_value_copy (&value, &prop->last_value);
782 GST_DEBUG ("no control value for param %s", prop->name);
784 g_value_unset (&value);
787 self->priv->last_sync = timestamp;
788 g_object_thaw_notify ((GObject *) self->object);
790 g_mutex_unlock (self->lock);
796 * gst_controller_get_value_arrays:
797 * @self: the controller that handles the values
798 * @timestamp: the time that should be processed
799 * @value_arrays: list to return the control-values in
801 * Function to be able to get an array of values for one or more given element
804 * All fields of the %GstValueArray in the list must be filled correctly.
805 * Especially the GstValueArray->values arrays must be big enough to keep
806 * the requested amount of values.
808 * The types of the values in the array are the same as the property's type.
810 * <note><para>This doesn't modify the controlled GObject properties!</para></note>
812 * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise
815 gst_controller_get_value_arrays (GstController * self,
816 GstClockTime timestamp, GSList * value_arrays)
821 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
822 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
823 g_return_val_if_fail (value_arrays, FALSE);
825 for (node = value_arrays; (res && node); node = g_slist_next (node)) {
826 res = gst_controller_get_value_array (self, timestamp, node->data);
833 * gst_controller_get_value_array:
834 * @self: the controller that handles the values
835 * @timestamp: the time that should be processed
836 * @value_array: array to put control-values in
838 * Function to be able to get an array of values for one element property.
840 * All fields of @value_array must be filled correctly. Especially the
841 * @value_array->values array must be big enough to keep the requested amount
842 * of values (as indicated by the nbsamples field).
844 * The type of the values in the array is the same as the property's type.
846 * <note><para>This doesn't modify the controlled GObject property!</para></note>
848 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
851 gst_controller_get_value_array (GstController * self, GstClockTime timestamp,
852 GstValueArray * value_array)
854 gboolean res = FALSE;
855 GstControlledProperty *prop;
857 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
858 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
859 g_return_val_if_fail (value_array, FALSE);
860 g_return_val_if_fail (value_array->property_name, FALSE);
861 g_return_val_if_fail (value_array->values, FALSE);
863 g_mutex_lock (self->lock);
866 gst_controller_find_controlled_property (self,
867 value_array->property_name))) {
868 /* get current value_array via control source */
874 gst_control_source_get_value_array (prop->csource, timestamp,
879 g_mutex_unlock (self->lock);
883 /* gobject handling */
886 _gst_controller_get_property (GObject * object, guint property_id,
887 GValue * value, GParamSpec * pspec)
889 GstController *self = GST_CONTROLLER (object);
891 switch (property_id) {
892 case PROP_CONTROL_RATE:{
893 /* FIXME: don't change if element is playing, controller works for GObject
896 GstState c_state, p_state;
897 GstStateChangeReturn ret;
899 ret = gst_element_get_state (self->object, &c_state, &p_state, 0);
900 if ((ret == GST_STATE_CHANGE_SUCCESS &&
901 (c_state == GST_STATE_NULL || c_state == GST_STATE_READY)) ||
902 (ret == GST_STATE_CHANGE_ASYNC &&
903 (p_state == GST_STATE_NULL || p_state == GST_STATE_READY))) {
905 g_value_set_uint64 (value, self->priv->control_rate);
909 GST_WARNING ("Changing the control rate is only allowed if the elemnt"
910 " is in NULL or READY");
916 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
922 /* sets the given properties for this object */
924 _gst_controller_set_property (GObject * object, guint property_id,
925 const GValue * value, GParamSpec * pspec)
927 GstController *self = GST_CONTROLLER (object);
929 switch (property_id) {
930 case PROP_CONTROL_RATE:{
931 self->priv->control_rate = g_value_get_uint64 (value);
935 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
942 _gst_controller_dispose (GObject * object)
944 GstController *self = GST_CONTROLLER (object);
946 if (self->object != NULL) {
947 g_mutex_lock (self->lock);
948 /* free list of properties */
949 if (self->properties) {
952 for (node = self->properties; node; node = g_list_next (node)) {
953 GstControlledProperty *prop = node->data;
955 gst_controlled_property_free (prop);
957 g_list_free (self->properties);
958 self->properties = NULL;
961 g_object_unref (self->object);
963 g_mutex_unlock (self->lock);
966 if (G_OBJECT_CLASS (parent_class)->dispose)
967 (G_OBJECT_CLASS (parent_class)->dispose) (object);
971 _gst_controller_finalize (GObject * object)
973 GstController *self = GST_CONTROLLER (object);
975 g_mutex_free (self->lock);
977 if (G_OBJECT_CLASS (parent_class)->finalize)
978 (G_OBJECT_CLASS (parent_class)->finalize) (object);
982 _gst_controller_init (GTypeInstance * instance, gpointer g_class)
984 GstController *self = GST_CONTROLLER (instance);
986 self->lock = g_mutex_new ();
988 G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_CONTROLLER,
989 GstControllerPrivate);
990 self->priv->last_sync = GST_CLOCK_TIME_NONE;
991 self->priv->control_rate = 100 * GST_MSECOND;
995 _gst_controller_class_init (GstControllerClass * klass)
997 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
999 parent_class = g_type_class_peek_parent (klass);
1000 g_type_class_add_private (klass, sizeof (GstControllerPrivate));
1002 gobject_class->set_property = _gst_controller_set_property;
1003 gobject_class->get_property = _gst_controller_get_property;
1004 gobject_class->dispose = _gst_controller_dispose;
1005 gobject_class->finalize = _gst_controller_finalize;
1007 /* register properties */
1008 g_object_class_install_property (gobject_class, PROP_CONTROL_RATE,
1009 g_param_spec_uint64 ("control-rate",
1011 "Controlled properties will be updated at least every control-rate nanoseconds",
1012 1, G_MAXUINT, 100 * GST_MSECOND,
1013 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1015 GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gstcontroller", 0,
1016 "dynamic parameter control for gstreamer elements");
1020 gst_controller_get_type (void)
1022 static volatile gsize type = 0;
1024 if (g_once_init_enter (&type)) {
1026 static const GTypeInfo info = {
1027 sizeof (GstControllerClass),
1028 NULL, /* base_init */
1029 NULL, /* base_finalize */
1030 (GClassInitFunc) _gst_controller_class_init, /* class_init */
1031 NULL, /* class_finalize */
1032 NULL, /* class_data */
1033 sizeof (GstController),
1034 0, /* n_preallocs */
1035 (GInstanceInitFunc) _gst_controller_init, /* instance_init */
1036 NULL /* value_table */
1038 _type = g_type_register_static (G_TYPE_OBJECT, "GstController", &info, 0);
1039 g_once_init_leave (&type, _type);