3 * Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dot net>
5 * gsthelper.c: GObject convenience methods for using dynamic properties
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * SECTION:gstcontrollergobject
25 * @short_description: #GObject convinience methods for using dynamic properties
26 * @see_also: #GstController
28 * These methods allow to use some #GstController functionallity directly from
33 #include "gstcontroller.h"
35 #define GST_CAT_DEFAULT gst_controller_debug
36 GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DEFAULT);
38 extern GQuark __gst_controller_key;
41 * gst_object_control_properties:
42 * @object: the object of which some properties should be controlled
43 * @...: %NULL terminated list of property names that should be controlled
45 * Convenience function for GObject
47 * Creates a GstController that allows you to dynamically control one, or more, GObject properties.
48 * If the given GObject already has a GstController, it adds the given properties to the existing
49 * controller and returns that controller.
51 * Returns: The GstController with which the user can control the given properties dynamically or NULL if
52 * one or more of the given properties aren't available, or cannot be controlled, for the given element.
56 gst_object_control_properties (GObject * object, ...)
60 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
64 va_start (var_args, object);
65 ctrl = gst_controller_new_valist (object, var_args);
71 * gst_object_uncontrol_properties:
72 * @object: the object of which some properties should not be controlled anymore
73 * @...: %NULL terminated list of property names that should be controlled
75 * Convenience function for GObject
77 * Removes the given element's properties from it's controller
79 * Returns: %FALSE if one of the given property names isn't handled by the
80 * controller, %TRUE otherwise
84 gst_object_uncontrol_properties (GObject * object, ...)
89 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
91 if ((ctrl = g_object_get_qdata (object, __gst_controller_key))) {
94 va_start (var_args, object);
95 res = gst_controller_remove_properties_valist (ctrl, var_args);
102 * gst_object_get_controller:
103 * @object: the object that has controlled properties
105 * Returns: the controller handling some of the given element's properties, %NULL if no controller
109 gst_object_get_controller (GObject * object)
111 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
113 return (g_object_get_qdata (object, __gst_controller_key));
117 * gst_object_set_controller:
118 * @object: the object that should get the controller
119 * @controller: the controller object to plug in
121 * Sets the controller on the given GObject
123 * Returns: %FALSE if the GObject already has an controller, %TRUE otherwise
127 gst_object_set_controller (GObject * object, GstController * controller)
131 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
132 g_return_val_if_fail (controller, FALSE);
134 if (!(ctrl = g_object_get_qdata (object, __gst_controller_key))) {
135 g_object_set_qdata (object, __gst_controller_key, controller);
142 * gst_object_sync_values:
143 * @object: the object that has controlled properties
144 * @timestamp: the time that should be processed
146 * Convenience function for GObject
148 * Returns: same thing as gst_controller_sync_values()
152 gst_object_sync_values (GObject * object, GstClockTime timestamp)
154 GstController *ctrl = NULL;
156 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
157 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
159 if ((ctrl = g_object_get_qdata (object, __gst_controller_key))) {
160 return gst_controller_sync_values (ctrl, timestamp);
166 * gst_object_get_value_arrays:
167 * @object: the object that has controlled properties
168 * @timestamp: the time that should be processed
169 * @value_arrays: list to return the control-values in
171 * Function to be able to get an array of values for one or more given element
174 * If the GstValueArray->values array in list nodes is NULL, it will be created
176 * The type of the values in the array are the same as the property's type.
178 * The g_object_* functions are just convenience functions for GObject
180 * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise
184 gst_object_get_value_arrays (GObject * object, GstClockTime timestamp,
185 GSList * value_arrays)
189 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
190 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
192 if ((ctrl = g_object_get_qdata (object, __gst_controller_key))) {
193 return gst_controller_get_value_arrays (ctrl, timestamp, value_arrays);
199 * gst_object_get_value_array:
200 * @object: the object that has controlled properties
201 * @timestamp: the time that should be processed
202 * @value_array: array to put control-values in
204 * Function to be able to get an array of values for one element properties
206 * If the GstValueArray->values array is NULL, it will be created by the function.
207 * The type of the values in the array are the same as the property's type.
209 * The g_object_* functions are just convenience functions for GObject
211 * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise
215 gst_object_get_value_array (GObject * object, GstClockTime timestamp,
216 GstValueArray * value_array)
220 g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
221 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
223 if ((ctrl = g_object_get_qdata (object, __gst_controller_key))) {
224 return gst_controller_get_value_array (ctrl, timestamp, value_array);