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);
230 GST_WARNING ("trying to control property %s again", name);
236 * gst_controller_remove_property:
237 * @self: the controller object
238 * @name: name of projecty in @object
240 * Removes a #GstControlledProperty for property @name.
242 * Returns: %TRUE if the property has been removed from the controller
245 gst_controller_remove_property (GstController * self, const gchar * name)
248 GstControlledProperty *prop;
250 if ((prop = gst_controller_find_controlled_property (self, name))) {
251 self->properties = g_list_remove (self->properties, prop);
252 //g_signal_handler_disconnect (self->object, prop->notify_handler_id);
253 gst_controlled_property_free (prop);
263 * gst_controller_new_valist:
264 * @object: the object of which some properties should be controlled
265 * @var_args: %NULL terminated list of property names that should be controlled
267 * Creates a new GstController for the given object's properties
269 * Returns: the new controller.
272 gst_controller_new_valist (GstObject * object, va_list var_args)
277 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
279 GST_INFO ("setting up a new controller");
281 self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
282 self->object = g_object_ref (object);
284 /* create GstControlledProperty for each property */
285 while ((name = va_arg (var_args, gchar *))) {
286 gst_controller_add_property (self, name);
294 * gst_controller_new_list:
295 * @object: the object of which some properties should be controlled
296 * @list: (transfer none) (element-type utf8): list of property names
297 * that should be controlled
299 * Creates a new GstController for the given object's properties
301 * Rename to: gst_controller_new
303 * Returns: the new controller.
306 gst_controller_new_list (GstObject * object, GList * list)
312 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
314 GST_INFO ("setting up a new controller");
316 self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
317 self->object = g_object_ref (object);
319 /* create GstControlledProperty for each property */
320 for (node = list; node; node = g_list_next (node)) {
321 name = (gchar *) node->data;
322 gst_controller_add_property (self, name);
329 * gst_controller_new:
330 * @object: the object of which some properties should be controlled
331 * @...: %NULL terminated list of property names that should be controlled
333 * Creates a new GstController for the given object's properties
335 * Returns: the new controller.
338 gst_controller_new (GstObject * object, ...)
343 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
345 va_start (var_args, object);
346 self = gst_controller_new_valist (object, var_args);
354 gst_controller_add_properties_valist (GstController * self, va_list var_args)
359 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
361 while ((name = va_arg (var_args, gchar *))) {
362 /* find the property in the properties list of the controller, remove and free it */
363 g_mutex_lock (self->lock);
364 res &= gst_controller_add_property (self, name);
365 g_mutex_unlock (self->lock);
373 gst_controller_add_properties_list (GstController * self, GList * list)
379 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
381 for (tmp = list; tmp; tmp = g_list_next (tmp)) {
382 name = (gchar *) tmp->data;
384 /* find the property in the properties list of the controller, remove and free it */
385 g_mutex_lock (self->lock);
386 res &= gst_controller_add_property (self, name);
387 g_mutex_unlock (self->lock);
395 gst_controller_add_properties (GstController * self, ...)
400 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
402 va_start (var_args, self);
403 res = gst_controller_add_properties_valist (self, var_args);
410 * gst_controller_remove_properties_valist:
411 * @self: the controller object from which some properties should be removed
412 * @var_args: %NULL terminated list of property names that should be removed
414 * Removes the given object properties from the controller
416 * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
419 gst_controller_remove_properties_valist (GstController * self, va_list var_args)
424 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
426 while ((name = va_arg (var_args, gchar *))) {
427 /* find the property in the properties list of the controller, remove and free it */
428 g_mutex_lock (self->lock);
429 res &= gst_controller_remove_property (self, name);
430 g_mutex_unlock (self->lock);
437 * gst_controller_remove_properties_list:
438 * @self: the controller object from which some properties should be removed
439 * @list: (transfer none) (element-type utf8): #GList of property names that
442 * Removes the given object properties from the controller
444 * Rename to: gst_controller_remove_properties
446 * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
449 gst_controller_remove_properties_list (GstController * self, GList * list)
455 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
457 for (tmp = list; tmp; tmp = g_list_next (tmp)) {
458 name = (gchar *) tmp->data;
460 /* find the property in the properties list of the controller, remove and free it */
461 g_mutex_lock (self->lock);
462 res &= gst_controller_remove_property (self, name);
463 g_mutex_unlock (self->lock);
470 * gst_controller_remove_properties:
471 * @self: the controller object from which some properties should be removed
472 * @...: %NULL terminated list of property names that should be removed
474 * Removes the given object properties from the controller
476 * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
479 gst_controller_remove_properties (GstController * self, ...)
484 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
486 va_start (var_args, self);
487 res = gst_controller_remove_properties_valist (self, var_args);
494 * gst_controller_is_active:
495 * @self: the #GstController which should be disabled
497 * Check if the controller is active. It is active if it has at least one
498 * controlled property that is not disabled.
500 * Returns: %TRUE if the controller is active
503 gst_controller_is_active (GstController * self)
505 gboolean active = FALSE;
507 GstControlledProperty *prop;
509 g_return_if_fail (GST_IS_CONTROLLER (self));
511 g_mutex_lock (self->lock);
512 for (node = self->properties; node; node = node->next) {
514 active |= !prop->disabled;
516 g_mutex_unlock (self->lock);
522 * gst_controller_set_property_disabled:
523 * @self: the #GstController which should be disabled
524 * @property_name: property to disable
525 * @disabled: boolean that specifies whether to disable the controller
528 * This function is used to disable the #GstController on a property for
529 * some time, i.e. gst_controller_sync_values() will do nothing for the
533 gst_controller_set_property_disabled (GstController * self,
534 const gchar * property_name, gboolean disabled)
536 GstControlledProperty *prop;
538 g_return_if_fail (GST_IS_CONTROLLER (self));
539 g_return_if_fail (property_name);
541 g_mutex_lock (self->lock);
542 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
543 prop->disabled = disabled;
545 g_mutex_unlock (self->lock);
549 * gst_controller_set_disabled:
550 * @self: the #GstController which should be disabled
551 * @disabled: boolean that specifies whether to disable the controller
554 * This function is used to disable all properties of the #GstController
555 * for some time, i.e. gst_controller_sync_values() will do nothing.
559 gst_controller_set_disabled (GstController * self, gboolean disabled)
562 GstControlledProperty *prop;
564 g_return_if_fail (GST_IS_CONTROLLER (self));
566 g_mutex_lock (self->lock);
567 for (node = self->properties; node; node = node->next) {
569 prop->disabled = disabled;
571 g_mutex_unlock (self->lock);
575 * gst_controller_set_control_source:
576 * @self: the controller object
577 * @property_name: name of the property for which the #GstControlSource should be set
578 * @csource: the #GstControlSource that should be used for the property
580 * Sets the #GstControlSource for @property_name. If there already was a #GstControlSource
581 * for this property it will be unreferenced.
583 * Returns: %FALSE if the given property isn't handled by the controller or the new #GstControlSource
584 * couldn't be bound to the property, %TRUE if everything worked as expected.
587 gst_controller_set_control_source (GstController * self,
588 const gchar * property_name, GstControlSource * csource)
590 GstControlledProperty *prop;
591 gboolean ret = FALSE;
593 g_mutex_lock (self->lock);
594 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
595 GstControlSource *old = prop->csource;
597 if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) {
598 g_object_ref (csource);
599 prop->csource = csource;
600 } else if (!csource) {
602 prop->csource = NULL;
606 g_object_unref (old);
608 g_mutex_unlock (self->lock);
614 * gst_controller_get_control_source:
615 * @self: the controller object
616 * @property_name: name of the property for which the #GstControlSource should be get
618 * Gets the corresponding #GstControlSource for the property. This should be unreferenced
621 * Returns: (transfer full): the #GstControlSource for @property_name or NULL if
622 * the property is not controlled by this controller or no #GstControlSource was
626 gst_controller_get_control_source (GstController * self,
627 const gchar * property_name)
629 GstControlledProperty *prop;
630 GstControlSource *ret = NULL;
632 g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL);
633 g_return_val_if_fail (property_name, NULL);
635 g_mutex_lock (self->lock);
636 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
639 g_mutex_unlock (self->lock);
648 * gst_controller_get:
649 * @self: the controller object which handles the properties
650 * @property_name: the name of the property to get
651 * @timestamp: the time the control-change should be read from
653 * Gets the value for the given controller-handled property at the requested
656 * Returns: the GValue of the property at the given time, or %NULL if the
657 * property isn't handled by the controller
660 gst_controller_get (GstController * self, const gchar * property_name,
661 GstClockTime timestamp)
663 GstControlledProperty *prop;
666 g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL);
667 g_return_val_if_fail (property_name, NULL);
668 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), NULL);
670 g_mutex_lock (self->lock);
671 if ((prop = gst_controller_find_controlled_property (self, property_name))) {
672 val = g_new0 (GValue, 1);
673 g_value_init (val, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
677 /* get current value via control source */
678 res = gst_control_source_get_value (prop->csource, timestamp, val);
684 g_object_get_property ((GObject *) self->object, prop->name, val);
687 g_mutex_unlock (self->lock);
693 * gst_controller_suggest_next_sync:
694 * @self: the controller that handles the values
696 * Returns a suggestion for timestamps where buffers should be split
697 * to get best controller results.
699 * Returns: Returns the suggested timestamp or %GST_CLOCK_TIME_NONE
700 * if no control-rate was set.
703 gst_controller_suggest_next_sync (GstController * self)
707 g_return_val_if_fail (GST_IS_CONTROLLER (self), GST_CLOCK_TIME_NONE);
708 g_return_val_if_fail (self->priv->control_rate != GST_CLOCK_TIME_NONE,
709 GST_CLOCK_TIME_NONE);
711 g_mutex_lock (self->lock);
713 /* TODO: Implement more logic, depending on interpolation mode
715 * FIXME: we need playback direction
717 ret = self->priv->last_sync + self->priv->control_rate;
719 g_mutex_unlock (self->lock);
725 * gst_controller_sync_values:
726 * @self: the controller that handles the values
727 * @timestamp: the time that should be processed
729 * Sets the properties of the element, according to the controller that (maybe)
730 * handles them and for the given timestamp.
732 * If this function fails, it is most likely the application developers fault.
733 * Most probably the control sources are not setup correctly.
735 * Returns: %TRUE if the controller values could be applied to the object
736 * properties, %FALSE otherwise
739 gst_controller_sync_values (GstController * self, GstClockTime timestamp)
741 GstControlledProperty *prop;
743 gboolean ret = TRUE, val_ret;
744 GValue value = { 0, };
746 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
747 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
749 GST_LOG ("sync_values");
751 g_mutex_lock (self->lock);
752 g_object_freeze_notify ((GObject *) self->object);
753 /* go over the controlled properties of the controller */
754 for (node = self->properties; node; node = g_list_next (node)) {
757 if (!prop->csource || prop->disabled)
760 GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
762 /* we can make this faster
763 * http://bugzilla.gnome.org/show_bug.cgi?id=536939
765 g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
766 val_ret = gst_control_source_get_value (prop->csource, timestamp, &value);
767 if (G_LIKELY (val_ret)) {
768 /* always set the value for first time, but then only if it changed
769 * this should limit g_object_notify invocations.
770 * FIXME: can we detect negative playback rates?
772 if ((timestamp < self->priv->last_sync) ||
773 gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) {
774 g_object_set_property ((GObject *) self->object, prop->name, &value);
775 g_value_copy (&value, &prop->last_value);
778 GST_DEBUG ("no control value for param %s", prop->name);
780 g_value_unset (&value);
783 self->priv->last_sync = timestamp;
784 g_object_thaw_notify ((GObject *) self->object);
786 g_mutex_unlock (self->lock);
792 * gst_controller_get_value_arrays:
793 * @self: the controller that handles the values
794 * @timestamp: the time that should be processed
795 * @value_arrays: list to return the control-values in
797 * Function to be able to get an array of values for one or more given element
800 * All fields of the %GstValueArray in the list must be filled correctly.
801 * Especially the GstValueArray->values arrays must be big enough to keep
802 * the requested amount of values.
804 * The types of the values in the array are the same as the property's type.
806 * <note><para>This doesn't modify the controlled GObject properties!</para></note>
808 * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise
811 gst_controller_get_value_arrays (GstController * self,
812 GstClockTime timestamp, GSList * value_arrays)
817 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
818 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
819 g_return_val_if_fail (value_arrays, FALSE);
821 for (node = value_arrays; (res && node); node = g_slist_next (node)) {
822 res = gst_controller_get_value_array (self, timestamp, node->data);
829 * gst_controller_get_value_array:
830 * @self: the controller that handles the values
831 * @timestamp: the time that should be processed
832 * @value_array: array to put control-values in
834 * Function to be able to get an array of values for one element property.
836 * All fields of @value_array must be filled correctly. Especially the
837 * @value_array->values array must be big enough to keep the requested amount
838 * of values (as indicated by the nbsamples field).
840 * The type of the values in the array is the same as the property's type.
842 * <note><para>This doesn't modify the controlled GObject property!</para></note>
844 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
847 gst_controller_get_value_array (GstController * self, GstClockTime timestamp,
848 GstValueArray * value_array)
850 gboolean res = FALSE;
851 GstControlledProperty *prop;
853 g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
854 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
855 g_return_val_if_fail (value_array, FALSE);
856 g_return_val_if_fail (value_array->property_name, FALSE);
857 g_return_val_if_fail (value_array->values, FALSE);
859 g_mutex_lock (self->lock);
862 gst_controller_find_controlled_property (self,
863 value_array->property_name))) {
864 /* get current value_array via control source */
870 gst_control_source_get_value_array (prop->csource, timestamp,
875 g_mutex_unlock (self->lock);
879 /* gobject handling */
882 _gst_controller_get_property (GObject * object, guint property_id,
883 GValue * value, GParamSpec * pspec)
885 GstController *self = GST_CONTROLLER (object);
887 switch (property_id) {
888 case PROP_CONTROL_RATE:{
889 /* FIXME: don't change if element is playing, controller works for GObject
892 GstState c_state, p_state;
893 GstStateChangeReturn ret;
895 ret = gst_element_get_state (self->object, &c_state, &p_state, 0);
896 if ((ret == GST_STATE_CHANGE_SUCCESS &&
897 (c_state == GST_STATE_NULL || c_state == GST_STATE_READY)) ||
898 (ret == GST_STATE_CHANGE_ASYNC &&
899 (p_state == GST_STATE_NULL || p_state == GST_STATE_READY))) {
901 g_value_set_uint64 (value, self->priv->control_rate);
905 GST_WARNING ("Changing the control rate is only allowed if the elemnt"
906 " is in NULL or READY");
912 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
918 /* sets the given properties for this object */
920 _gst_controller_set_property (GObject * object, guint property_id,
921 const GValue * value, GParamSpec * pspec)
923 GstController *self = GST_CONTROLLER (object);
925 switch (property_id) {
926 case PROP_CONTROL_RATE:{
927 self->priv->control_rate = g_value_get_uint64 (value);
931 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
938 _gst_controller_dispose (GObject * object)
940 GstController *self = GST_CONTROLLER (object);
942 if (self->object != NULL) {
943 g_mutex_lock (self->lock);
944 /* free list of properties */
945 if (self->properties) {
948 for (node = self->properties; node; node = g_list_next (node)) {
949 GstControlledProperty *prop = node->data;
951 gst_controlled_property_free (prop);
953 g_list_free (self->properties);
954 self->properties = NULL;
957 g_object_unref (self->object);
959 g_mutex_unlock (self->lock);
962 if (G_OBJECT_CLASS (parent_class)->dispose)
963 (G_OBJECT_CLASS (parent_class)->dispose) (object);
967 _gst_controller_finalize (GObject * object)
969 GstController *self = GST_CONTROLLER (object);
971 g_mutex_free (self->lock);
973 if (G_OBJECT_CLASS (parent_class)->finalize)
974 (G_OBJECT_CLASS (parent_class)->finalize) (object);
978 _gst_controller_init (GTypeInstance * instance, gpointer g_class)
980 GstController *self = GST_CONTROLLER (instance);
982 self->lock = g_mutex_new ();
984 G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_CONTROLLER,
985 GstControllerPrivate);
986 self->priv->last_sync = GST_CLOCK_TIME_NONE;
987 self->priv->control_rate = 100 * GST_MSECOND;
991 _gst_controller_class_init (GstControllerClass * klass)
993 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
995 parent_class = g_type_class_peek_parent (klass);
996 g_type_class_add_private (klass, sizeof (GstControllerPrivate));
998 gobject_class->set_property = _gst_controller_set_property;
999 gobject_class->get_property = _gst_controller_get_property;
1000 gobject_class->dispose = _gst_controller_dispose;
1001 gobject_class->finalize = _gst_controller_finalize;
1003 /* register properties */
1004 g_object_class_install_property (gobject_class, PROP_CONTROL_RATE,
1005 g_param_spec_uint64 ("control-rate",
1007 "Controlled properties will be updated at least every control-rate nanoseconds",
1008 1, G_MAXUINT, 100 * GST_MSECOND,
1009 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1011 GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gstcontroller", 0,
1012 "dynamic parameter control for gstreamer elements");
1016 gst_controller_get_type (void)
1018 static volatile gsize type = 0;
1020 if (g_once_init_enter (&type)) {
1022 static const GTypeInfo info = {
1023 sizeof (GstControllerClass),
1024 NULL, /* base_init */
1025 NULL, /* base_finalize */
1026 (GClassInitFunc) _gst_controller_class_init, /* class_init */
1027 NULL, /* class_finalize */
1028 NULL, /* class_data */
1029 sizeof (GstController),
1030 0, /* n_preallocs */
1031 (GInstanceInitFunc) _gst_controller_init, /* instance_init */
1032 NULL /* value_table */
1034 _type = g_type_register_static (G_TYPE_OBJECT, "GstController", &info, 0);
1035 g_once_init_leave (&type, _type);