26
26
* A value mapping object that attaches control sources to gobject properties.
28
/* FIXME(ensonic): should we make gst_object_add_control_binding() internal
29
* - we create the control_binding for a certain object anyway
30
* - we could call gst_object_add_control_binding() at the end of
31
* gst_control_binding_constructor()
32
* - the weak-ref on object is not nice, as is the same as gst_object_parent()
33
* once the object is added to the parent
35
* - another option would be do defer what I am doing in _constructor to when
36
* the parent is set (need to listen to the signal then)
37
* then basically I could
38
* a) remove the obj arg and wait the binding to be added or
39
* b) add the binding from constructor, unref object there and make obj
29
43
#include "gst_private.h"
261
280
* @n_values: the number of values
262
281
* @values: array to put control-values in
264
* Gets a number of values for the given controllered property starting at the
283
* Gets a number of values for the given controlled property starting at the
265
284
* requested time. The array @values need to hold enough space for @n_values of
266
285
* the same type as the objects property's type.
268
287
* This function is useful if one wants to e.g. draw a graph of the control
269
288
* curve or apply a control curve sample by sample.
290
* The values are unboxed and ready to be used. The similar function
291
* gst_control_binding_get_g_value_array() returns the array as #GValues and is
292
* better suites for bindings.
271
294
* Returns: %TRUE if the given array could be filled, %FALSE otherwise
274
297
gst_control_binding_get_value_array (GstControlBinding * self,
275
298
GstClockTime timestamp, GstClockTime interval, guint n_values,
278
301
GstControlBindingClass *klass;
279
302
gboolean ret = FALSE;
319
#define CONVERT_ARRAY(type,TYPE) \
321
g##type *v = g_new (g##type,n_values); \
322
ret = gst_control_binding_get_value_array (self, timestamp, interval, \
325
for (i = 0; i < n_values; i++) { \
326
g_value_init (&values[i], G_TYPE_##TYPE); \
327
g_value_set_##type (&values[i], v[i]); \
334
* gst_control_binding_get_g_value_array:
335
* @self: the control binding
336
* @timestamp: the time that should be processed
337
* @interval: the time spacing between subsequent values
338
* @n_values: the number of values
339
* @values: array to put control-values in
341
* Gets a number of #GValues for the given controlled property starting at the
342
* requested time. The array @values need to hold enough space for @n_values of
345
* This function is useful if one wants to e.g. draw a graph of the control
346
* curve or apply a control curve sample by sample.
348
* Returns: %TRUE if the given array could be filled, %FALSE otherwise
351
gst_control_binding_get_g_value_array (GstControlBinding * self,
352
GstClockTime timestamp, GstClockTime interval, guint n_values,
355
GstControlBindingClass *klass;
356
gboolean ret = FALSE;
358
g_return_val_if_fail (GST_IS_CONTROL_BINDING (self), FALSE);
359
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
360
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE);
361
g_return_val_if_fail (values, FALSE);
363
klass = GST_CONTROL_BINDING_GET_CLASS (self);
365
if (G_LIKELY (klass->get_g_value_array != NULL)) {
367
klass->get_g_value_array (self, timestamp, interval, n_values, values);
372
base = type = G_PARAM_SPEC_VALUE_TYPE (GST_CONTROL_BINDING_PSPEC (self));
373
while ((type = g_type_parent (type)))
376
GST_INFO_OBJECT (self, "missing get_g_value_array implementation, we're "
380
CONVERT_ARRAY (int, INT);
383
CONVERT_ARRAY (uint, UINT);
386
CONVERT_ARRAY (long, LONG);
389
CONVERT_ARRAY (ulong, ULONG);
392
CONVERT_ARRAY (int64, INT64);
395
CONVERT_ARRAY (uint64, UINT64);
398
CONVERT_ARRAY (float, FLOAT);
401
CONVERT_ARRAY (double, DOUBLE);
404
CONVERT_ARRAY (boolean, BOOLEAN);
408
gint *v = g_new (gint, n_values);
409
ret = gst_control_binding_get_value_array (self, timestamp, interval,
412
for (i = 0; i < n_values; i++) {
413
g_value_init (&values[i], type);
414
g_value_set_enum (&values[i], v[i]);
421
GST_WARNING ("incomplete implementation for paramspec type '%s'",
422
G_PARAM_SPEC_TYPE_NAME (GST_CONTROL_BINDING_PSPEC (self)));
423
GST_CONTROL_BINDING_PSPEC (self) = NULL;
297
431
* gst_control_binding_set_disabled:
298
432
* @self: the control binding