~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to gst/gstcontrolbinding.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-05-21 11:14:06 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120521111406-1wfas0o9fdaxjyo8
Tags: 0.11.91-1
* New upstream release, "I will give you five magic beans!":
  + debian/libgstreamer.symbols:
    - Update symbols file.
* debian/libgstreamer-dev.install:
  + Don't ship useless .la file for the core plugins.
  + Don't ship .a and .la files for the library.
* debian/control.in:
  + Update debhelper dependency version and Standards-Version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *
26
26
 * A value mapping object that attaches control sources to gobject properties.
27
27
 */
 
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
 
34
 *
 
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
 
40
 *      writeonly
 
41
 */
28
42
 
29
43
#include "gst_private.h"
30
44
 
130
144
{
131
145
  GstControlBinding *self = GST_CONTROL_BINDING (object);
132
146
 
133
 
  if (self->object)
134
 
    gst_object_replace (&self->object, NULL);
 
147
  /* we did not took a reference */
 
148
  g_object_remove_weak_pointer ((GObject *) self->object,
 
149
      (gpointer *) & self->object);
 
150
  self->object = NULL;
135
151
 
136
152
  ((GObjectClass *) gst_control_binding_parent_class)->dispose (object);
137
153
}
154
170
 
155
171
  switch (prop_id) {
156
172
    case PROP_OBJECT:
157
 
      self->object = g_value_dup_object (value);
 
173
      /* do not ref to avoid a ref cycle */
 
174
      self->object = g_value_get_object (value);
 
175
      g_object_add_weak_pointer ((GObject *) self->object,
 
176
          (gpointer *) & self->object);
158
177
      break;
159
178
    case PROP_NAME:
160
179
      self->name = g_value_dup_string (value);
261
280
 * @n_values: the number of values
262
281
 * @values: array to put control-values in
263
282
 *
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.
267
286
 *
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.
270
289
 *
 
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.
 
293
 *
271
294
 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
272
295
 */
273
296
gboolean
274
297
gst_control_binding_get_value_array (GstControlBinding * self,
275
298
    GstClockTime timestamp, GstClockTime interval, guint n_values,
276
 
    GValue * values)
 
299
    gpointer values)
277
300
{
278
301
  GstControlBindingClass *klass;
279
302
  gboolean ret = FALSE;
293
316
  return ret;
294
317
}
295
318
 
 
319
#define CONVERT_ARRAY(type,TYPE) \
 
320
{ \
 
321
  g##type *v = g_new (g##type,n_values); \
 
322
  ret = gst_control_binding_get_value_array (self, timestamp, interval, \
 
323
      n_values, v); \
 
324
  if (ret) { \
 
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]); \
 
328
    } \
 
329
  } \
 
330
  g_free (v); \
 
331
}
 
332
 
 
333
/**
 
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
 
340
 *
 
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
 
343
 * #GValue.
 
344
 *
 
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.
 
347
 *
 
348
 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
 
349
 */
 
350
gboolean
 
351
gst_control_binding_get_g_value_array (GstControlBinding * self,
 
352
    GstClockTime timestamp, GstClockTime interval, guint n_values,
 
353
    GValue * values)
 
354
{
 
355
  GstControlBindingClass *klass;
 
356
  gboolean ret = FALSE;
 
357
 
 
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);
 
362
 
 
363
  klass = GST_CONTROL_BINDING_GET_CLASS (self);
 
364
 
 
365
  if (G_LIKELY (klass->get_g_value_array != NULL)) {
 
366
    ret =
 
367
        klass->get_g_value_array (self, timestamp, interval, n_values, values);
 
368
  } else {
 
369
    guint i;
 
370
    GType type, base;
 
371
 
 
372
    base = type = G_PARAM_SPEC_VALUE_TYPE (GST_CONTROL_BINDING_PSPEC (self));
 
373
    while ((type = g_type_parent (type)))
 
374
      base = type;
 
375
 
 
376
    GST_INFO_OBJECT (self, "missing get_g_value_array implementation, we're "
 
377
        "emulating it");
 
378
    switch (base) {
 
379
      case G_TYPE_INT:
 
380
        CONVERT_ARRAY (int, INT);
 
381
        break;
 
382
      case G_TYPE_UINT:
 
383
        CONVERT_ARRAY (uint, UINT);
 
384
        break;
 
385
      case G_TYPE_LONG:
 
386
        CONVERT_ARRAY (long, LONG);
 
387
        break;
 
388
      case G_TYPE_ULONG:
 
389
        CONVERT_ARRAY (ulong, ULONG);
 
390
        break;
 
391
      case G_TYPE_INT64:
 
392
        CONVERT_ARRAY (int64, INT64);
 
393
        break;
 
394
      case G_TYPE_UINT64:
 
395
        CONVERT_ARRAY (uint64, UINT64);
 
396
        break;
 
397
      case G_TYPE_FLOAT:
 
398
        CONVERT_ARRAY (float, FLOAT);
 
399
        break;
 
400
      case G_TYPE_DOUBLE:
 
401
        CONVERT_ARRAY (double, DOUBLE);
 
402
        break;
 
403
      case G_TYPE_BOOLEAN:
 
404
        CONVERT_ARRAY (boolean, BOOLEAN);
 
405
        break;
 
406
      case G_TYPE_ENUM:
 
407
      {
 
408
        gint *v = g_new (gint, n_values);
 
409
        ret = gst_control_binding_get_value_array (self, timestamp, interval,
 
410
            n_values, v);
 
411
        if (ret) {
 
412
          for (i = 0; i < n_values; i++) {
 
413
            g_value_init (&values[i], type);
 
414
            g_value_set_enum (&values[i], v[i]);
 
415
          }
 
416
        }
 
417
        g_free (v);
 
418
      }
 
419
        break;
 
420
      default:
 
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;
 
424
        break;
 
425
    }
 
426
  }
 
427
  return ret;
 
428
}
 
429
 
296
430
/**
297
431
 * gst_control_binding_set_disabled:
298
432
 * @self: the control binding