Blame gst/gstcontrolsource.c

Packit Service 963350
/* GStreamer
Packit Service 963350
 *
Packit Service 963350
 * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
Packit Service 963350
 *
Packit Service 963350
 * gstcontrolsource.c: Interface declaration for control sources
Packit Service 963350
 *
Packit Service 963350
 * This library is free software; you can redistribute it and/or
Packit Service 963350
 * modify it under the terms of the GNU Library General Public
Packit Service 963350
 * License as published by the Free Software Foundation; either
Packit Service 963350
 * version 2 of the License, or (at your option) any later version.
Packit Service 963350
 *
Packit Service 963350
 * This library is distributed in the hope that it will be useful,
Packit Service 963350
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 963350
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 963350
 * Library General Public License for more details.
Packit Service 963350
 *
Packit Service 963350
 * You should have received a copy of the GNU Library General Public
Packit Service 963350
 * License along with this library; if not, write to the
Packit Service 963350
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit Service 963350
 * Boston, MA 02110-1301, USA.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * SECTION:gstcontrolsource
Packit Service 963350
 * @title: GstControlSource
Packit Service 963350
 * @short_description: base class for control source sources
Packit Service 963350
 *
Packit Service 963350
 * The #GstControlSource is a base class for control value sources that could
Packit Service 963350
 * be used to get timestamp-value pairs. A control source essentially is a
Packit Service 963350
 * function over time.
Packit Service 963350
 *
Packit Service 963350
 * A #GstControlSource is used by first getting an instance of a specific
Packit Service 963350
 * control-source, creating a binding for the control-source to the target property
Packit Service 963350
 * of the element and then adding the binding to the element. The binding will
Packit Service 963350
 * convert the data types and value range to fit to the bound property.
Packit Service 963350
 *
Packit Service 963350
 * For implementing a new #GstControlSource one has to implement
Packit Service 963350
 * #GstControlSourceGetValue and #GstControlSourceGetValueArray functions.
Packit Service 963350
 * These are then used by gst_control_source_get_value() and
Packit Service 963350
 * gst_control_source_get_value_array() to get values for specific timestamps.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
#include "gst_private.h"
Packit Service 963350
Packit Service 963350
#include <glib-object.h>
Packit Service 963350
#include <gst/gst.h>
Packit Service 963350
Packit Service 963350
#include "gstcontrolsource.h"
Packit Service 963350
Packit Service 963350
#define GST_CAT_DEFAULT control_source_debug
Packit Service 963350
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
Packit Service 963350
Packit Service 963350
#define _do_init \
Packit Service 963350
  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gstcontrolsource", 0, \
Packit Service 963350
      "dynamic parameter control sources");
Packit Service 963350
Packit Service 963350
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstControlSource, gst_control_source,
Packit Service 963350
    GST_TYPE_OBJECT, _do_init);
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_control_source_class_init (GstControlSourceClass * klass)
Packit Service 963350
{
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_control_source_init (GstControlSource * self)
Packit Service 963350
{
Packit Service 963350
  self->get_value = NULL;
Packit Service 963350
  self->get_value_array = NULL;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_control_source_get_value: (method)
Packit Service 963350
 * @self: the #GstControlSource object
Packit Service 963350
 * @timestamp: the time for which the value should be returned
Packit Service 963350
 * @value: (out): the value
Packit Service 963350
 *
Packit Service 963350
 * Gets the value for this #GstControlSource at a given timestamp.
Packit Service 963350
 *
Packit Service 963350
 * Returns: %FALSE if the value couldn't be returned, %TRUE otherwise.
Packit Service 963350
 */
Packit Service 963350
gboolean
Packit Service 963350
gst_control_source_get_value (GstControlSource * self, GstClockTime timestamp,
Packit Service 963350
    gdouble * value)
Packit Service 963350
{
Packit Service 963350
  g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE);
Packit Service 963350
Packit Service 963350
  if (G_LIKELY (self->get_value)) {
Packit Service 963350
    return self->get_value (self, timestamp, value);
Packit Service 963350
  } else {
Packit Service 963350
    GST_ERROR ("Not bound to a specific property yet!");
Packit Service 963350
    return FALSE;
Packit Service 963350
  }
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_control_source_get_value_array: (method)
Packit Service 963350
 * @self: the #GstControlSource object
Packit Service 963350
 * @timestamp: the first timestamp
Packit Service 963350
 * @interval: the time steps
Packit Service 963350
 * @n_values: the number of values to fetch
Packit Service 963350
 * @values: (array length=n_values): array to put control-values in
Packit Service 963350
 *
Packit Service 963350
 * Gets an array of values for for this #GstControlSource. Values that are
Packit Service 963350
 * undefined contain NANs.
Packit Service 963350
 *
Packit Service 963350
 * Returns: %TRUE if the given array could be filled, %FALSE otherwise
Packit Service 963350
 */
Packit Service 963350
gboolean
Packit Service 963350
gst_control_source_get_value_array (GstControlSource * self,
Packit Service 963350
    GstClockTime timestamp, GstClockTime interval, guint n_values,
Packit Service 963350
    gdouble * values)
Packit Service 963350
{
Packit Service 963350
  g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE);
Packit Service 963350
Packit Service 963350
  if (G_LIKELY (self->get_value_array)) {
Packit Service 963350
    return self->get_value_array (self, timestamp, interval, n_values, values);
Packit Service 963350
  } else {
Packit Service 963350
    GST_ERROR ("Not bound to a specific property yet!");
Packit Service 963350
    return FALSE;
Packit Service 963350
  }
Packit Service 963350
}