+++ /dev/null
-/* GStreamer
- *
- * Copyright (C) 2005 Stefan Kost <ensonic at users dot sf dot net>
- * 2007 Sebastian Dröge <slomo@circular-chaos.org>
- * 2011 Stefan Sauer <ensonic at users dot sf dot net>
- *
- * gstcontroller.c: dynamic parameter control subsystem
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:gstcontroller
- * @short_description: dynamic parameter control subsystem
- *
- * The controller subsystem offers a lightweight way to adjust gobject
- * properties over stream-time. It works by using time-stamped value pairs that
- * are queued for element-properties. At run-time the elements continously pull
- * values changes for the current stream-time.
- *
- * What needs to be changed in a #GstElement?
- * Very little - it is just two steps to make a plugin controllable!
- * <orderedlist>
- * <listitem><para>
- * mark gobject-properties paramspecs that make sense to be controlled,
- * by GST_PARAM_CONTROLLABLE.
- * </para></listitem>
- * <listitem><para>
- * when processing data (get, chain, loop function) at the beginning call
- * gst_object_sync_values(element,timestamp).
- * This will made the controller to update all gobject properties that are under
- * control with the current values based on timestamp.
- * </para></listitem>
- * </orderedlist>
- *
- * What needs to be done in applications?
- * Again its not a lot to change.
- * <orderedlist>
- * <listitem><para>
- * first put some properties under control, by calling
- * controller = gst_object_control_properties (object, "prop1", "prop2",...);
- * </para></listitem>
- * <listitem><para>
- * create a #GstControlSource.
- * csource = gst_interpolation_control_source_new ();
- * gst_interpolation_control_source_set_interpolation_mode(csource, mode);
- * </para></listitem>
- * <listitem><para>
- * Attach the #GstControlSource on the controller to a property.
- * gst_controller_set_control_source (controller, "prop1", csource);
- * </para></listitem>
- * <listitem><para>
- * Set the control values
- * gst_interpolation_control_source_set (csource,0 * GST_SECOND, value1);
- * gst_interpolation_control_source_set (csource,1 * GST_SECOND, value2);
- * </para></listitem>
- * <listitem><para>
- * start your pipeline
- * </para></listitem>
- * </orderedlist>
- */
-
-#include "gst_private.h"
-
-#include "gstobject.h"
-#include "gstclock.h"
-#include "gstinfo.h"
-#include "gstcontroller.h"
-#include "gstcontrolsource.h"
-#include "gstparamspecs.h"
-
-#define GST_CAT_DEFAULT controller_debug
-GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
-
-static GObjectClass *parent_class = NULL;
-
-/* property ids */
-enum
-{
- PROP_CONTROL_RATE = 1
-};
-
-struct _GstControllerPrivate
-{
- GstClockTime control_rate;
- GstClockTime last_sync;
-};
-
-/* helper */
-
-/*
- * GstControlledProperty:
- */
-typedef struct _GstControlledProperty
-{
- GParamSpec *pspec; /* GParamSpec for this property */
- const gchar *name; /* name of the property */
- GstControlSource *csource; /* GstControlSource for this property */
- gboolean disabled;
- GValue last_value;
-} GstControlledProperty;
-
-#define GST_CONTROLLED_PROPERTY(obj) ((GstControlledProperty *)(obj))
-
-/*
- * gst_controlled_property_new:
- * @object: for which object the controlled property should be set up
- * @name: the name of the property to be controlled
- *
- * Private method which initializes the fields of a new controlled property
- * structure.
- *
- * Returns: a freshly allocated structure or %NULL
- */
-static GstControlledProperty *
-gst_controlled_property_new (GstObject * object, const gchar * name)
-{
- GstControlledProperty *prop = NULL;
- GParamSpec *pspec;
-
- GST_INFO ("trying to put property '%s' under control", name);
-
- /* check if the object has a property of that name */
- if ((pspec =
- g_object_class_find_property (G_OBJECT_GET_CLASS (object), name))) {
- GST_DEBUG (" psec->flags : 0x%08x", pspec->flags);
-
- /* check if this param is witable && controlable && !construct-only */
- g_return_val_if_fail ((pspec->flags & (G_PARAM_WRITABLE |
- GST_PARAM_CONTROLLABLE | G_PARAM_CONSTRUCT_ONLY)) ==
- (G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE), NULL);
-
- if ((prop = g_slice_new (GstControlledProperty))) {
- prop->pspec = pspec;
- prop->name = pspec->name;
- prop->csource = NULL;
- prop->disabled = FALSE;
- memset (&prop->last_value, 0, sizeof (GValue));
- g_value_init (&prop->last_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
- }
- } else {
- GST_WARNING ("class '%s' has no property '%s'", G_OBJECT_TYPE_NAME (object),
- name);
- }
- return prop;
-}
-
-/*
- * gst_controlled_property_free:
- * @prop: the object to free
- *
- * Private method which frees all data allocated by a #GstControlledProperty
- * instance.
- */
-static void
-gst_controlled_property_free (GstControlledProperty * prop)
-{
- if (prop->csource)
- g_object_unref (prop->csource);
- g_value_unset (&prop->last_value);
- g_slice_free (GstControlledProperty, prop);
-}
-
-/*
- * gst_controller_find_controlled_property:
- * @self: the controller object to search for a property in
- * @name: the gobject property name to look for
- *
- * Searches the list of properties under control.
- *
- * Returns: a #GstControlledProperty object of %NULL if the property is not
- * being controlled.
- */
-static GstControlledProperty *
-gst_controller_find_controlled_property (GstController * self,
- const gchar * name)
-{
- GstControlledProperty *prop;
- GList *node;
-
- for (node = self->properties; node; node = g_list_next (node)) {
- prop = node->data;
- /* FIXME: eventually use GQuark to speed it up */
- if (!strcmp (prop->name, name)) {
- return prop;
- }
- }
- GST_DEBUG ("controller does not (yet) manage property '%s'", name);
-
- return NULL;
-}
-
-/*
- * gst_controller_add_property:
- * @self: the controller object
- * @name: name of projecty in @object
- *
- * Creates a new #GstControlledProperty if there is none for property @name yet.
- *
- * Returns: %TRUE if the property has been added to the controller
- */
-static gboolean
-gst_controller_add_property (GstController * self, const gchar * name)
-{
- gboolean res = TRUE;
-
- /* test if this property isn't yet controlled */
- if (!gst_controller_find_controlled_property (self, name)) {
- GstControlledProperty *prop;
-
- /* create GstControlledProperty and add to self->properties list */
- if ((prop = gst_controlled_property_new (self->object, name))) {
- self->properties = g_list_prepend (self->properties, prop);
- GST_DEBUG_OBJECT (self->object, "property %s added", name);
- } else
- res = FALSE;
- } else {
- GST_WARNING_OBJECT (self->object, "trying to control property %s again",
- name);
- }
- return res;
-}
-
-/*
- * gst_controller_remove_property:
- * @self: the controller object
- * @name: name of projecty in @object
- *
- * Removes a #GstControlledProperty for property @name.
- *
- * Returns: %TRUE if the property has been removed from the controller
- */
-static gboolean
-gst_controller_remove_property (GstController * self, const gchar * name)
-{
- gboolean res = TRUE;
- GstControlledProperty *prop;
-
- if ((prop = gst_controller_find_controlled_property (self, name))) {
- self->properties = g_list_remove (self->properties, prop);
- //g_signal_handler_disconnect (self->object, prop->notify_handler_id);
- gst_controlled_property_free (prop);
- GST_DEBUG_OBJECT (self->object, "property %s removed", name);
- } else {
- res = FALSE;
- }
- return res;
-}
-
-/* methods */
-
-/**
- * gst_controller_new_valist:
- * @object: the object of which some properties should be controlled
- * @var_args: %NULL terminated list of property names that should be controlled
- *
- * Creates a new GstController for the given object's properties
- *
- * Returns: the new controller.
- */
-GstController *
-gst_controller_new_valist (GstObject * object, va_list var_args)
-{
- GstController *self;
- gchar *name;
-
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
-
- /* FIXME: storing the controller into the object is ugly
- * we'd like to make the controller object completely internal
- */
- self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
- self->object = g_object_ref (object);
- object->ctrl = g_object_ref (self);
-
- /* create GstControlledProperty for each property */
- while ((name = va_arg (var_args, gchar *))) {
- gst_controller_add_property (self, name);
- }
- va_end (var_args);
-
- return self;
-}
-
-/**
- * gst_controller_new_list:
- * @object: the object of which some properties should be controlled
- * @list: (transfer none) (element-type utf8): list of property names
- * that should be controlled
- *
- * Creates a new GstController for the given object's properties
- *
- * Rename to: gst_controller_new
- *
- * Returns: the new controller.
- */
-GstController *
-gst_controller_new_list (GstObject * object, GList * list)
-{
- GstController *self;
- gchar *name;
- GList *node;
-
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
-
- self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
- self->object = g_object_ref (object);
- object->ctrl = g_object_ref (self);
-
- /* create GstControlledProperty for each property */
- for (node = list; node; node = g_list_next (node)) {
- name = (gchar *) node->data;
- gst_controller_add_property (self, name);
- }
-
- return self;
-}
-
-/**
- * gst_controller_new:
- * @object: the object of which some properties should be controlled
- * @...: %NULL terminated list of property names that should be controlled
- *
- * Creates a new GstController for the given object's properties
- *
- * Returns: the new controller.
- */
-GstController *
-gst_controller_new (GstObject * object, ...)
-{
- GstController *self;
- va_list var_args;
-
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
-
- va_start (var_args, object);
- self = gst_controller_new_valist (object, var_args);
- va_end (var_args);
-
- return self;
-}
-
-// FIXME: docs
-gboolean
-gst_controller_add_properties_valist (GstController * self, va_list var_args)
-{
- gboolean res = TRUE;
- gchar *name;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- while ((name = va_arg (var_args, gchar *))) {
- /* find the property in the properties list of the controller, remove and free it */
- g_mutex_lock (self->lock);
- res &= gst_controller_add_property (self, name);
- g_mutex_unlock (self->lock);
- }
-
- return res;
-}
-
-// FIXME: docs
-gboolean
-gst_controller_add_properties_list (GstController * self, GList * list)
-{
- gboolean res = TRUE;
- gchar *name;
- GList *tmp;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- for (tmp = list; tmp; tmp = g_list_next (tmp)) {
- name = (gchar *) tmp->data;
-
- /* find the property in the properties list of the controller, remove and free it */
- g_mutex_lock (self->lock);
- res &= gst_controller_add_property (self, name);
- g_mutex_unlock (self->lock);
- }
-
- return res;
-}
-
-// FIXME: docs
-gboolean
-gst_controller_add_properties (GstController * self, ...)
-{
- gboolean res;
- va_list var_args;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- va_start (var_args, self);
- res = gst_controller_add_properties_valist (self, var_args);
- va_end (var_args);
-
- return res;
-}
-
-/**
- * gst_controller_remove_properties_valist:
- * @self: the controller object from which some properties should be removed
- * @var_args: %NULL terminated list of property names that should be removed
- *
- * Removes the given object properties from the controller
- *
- * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
- */
-gboolean
-gst_controller_remove_properties_valist (GstController * self, va_list var_args)
-{
- gboolean res = TRUE;
- gchar *name;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- while ((name = va_arg (var_args, gchar *))) {
- /* find the property in the properties list of the controller, remove and free it */
- g_mutex_lock (self->lock);
- res &= gst_controller_remove_property (self, name);
- g_mutex_unlock (self->lock);
- }
-
- return res;
-}
-
-/**
- * gst_controller_remove_properties_list:
- * @self: the controller object from which some properties should be removed
- * @list: (transfer none) (element-type utf8): #GList of property names that
- * should be removed
- *
- * Removes the given object properties from the controller
- *
- * Rename to: gst_controller_remove_properties
- *
- * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
- */
-gboolean
-gst_controller_remove_properties_list (GstController * self, GList * list)
-{
- gboolean res = TRUE;
- gchar *name;
- GList *tmp;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- for (tmp = list; tmp; tmp = g_list_next (tmp)) {
- name = (gchar *) tmp->data;
-
- /* find the property in the properties list of the controller, remove and free it */
- g_mutex_lock (self->lock);
- res &= gst_controller_remove_property (self, name);
- g_mutex_unlock (self->lock);
- }
-
- return res;
-}
-
-/**
- * gst_controller_remove_properties:
- * @self: the controller object from which some properties should be removed
- * @...: %NULL terminated list of property names that should be removed
- *
- * Removes the given object properties from the controller
- *
- * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise
- */
-gboolean
-gst_controller_remove_properties (GstController * self, ...)
-{
- gboolean res;
- va_list var_args;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- va_start (var_args, self);
- res = gst_controller_remove_properties_valist (self, var_args);
- va_end (var_args);
-
- return res;
-}
-
-/**
- * gst_controller_is_active:
- * @self: the #GstController which should be disabled
- *
- * Check if the controller is active. It is active if it has at least one
- * controlled property that is not disabled.
- *
- * Returns: %TRUE if the controller is active
- */
-gboolean
-gst_controller_is_active (GstController * self)
-{
- gboolean active = FALSE;
- GList *node;
- GstControlledProperty *prop;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
-
- g_mutex_lock (self->lock);
- for (node = self->properties; node; node = node->next) {
- prop = node->data;
- active |= !prop->disabled;
- }
- g_mutex_unlock (self->lock);
-
- return active;
-}
-
-/**
- * gst_controller_set_property_disabled:
- * @self: the #GstController which should be disabled
- * @property_name: property to disable
- * @disabled: boolean that specifies whether to disable the controller
- * or not.
- *
- * This function is used to disable the #GstController on a property for
- * some time, i.e. gst_controller_sync_values() will do nothing for the
- * property.
- */
-void
-gst_controller_set_property_disabled (GstController * self,
- const gchar * property_name, gboolean disabled)
-{
- GstControlledProperty *prop;
-
- g_return_if_fail (GST_IS_CONTROLLER (self));
- g_return_if_fail (property_name);
-
- g_mutex_lock (self->lock);
- if ((prop = gst_controller_find_controlled_property (self, property_name))) {
- prop->disabled = disabled;
- }
- g_mutex_unlock (self->lock);
-}
-
-/**
- * gst_controller_set_disabled:
- * @self: the #GstController which should be disabled
- * @disabled: boolean that specifies whether to disable the controller
- * or not.
- *
- * This function is used to disable all properties of the #GstController
- * for some time, i.e. gst_controller_sync_values() will do nothing.
- */
-
-void
-gst_controller_set_disabled (GstController * self, gboolean disabled)
-{
- GList *node;
- GstControlledProperty *prop;
-
- g_return_if_fail (GST_IS_CONTROLLER (self));
-
- g_mutex_lock (self->lock);
- for (node = self->properties; node; node = node->next) {
- prop = node->data;
- prop->disabled = disabled;
- }
- g_mutex_unlock (self->lock);
-}
-
-/**
- * gst_controller_set_control_source:
- * @self: the controller object
- * @property_name: name of the property for which the #GstControlSource should be set
- * @csource: the #GstControlSource that should be used for the property
- *
- * Sets the #GstControlSource for @property_name. If there already was a #GstControlSource
- * for this property it will be unreferenced.
- *
- * Returns: %FALSE if the given property isn't handled by the controller or the new #GstControlSource
- * couldn't be bound to the property, %TRUE if everything worked as expected.
- */
-gboolean
-gst_controller_set_control_source (GstController * self,
- const gchar * property_name, GstControlSource * csource)
-{
- GstControlledProperty *prop;
- gboolean ret = FALSE;
-
- g_mutex_lock (self->lock);
- if ((prop = gst_controller_find_controlled_property (self, property_name))) {
- GstControlSource *old = prop->csource;
-
- if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) {
- g_object_ref (csource);
- prop->csource = csource;
- } else if (!csource) {
- ret = TRUE;
- prop->csource = NULL;
- }
-
- if (ret && old)
- g_object_unref (old);
- }
- g_mutex_unlock (self->lock);
-
- return ret;
-}
-
-/**
- * gst_controller_get_control_source:
- * @self: the controller object
- * @property_name: name of the property for which the #GstControlSource should be get
- *
- * Gets the corresponding #GstControlSource for the property. This should be unreferenced
- * again after use.
- *
- * Returns: (transfer full): the #GstControlSource for @property_name or NULL if
- * the property is not controlled by this controller or no #GstControlSource was
- * assigned yet.
- */
-GstControlSource *
-gst_controller_get_control_source (GstController * self,
- const gchar * property_name)
-{
- GstControlledProperty *prop;
- GstControlSource *ret = NULL;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL);
- g_return_val_if_fail (property_name, NULL);
-
- g_mutex_lock (self->lock);
- if ((prop = gst_controller_find_controlled_property (self, property_name))) {
- ret = prop->csource;
- }
- g_mutex_unlock (self->lock);
-
- if (ret)
- g_object_ref (ret);
-
- return ret;
-}
-
-/**
- * gst_controller_get:
- * @self: the controller object which handles the properties
- * @property_name: the name of the property to get
- * @timestamp: the time the control-change should be read from
- *
- * Gets the value for the given controller-handled property at the requested
- * time.
- *
- * Returns: the GValue of the property at the given time, or %NULL if the
- * property isn't handled by the controller
- */
-GValue *
-gst_controller_get (GstController * self, const gchar * property_name,
- GstClockTime timestamp)
-{
- GstControlledProperty *prop;
- GValue *val = NULL;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL);
- g_return_val_if_fail (property_name, NULL);
- g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), NULL);
-
- g_mutex_lock (self->lock);
- if ((prop = gst_controller_find_controlled_property (self, property_name))) {
- val = g_new0 (GValue, 1);
- g_value_init (val, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
- if (prop->csource) {
- gboolean res;
-
- /* get current value via control source */
- res = gst_control_source_get_value (prop->csource, timestamp, val);
- if (!res) {
- g_free (val);
- val = NULL;
- }
- } else {
- g_object_get_property ((GObject *) self->object, prop->name, val);
- }
- }
- g_mutex_unlock (self->lock);
-
- return val;
-}
-
-/**
- * gst_controller_suggest_next_sync:
- * @self: the controller that handles the values
- *
- * Returns a suggestion for timestamps where buffers should be split
- * to get best controller results.
- *
- * Returns: Returns the suggested timestamp or %GST_CLOCK_TIME_NONE
- * if no control-rate was set.
- */
-GstClockTime
-gst_controller_suggest_next_sync (GstController * self)
-{
- GstClockTime ret;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), GST_CLOCK_TIME_NONE);
- g_return_val_if_fail (self->priv->control_rate != GST_CLOCK_TIME_NONE,
- GST_CLOCK_TIME_NONE);
-
- g_mutex_lock (self->lock);
-
- /* TODO: Implement more logic, depending on interpolation mode
- * and control points
- * FIXME: we need playback direction
- */
- ret = self->priv->last_sync + self->priv->control_rate;
-
- g_mutex_unlock (self->lock);
-
- return ret;
-}
-
-/**
- * gst_controller_sync_values:
- * @self: the controller that handles the values
- * @timestamp: the time that should be processed
- *
- * Sets the properties of the element, according to the controller that (maybe)
- * handles them and for the given timestamp.
- *
- * If this function fails, it is most likely the application developers fault.
- * Most probably the control sources are not setup correctly.
- *
- * Returns: %TRUE if the controller values could be applied to the object
- * properties, %FALSE otherwise
- */
-gboolean
-gst_controller_sync_values (GstController * self, GstClockTime timestamp)
-{
- GstControlledProperty *prop;
- GList *node;
- gboolean ret = TRUE, val_ret;
- GValue value = { 0, };
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
- g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
-
- GST_LOG ("sync_values");
-
- g_mutex_lock (self->lock);
- g_object_freeze_notify ((GObject *) self->object);
- /* go over the controlled properties of the controller */
- for (node = self->properties; node; node = g_list_next (node)) {
- prop = node->data;
-
- if (!prop->csource || prop->disabled)
- continue;
-
- GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
-
- /* we can make this faster
- * http://bugzilla.gnome.org/show_bug.cgi?id=536939
- */
- g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
- val_ret = gst_control_source_get_value (prop->csource, timestamp, &value);
- if (G_LIKELY (val_ret)) {
- /* always set the value for first time, but then only if it changed
- * this should limit g_object_notify invocations.
- * FIXME: can we detect negative playback rates?
- */
- if ((timestamp < self->priv->last_sync) ||
- gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) {
- g_object_set_property ((GObject *) self->object, prop->name, &value);
- g_value_copy (&value, &prop->last_value);
- }
- } else {
- GST_DEBUG ("no control value for param %s", prop->name);
- }
- g_value_unset (&value);
- ret &= val_ret;
- }
- self->priv->last_sync = timestamp;
- g_object_thaw_notify ((GObject *) self->object);
-
- g_mutex_unlock (self->lock);
-
- return ret;
-}
-
-/**
- * gst_controller_get_value_arrays:
- * @self: the controller that handles the values
- * @timestamp: the time that should be processed
- * @value_arrays: list to return the control-values in
- *
- * Function to be able to get an array of values for one or more given element
- * properties.
- *
- * All fields of the %GstValueArray in the list must be filled correctly.
- * Especially the GstValueArray->values arrays must be big enough to keep
- * the requested amount of values.
- *
- * The types of the values in the array are the same as the property's type.
- *
- * <note><para>This doesn't modify the controlled GObject properties!</para></note>
- *
- * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise
- */
-gboolean
-gst_controller_get_value_arrays (GstController * self,
- GstClockTime timestamp, GSList * value_arrays)
-{
- gboolean res = TRUE;
- GSList *node;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
- g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
- g_return_val_if_fail (value_arrays, FALSE);
-
- for (node = value_arrays; (res && node); node = g_slist_next (node)) {
- res = gst_controller_get_value_array (self, timestamp, node->data);
- }
-
- return (res);
-}
-
-/**
- * gst_controller_get_value_array:
- * @self: the controller that handles the values
- * @timestamp: the time that should be processed
- * @value_array: array to put control-values in
- *
- * Function to be able to get an array of values for one element property.
- *
- * All fields of @value_array must be filled correctly. Especially the
- * @value_array->values array must be big enough to keep the requested amount
- * of values (as indicated by the nbsamples field).
- *
- * The type of the values in the array is the same as the property's type.
- *
- * <note><para>This doesn't modify the controlled GObject property!</para></note>
- *
- * Returns: %TRUE if the given array could be filled, %FALSE otherwise
- */
-gboolean
-gst_controller_get_value_array (GstController * self, GstClockTime timestamp,
- GstValueArray * value_array)
-{
- gboolean res = FALSE;
- GstControlledProperty *prop;
-
- g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
- g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
- g_return_val_if_fail (value_array, FALSE);
- g_return_val_if_fail (value_array->property_name, FALSE);
- g_return_val_if_fail (value_array->values, FALSE);
-
- g_mutex_lock (self->lock);
-
- if ((prop =
- gst_controller_find_controlled_property (self,
- value_array->property_name))) {
- /* get current value_array via control source */
-
- if (!prop->csource)
- goto out;
-
- res =
- gst_control_source_get_value_array (prop->csource, timestamp,
- value_array);
- }
-
-out:
- g_mutex_unlock (self->lock);
- return res;
-}
-
-/* gobject handling */
-
-static void
-_gst_controller_get_property (GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
-{
- GstController *self = GST_CONTROLLER (object);
-
- switch (property_id) {
- case PROP_CONTROL_RATE:{
- /* FIXME: don't change if element is playing, controller works for GObject
- so this wont work
-
- GstState c_state, p_state;
- GstStateChangeReturn ret;
-
- ret = gst_element_get_state (self->object, &c_state, &p_state, 0);
- if ((ret == GST_STATE_CHANGE_SUCCESS &&
- (c_state == GST_STATE_NULL || c_state == GST_STATE_READY)) ||
- (ret == GST_STATE_CHANGE_ASYNC &&
- (p_state == GST_STATE_NULL || p_state == GST_STATE_READY))) {
- */
- g_value_set_uint64 (value, self->priv->control_rate);
- /*
- }
- else {
- GST_WARNING ("Changing the control rate is only allowed if the elemnt"
- " is in NULL or READY");
- }
- */
- }
- break;
- default:{
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
- break;
- }
-}
-
-/* sets the given properties for this object */
-static void
-_gst_controller_set_property (GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstController *self = GST_CONTROLLER (object);
-
- switch (property_id) {
- case PROP_CONTROL_RATE:{
- self->priv->control_rate = g_value_get_uint64 (value);
- }
- break;
- default:{
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
- break;
- }
-}
-
-static void
-_gst_controller_dispose (GObject * object)
-{
- GstController *self = GST_CONTROLLER (object);
-
- if (self->object != NULL) {
- g_mutex_lock (self->lock);
- /* free list of properties */
- if (self->properties) {
- GList *node;
-
- for (node = self->properties; node; node = g_list_next (node)) {
- GstControlledProperty *prop = node->data;
-
- gst_controlled_property_free (prop);
- }
- g_list_free (self->properties);
- self->properties = NULL;
- }
-
- g_object_unref (self->object);
- self->object = NULL;
- g_mutex_unlock (self->lock);
- }
-
- if (G_OBJECT_CLASS (parent_class)->dispose)
- (G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-_gst_controller_finalize (GObject * object)
-{
- GstController *self = GST_CONTROLLER (object);
-
- g_mutex_free (self->lock);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-static void
-_gst_controller_init (GTypeInstance * instance, gpointer g_class)
-{
- GstController *self = GST_CONTROLLER (instance);
-
- self->lock = g_mutex_new ();
- self->priv =
- G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_CONTROLLER,
- GstControllerPrivate);
- self->priv->last_sync = GST_CLOCK_TIME_NONE;
- self->priv->control_rate = 100 * GST_MSECOND;
-}
-
-static void
-_gst_controller_class_init (GstControllerClass * klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (GstControllerPrivate));
-
- gobject_class->set_property = _gst_controller_set_property;
- gobject_class->get_property = _gst_controller_get_property;
- gobject_class->dispose = _gst_controller_dispose;
- gobject_class->finalize = _gst_controller_finalize;
-
- /* register properties */
- g_object_class_install_property (gobject_class, PROP_CONTROL_RATE,
- g_param_spec_uint64 ("control-rate",
- "control rate",
- "Controlled properties will be updated at least every control-rate nanoseconds",
- 1, G_MAXUINT, 100 * GST_MSECOND,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gstcontroller", 0,
- "dynamic parameter control for gstreamer elements");
-}
-
-GType
-gst_controller_get_type (void)
-{
- static volatile gsize type = 0;
-
- if (g_once_init_enter (&type)) {
- GType _type;
- static const GTypeInfo info = {
- sizeof (GstControllerClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) _gst_controller_class_init, /* class_init */
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GstController),
- 0, /* n_preallocs */
- (GInstanceInitFunc) _gst_controller_init, /* instance_init */
- NULL /* value_table */
- };
- _type = g_type_register_static (G_TYPE_OBJECT, "GstController", &info, 0);
- g_once_init_leave (&type, _type);
- }
- return type;
-}
* gst_object_set_name() and gst_object_get_name() are used to set/get the name
* of the object.
*
+ *
+ * <refsect2>
+ * <title>controlled properties</title>
+ * Controlled properties offers a lightweight way to adjust gobject
+ * properties over stream-time. It works by using time-stamped value pairs that
+ * are queued for element-properties. At run-time the elements continously pull
+ * values changes for the current stream-time.
+ *
+ * What needs to be changed in a #GstElement?
+ * Very little - it is just two steps to make a plugin controllable!
+ * <orderedlist>
+ * <listitem><para>
+ * mark gobject-properties paramspecs that make sense to be controlled,
+ * by GST_PARAM_CONTROLLABLE.
+ * </para></listitem>
+ * <listitem><para>
+ * when processing data (get, chain, loop function) at the beginning call
+ * gst_object_sync_values(element,timestamp).
+ * This will made the controller to update all gobject properties that are under
+ * control with the current values based on timestamp.
+ * </para></listitem>
+ * </orderedlist>
+ *
+ * What needs to be done in applications?
+ * Again its not a lot to change.
+ * <orderedlist>
+ * <listitem><para>
+ * first put some properties under control, by calling
+ * gst_object_control_properties (object, "prop1", "prop2",...);
+ * </para></listitem>
+ * <listitem><para>
+ * create a #GstControlSource.
+ * csource = gst_interpolation_control_source_new ();
+ * gst_interpolation_control_source_set_interpolation_mode(csource, mode);
+ * </para></listitem>
+ * <listitem><para>
+ * Attach the #GstControlSource on the controller to a property.
+ * gst_object_set_control_source (object, "prop1", csource);
+ * </para></listitem>
+ * <listitem><para>
+ * Set the control values
+ * gst_interpolation_control_source_set (csource,0 * GST_SECOND, value1);
+ * gst_interpolation_control_source_set (csource,1 * GST_SECOND, value2);
+ * </para></listitem>
+ * <listitem><para>
+ * start your pipeline
+ * </para></listitem>
+ * </orderedlist>
+ * </refsect2>
+ *
* Last reviewed on 2005-11-09 (0.9.4)
*/
#include "gstobject.h"
#include "gstmarshal.h"
-#include "gstcontroller.h"
+#include "gstclock.h"
+#include "gstcontrolsource.h"
#include "gstinfo.h"
+#include "gstparamspecs.h"
#include "gstutils.h"
#ifndef GST_DISABLE_TRACE
static GParamSpec *properties[PROP_LAST];
+/*
+ * GstControlledProperty:
+ */
+typedef struct _GstControlledProperty
+{
+ GParamSpec *pspec; /* GParamSpec for this property */
+ const gchar *name; /* name of the property */
+ GstControlSource *csource; /* GstControlSource for this property */
+ gboolean disabled;
+ GValue last_value;
+} GstControlledProperty;
+
+static void gst_controlled_property_free (GstControlledProperty * prop);
+
+
G_DEFINE_ABSTRACT_TYPE (GstObject, gst_object, G_TYPE_INITIALLY_UNOWNED);
static void
#endif
object->flags = 0;
+
+ object->control_rate = 100 * GST_MSECOND;
+ object->last_sync = GST_CLOCK_TIME_NONE;
}
/**
GST_OBJECT_PARENT (object) = NULL;
GST_OBJECT_UNLOCK (object);
- if (self->ctrl) {
- g_object_unref (self->ctrl);
- self->ctrl = NULL;
+ if (self->properties) {
+ GList *node;
+
+ for (node = self->properties; node; node = g_list_next (node)) {
+ gst_controlled_property_free ((GstControlledProperty *) node->data);
+ }
+ g_list_free (self->properties);
+ self->properties = NULL;
}
((GObjectClass *) gst_object_parent_class)->dispose (object);
return path;
}
+/* controller helper functions */
+
+/*
+ * gst_controlled_property_new:
+ * @object: for which object the controlled property should be set up
+ * @name: the name of the property to be controlled
+ *
+ * Private method which initializes the fields of a new controlled property
+ * structure.
+ *
+ * Returns: a freshly allocated structure or %NULL
+ */
+static GstControlledProperty *
+gst_controlled_property_new (GstObject * object, const gchar * name)
+{
+ GstControlledProperty *prop = NULL;
+ GParamSpec *pspec;
+
+ GST_INFO ("trying to put property '%s' under control", name);
+
+ /* check if the object has a property of that name */
+ if ((pspec =
+ g_object_class_find_property (G_OBJECT_GET_CLASS (object), name))) {
+ GST_DEBUG (" psec->flags : 0x%08x", pspec->flags);
+
+ /* check if this param is witable && controlable && !construct-only */
+ g_return_val_if_fail ((pspec->flags & (G_PARAM_WRITABLE |
+ GST_PARAM_CONTROLLABLE | G_PARAM_CONSTRUCT_ONLY)) ==
+ (G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE), NULL);
+
+ if ((prop = g_slice_new (GstControlledProperty))) {
+ prop->pspec = pspec;
+ prop->name = pspec->name;
+ prop->csource = NULL;
+ prop->disabled = FALSE;
+ memset (&prop->last_value, 0, sizeof (GValue));
+ g_value_init (&prop->last_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
+ }
+ } else {
+ GST_WARNING ("class '%s' has no property '%s'", G_OBJECT_TYPE_NAME (object),
+ name);
+ }
+ return prop;
+}
+
+/*
+ * gst_controlled_property_free:
+ * @prop: the object to free
+ *
+ * Private method which frees all data allocated by a #GstControlledProperty
+ * instance.
+ */
+static void
+gst_controlled_property_free (GstControlledProperty * prop)
+{
+ if (prop->csource)
+ g_object_unref (prop->csource);
+ g_value_unset (&prop->last_value);
+ g_slice_free (GstControlledProperty, prop);
+}
+
+/*
+ * gst_object_find_controlled_property:
+ * @self: the gobject to search for a property in
+ * @name: the gobject property name to look for
+ *
+ * Searches the list of properties under control.
+ *
+ * Returns: a #GstControlledProperty or %NULL if the property is not being
+ * controlled.
+ */
+static GstControlledProperty *
+gst_object_find_controlled_property (GstObject * self, const gchar * name)
+{
+ GstControlledProperty *prop;
+ GList *node;
+
+ for (node = self->properties; node; node = g_list_next (node)) {
+ prop = node->data;
+ /* FIXME: eventually use GQuark to speed it up */
+ if (!strcmp (prop->name, name)) {
+ return prop;
+ }
+ }
+ GST_DEBUG ("controller does not (yet) manage property '%s'", name);
+
+ return NULL;
+}
+
+/*
+ * gst_object_add_controlled_property:
+ * @self: the object
+ * @name: name of projecty in @object
+ *
+ * Creates a new #GstControlledProperty if there is none for property @name yet.
+ *
+ * Returns: %TRUE if the property has been added to the controller
+ */
+static gboolean
+gst_object_add_controlled_property (GstObject * self, const gchar * name)
+{
+ gboolean res = TRUE;
+
+ /* test if this property isn't yet controlled */
+ if (!gst_object_find_controlled_property (self, name)) {
+ GstControlledProperty *prop;
+
+ /* create GstControlledProperty and add to self->properties list */
+ if ((prop = gst_controlled_property_new (self, name))) {
+ self->properties = g_list_prepend (self->properties, prop);
+ GST_DEBUG_OBJECT (self, "property %s added", name);
+ } else
+ res = FALSE;
+ } else {
+ GST_WARNING_OBJECT (self, "trying to control property %s again", name);
+ }
+ return res;
+}
+
+/*
+ * gst_object_remove_controlled_property:
+ * @self: the object
+ * @name: name of projecty in @object
+ *
+ * Removes a #GstControlledProperty for property @name.
+ *
+ * Returns: %TRUE if the property has been removed from the controller
+ */
+static gboolean
+gst_object_remove_controlled_property (GstObject * self, const gchar * name)
+{
+ gboolean res = TRUE;
+ GstControlledProperty *prop;
+
+ if ((prop = gst_object_find_controlled_property (self, name))) {
+ self->properties = g_list_remove (self->properties, prop);
+ //g_signal_handler_disconnect (self->object, prop->notify_handler_id);
+ gst_controlled_property_free (prop);
+ GST_DEBUG_OBJECT (self, "property %s removed", name);
+ } else {
+ res = FALSE;
+ }
+ return res;
+}
+
/* controller functions */
/**
gboolean
gst_object_control_properties (GstObject * object, ...)
{
- gboolean res = FALSE;
+ gboolean res = TRUE;
va_list var_args;
+ gchar *name;
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
va_start (var_args, object);
- if (object->ctrl) {
- GstController *ctrl = gst_controller_new_valist (object, var_args);
-
- /* FIXME: see gst_controller_new_*() */
- g_object_unref (object->ctrl);
- object->ctrl = ctrl;
-
- res = (object->ctrl != NULL);
- } else {
- res = gst_controller_add_properties_valist ((GstController *) object->ctrl,
- var_args);
+ GST_OBJECT_LOCK (object);
+ while ((name = va_arg (var_args, gchar *))) {
+ res &= gst_object_add_controlled_property (object, name);
}
+ GST_OBJECT_UNLOCK (object);
va_end (var_args);
return res;
}
gboolean
gst_object_uncontrol_properties (GstObject * object, ...)
{
- gboolean res = FALSE;
- g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
+ gboolean res = TRUE;
+ va_list var_args;
+ gchar *name;
- if (object->ctrl) {
- va_list var_args;
+ g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
- va_start (var_args, object);
- res = gst_controller_remove_properties_valist (
- (GstController *) object->ctrl, var_args);
- va_end (var_args);
+ va_start (var_args, object);
+ GST_OBJECT_LOCK (object);
+ while ((name = va_arg (var_args, gchar *))) {
+ res &= gst_object_remove_controlled_property (object, name);
}
+ GST_OBJECT_UNLOCK (object);
+ va_end (var_args);
return (res);
}
* gst_object_suggest_next_sync:
* @object: the object that has controlled properties
*
- * Convenience function for GObject
+ * Returns a suggestion for timestamps where buffers should be split
+ * to get best controller results.
*
- * Returns: same thing as gst_controller_suggest_next_sync()
+ * Returns: Returns the suggested timestamp or %GST_CLOCK_TIME_NONE
+ * if no control-rate was set.
*/
GstClockTime
gst_object_suggest_next_sync (GstObject * object)
{
+ GstClockTime ret;
+
g_return_val_if_fail (GST_IS_OBJECT (object), GST_CLOCK_TIME_NONE);
+ g_return_val_if_fail (object->control_rate != GST_CLOCK_TIME_NONE,
+ GST_CLOCK_TIME_NONE);
+
+ GST_OBJECT_LOCK (object);
+
+ /* TODO: Implement more logic, depending on interpolation mode and control
+ * points
+ * FIXME: we need playback direction
+ */
+ ret = object->last_sync + object->control_rate;
+
+ GST_OBJECT_UNLOCK (object);
- if (object->ctrl)
- return gst_controller_suggest_next_sync ((GstController *) object->ctrl);
- return (GST_CLOCK_TIME_NONE);
+ return ret;
}
/**
* @object: the object that has controlled properties
* @timestamp: the time that should be processed
*
- * Convenience function for GObject
+ * Sets the properties of the object, according to the #GstControlSources that
+ * (maybe) handle them and for the given timestamp.
*
- * Returns: same thing as gst_controller_sync_values()
+ * If this function fails, it is most likely the application developers fault.
+ * Most probably the control sources are not setup correctly.
+ *
+ * Returns: %TRUE if the controller values could be applied to the object
+ * properties, %FALSE otherwise
*/
gboolean
gst_object_sync_values (GstObject * object, GstClockTime timestamp)
{
+ GstControlledProperty *prop;
+ GList *node;
+ gboolean ret = TRUE, val_ret;
+ GValue value = { 0, };
+
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
+
+ GST_LOG ("sync_values");
+
+ /* FIXME: this deadlocks */
+ /* GST_OBJECT_LOCK (object); */
+ g_object_freeze_notify ((GObject *) object);
+ /* go over the controlled properties of the controller */
+ for (node = object->properties; node; node = g_list_next (node)) {
+ prop = node->data;
+
+ if (!prop->csource || prop->disabled)
+ continue;
+
+ GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
+
+ /* we can make this faster
+ * http://bugzilla.gnome.org/show_bug.cgi?id=536939
+ */
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
+ val_ret = gst_control_source_get_value (prop->csource, timestamp, &value);
+ if (G_LIKELY (val_ret)) {
+ /* always set the value for first time, but then only if it changed
+ * this should limit g_object_notify invocations.
+ * FIXME: can we detect negative playback rates?
+ */
+ if ((timestamp < object->last_sync) ||
+ gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) {
+ g_object_set_property ((GObject *) object, prop->name, &value);
+ g_value_copy (&value, &prop->last_value);
+ }
+ } else {
+ GST_DEBUG ("no control value for param %s", prop->name);
+ }
+ g_value_unset (&value);
+ ret &= val_ret;
+ }
+ object->last_sync = timestamp;
+ g_object_thaw_notify ((GObject *) object);
+ /* GST_OBJECT_UNLOCK (object); */
- if (object->ctrl)
- return gst_controller_sync_values ((GstController *) object->ctrl,
- timestamp);
- /* this is no failure, its called by elements regardless if there is a
- * controller assigned or not */
- return (TRUE);
+ return ret;
}
/**
- * gst_object_has_active_automation:
+ * gst_object_has_active_controlled_properties:
* @object: the object that has controlled properties
*
- * Check if the object has an active controller. It has one if it has at least
- * one controlled property that is not disabled.
+ * Check if the @object has an active controlled properties.
*
- * Returns: %TRUE if the controller is active
+ * Returns: %TRUE if the object has active controlled properties
*/
gboolean
-gst_object_has_active_automation (GstObject * object)
+gst_object_has_active_controlled_properties (GstObject * object)
{
gboolean res = FALSE;
+ GList *node;
+ GstControlledProperty *prop;
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
- if (object->ctrl)
- res = gst_controller_is_active ((GstController *) object->ctrl);
+ GST_OBJECT_LOCK (object);
+ for (node = object->properties; node; node = node->next) {
+ prop = node->data;
+ res |= !prop->disabled;
+ }
+ GST_OBJECT_UNLOCK (object);
return res;
}
/**
- * gst_object_set_automation_disabled:
+ * gst_object_set_controlled_properties_disabled:
* @object: the object that has controlled properties
* @disabled: boolean that specifies whether to disable the controller
* or not.
*
- * This function is used to disable all properties of the #GstController
- * for some time, i.e. gst_object_sync_values() will do nothing..
+ * This function is used to disable all controlled properties of the @object for
+ * some time, i.e. gst_object_sync_values() will do nothing..
*/
void
-gst_object_set_automation_disabled (GstObject * object, gboolean disabled)
+gst_object_set_controlled_properties_disabled (GstObject * object,
+ gboolean disabled)
{
+ GList *node;
+ GstControlledProperty *prop;
+
g_return_if_fail (GST_IS_OBJECT (object));
- if (object->ctrl)
- gst_controller_set_disabled (object->ctrl, disabled);
+ GST_OBJECT_LOCK (object);
+ for (node = object->properties; node; node = node->next) {
+ prop = node->data;
+ prop->disabled = disabled;
+ }
+ GST_OBJECT_UNLOCK (object);
}
/**
- * gst_object_set_property_automation_disabled:
+ * gst_object_set_controlled_property_disabled:
* @object: the object that has controlled properties
* @property_name: property to disable
* @disabled: boolean that specifies whether to disable the controller
* property.
*/
void
-gst_object_set_property_automation_disabled (GstObject * object,
+gst_object_set_controlled_property_disabled (GstObject * object,
const gchar * property_name, gboolean disabled)
{
+ GstControlledProperty *prop;
+
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (property_name);
- if (object->ctrl)
- gst_controller_set_property_disabled ((GstController *) object->ctrl,
- property_name, disabled);
+ GST_OBJECT_LOCK (object);
+ if ((prop = gst_object_find_controlled_property (object, property_name))) {
+ prop->disabled = disabled;
+ }
+ GST_OBJECT_UNLOCK (object);
}
/**
gst_object_set_control_source (GstObject * object, const gchar * property_name,
GstControlSource * csource)
{
+ GstControlledProperty *prop;
+ gboolean ret = FALSE;
+
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
g_return_val_if_fail (property_name, FALSE);
- g_return_val_if_fail (GST_IS_CONTROL_SOURCE (csource), FALSE);
+ g_return_val_if_fail ((!csource || GST_IS_CONTROL_SOURCE (csource)), FALSE);
- if (object->ctrl)
- return gst_controller_set_control_source ((GstController *) object->ctrl,
- property_name, csource);
- return FALSE;
+ GST_OBJECT_LOCK (object);
+ if ((prop = gst_object_find_controlled_property (object, property_name))) {
+ GstControlSource *old = prop->csource;
+
+ if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) {
+ prop->csource = g_object_ref (csource);
+ } else if (!csource) {
+ ret = TRUE;
+ prop->csource = NULL;
+ }
+
+ if (ret && old)
+ g_object_unref (old);
+ }
+ GST_OBJECT_UNLOCK (object);
+
+ return ret;
}
/**
GstControlSource *
gst_object_get_control_source (GstObject * object, const gchar * property_name)
{
+ GstControlledProperty *prop;
+ GstControlSource *ret = NULL;
+
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
g_return_val_if_fail (property_name, NULL);
- if (object->ctrl)
- return gst_controller_get_control_source ((GstController *) object->ctrl,
- property_name);
- return NULL;
+ GST_OBJECT_LOCK (object);
+ if ((prop = gst_object_find_controlled_property (object, property_name))) {
+ if ((ret = prop->csource))
+ g_object_ref (ret);
+ }
+ GST_OBJECT_UNLOCK (object);
+
+ return ret;
}
-// FIXME: docs
+/**
+ * gst_object_get_value:
+ * @object: the object that has controlled properties
+ * @property_name: the name of the property to get
+ * @timestamp: the time the control-change should be read from
+ *
+ * Gets the value for the given controllered property at the requested time.
+ *
+ * Returns: the GValue of the property at the given time, or %NULL if the
+ * property isn't controlled.
+ */
GValue *
gst_object_get_value (GstObject * object, const gchar * property_name,
GstClockTime timestamp)
{
+ GstControlledProperty *prop;
+ GValue *val = NULL;
+
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
g_return_val_if_fail (property_name, NULL);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), NULL);
- if (object->ctrl)
- return gst_controller_get (object->ctrl, property_name, timestamp);
- return NULL;
+ GST_OBJECT_LOCK (object);
+ if ((prop = gst_object_find_controlled_property (object, property_name))) {
+ val = g_new0 (GValue, 1);
+ g_value_init (val, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
+ if (prop->csource) {
+ gboolean res;
+
+ /* get current value via control source */
+ res = gst_control_source_get_value (prop->csource, timestamp, val);
+ if (!res) {
+ g_free (val);
+ val = NULL;
+ }
+ } else {
+ g_object_get_property ((GObject *) object, prop->name, val);
+ }
+ }
+ GST_OBJECT_UNLOCK (object);
+
+ return val;
}
/**
gst_object_get_value_arrays (GstObject * object, GstClockTime timestamp,
GSList * value_arrays)
{
+ gboolean res = TRUE;
+ GSList *node;
+
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
+ g_return_val_if_fail (value_arrays, FALSE);
- if (object->ctrl)
- return gst_controller_get_value_arrays ((GstController *) object->ctrl,
- timestamp, value_arrays);
- return (FALSE);
+ for (node = value_arrays; (res && node); node = g_slist_next (node)) {
+ res = gst_object_get_value_array (object, timestamp, node->data);
+ }
+ return res;
}
/**
gst_object_get_value_array (GstObject * object, GstClockTime timestamp,
GstValueArray * value_array)
{
+ gboolean res = FALSE;
+ GstControlledProperty *prop;
+
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
+ g_return_val_if_fail (value_array, FALSE);
+ g_return_val_if_fail (value_array->property_name, FALSE);
+ g_return_val_if_fail (value_array->values, FALSE);
- if (object->ctrl)
- return gst_controller_get_value_array ((GstController *) object->ctrl,
- timestamp, value_array);
- return (FALSE);
+ GST_OBJECT_LOCK (object);
+
+ if ((prop = gst_object_find_controlled_property (object,
+ value_array->property_name))) {
+ /* get current value_array via control source */
+ if (!prop->csource)
+ goto out;
+
+ res = gst_control_source_get_value_array (prop->csource, timestamp,
+ value_array);
+ }
+
+out:
+ GST_OBJECT_UNLOCK (object);
+ return res;
}
/**
GstClockTime
gst_object_get_control_rate (GstObject * object)
{
- GstClockTime control_rate = GST_CLOCK_TIME_NONE;
-
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
- if (object->ctrl)
- g_object_get (object->ctrl, "control-rate", &control_rate, NULL);
- return (control_rate);
+ return object->control_rate;
}
/**
{
g_return_if_fail (GST_IS_OBJECT (object));
- if (object->ctrl)
- g_object_set (object->ctrl, "control-rate", control_rate, NULL);
+ object->control_rate = control_rate;
}
/* tests for an element with no controlled params */
GST_START_TEST (controller_new_fail1)
{
- GstController *ctrl;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("fakesrc", "test_source");
- ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
-
/* that property should not exist */
- res = gst_controller_add_properties (ctrl, "_schrompf_", NULL);
+ res = gst_object_control_properties (GST_OBJECT (elem), "_schrompf_", NULL);
fail_unless (res == FALSE, NULL);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* tests for readonly params */
GST_START_TEST (controller_new_fail2)
{
- GstController *ctrl;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
- ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should exist and but is readonly */
ASSERT_CRITICAL (res =
- gst_controller_add_properties (ctrl, "readonly", NULL));
+ gst_object_control_properties (GST_OBJECT (elem), "readonly", NULL));
fail_unless (res == FALSE, NULL);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* tests for static params */
GST_START_TEST (controller_new_fail3)
{
- GstController *ctrl;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
- ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should exist and but is not controlable */
- ASSERT_CRITICAL (res = gst_controller_add_properties (ctrl, "static", NULL));
+ ASSERT_CRITICAL (res = gst_object_control_properties (GST_OBJECT (elem),
+ "static", NULL));
fail_unless (res == FALSE, NULL);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* tests for construct-only params */
GST_START_TEST (controller_new_fail4)
{
- GstController *ctrl;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
- ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should exist and but is construct-only */
ASSERT_CRITICAL (res =
- gst_controller_add_properties (ctrl, "construct-only", NULL));
+ gst_object_control_properties (GST_OBJECT (elem), "construct-only",
+ NULL));
fail_unless (res == FALSE, NULL);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* tests for an element with controlled params */
GST_START_TEST (controller_new_okay1)
{
- GstController *ctrl;
GstElement *elem;
+ gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ res = gst_object_control_properties (GST_OBJECT (elem), "ulong", NULL);
+ fail_unless (res == TRUE, NULL);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* tests for an element with several controlled params */
GST_START_TEST (controller_new_okay2)
{
- GstController *ctrl;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- ctrl =
- gst_controller_new (GST_OBJECT (elem), "ulong", "double", "float", NULL);
- fail_unless (ctrl != NULL, NULL);
-
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
+ /* these properties should exist and should be controllable */
+ res = gst_object_control_properties (GST_OBJECT (elem), "ulong", "double",
+ "float", NULL);
+ fail_unless (res == TRUE, NULL);
- res = gst_controller_add_properties (ctrl, "boolean", NULL);
+ res = gst_object_control_properties (GST_OBJECT (elem), "boolean", NULL);
fail_unless (res == TRUE, NULL);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* controlling a params twice should be handled */
GST_START_TEST (controller_param_twice)
{
- GstController *ctrl;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ res =
+ gst_object_control_properties (GST_OBJECT (elem), "ulong", "ulong", NULL);
+ fail_unless (res, NULL);
/* it should have been added at least once, let remove it */
- res = gst_controller_remove_properties (ctrl, "ulong", NULL);
+ res = gst_object_uncontrol_properties (GST_OBJECT (elem), "ulong", NULL);
fail_unless (res, NULL);
/* removing it again should not work */
- res = gst_controller_remove_properties (ctrl, "ulong", NULL);
+ res = gst_object_uncontrol_properties (GST_OBJECT (elem), "ulong", NULL);
fail_unless (!res, NULL);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* tests if we cleanup properly */
GST_START_TEST (controller_controlsource_refcounts)
{
- GstController *ctrl;
GstElement *elem;
GstControlSource *csource, *test_csource;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
csource = (GstControlSource *) gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL);
fail_unless_equals_int (G_OBJECT (csource)->ref_count, 1);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong", csource));
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
+ csource));
fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2);
- g_object_unref (G_OBJECT (csource));
-
- test_csource = gst_controller_get_control_source (ctrl, "ulong");
+ test_csource = gst_object_get_control_source (GST_OBJECT (elem), "ulong");
fail_unless (test_csource != NULL, NULL);
fail_unless (test_csource == csource);
- fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2);
+ fail_unless_equals_int (G_OBJECT (csource)->ref_count, 3);
+ g_object_unref (test_csource);
g_object_unref (csource);
- /* free the controller */
- g_object_unref (ctrl);
-
gst_object_unref (elem);
}
GST_END_TEST;
-/* tests if we don't fail on empty controllers */
+/* tests if we don't fail on empty interpolation controlsources */
GST_START_TEST (controller_controlsource_empty1)
{
- GstController *ctrl;
GstElement *elem;
GstControlSource *csource;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
csource = (GstControlSource *) gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong", csource));
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
+ csource));
/* don't fail on empty control point lists */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
/* unref objects */
g_object_unref (csource);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
GST_END_TEST;
-/* tests if we don't fail on controllers that are empty again */
+/* tests if we don't fail on interpolation controlsources that are empty again */
GST_START_TEST (controller_controlsource_empty2)
{
- GstController *ctrl;
GstElement *elem;
GstInterpolationControlSource *csource;
GValue val = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
(GstControlSource *) csource));
/* set control values */
gst_interpolation_control_source_unset (csource, 0 * GST_SECOND);
/* don't fail on empty control point lists */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
/* unref objects */
g_object_unref (csource);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test timed value handling without interpolation */
GST_START_TEST (controller_interpolate_none)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (res, NULL);
fail_unless (gst_interpolation_control_source_get_count (csource) == 2);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test timed value handling in trigger mode */
GST_START_TEST (controller_interpolate_trigger)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
/* now pull in values for some timestamps */
fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
0 * GST_SECOND, &val_ulong));
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
1 * GST_SECOND, &val_ulong));
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
2 * GST_SECOND, &val_ulong));
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (G_OBJECT (csource));
- g_object_unref (ctrl);
+ g_object_unref (csource);
gst_object_unref (elem);
}
/* test timed value handling with linear interpolation */
GST_START_TEST (controller_interpolate_linear)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
&val_ulong);
fail_unless (res, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test timed value handling with cubic interpolation */
GST_START_TEST (controller_interpolate_cubic)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "double", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "double",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "double",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
&val_double);
fail_unless (res, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 0.0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 5.0);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 2.0);
- gst_controller_sync_values (ctrl, 3 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 3 * GST_SECOND);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double > 2.0 &&
GST_TEST_MONO_SOURCE (elem)->val_double < 8.0, NULL);
- gst_controller_sync_values (ctrl, 4 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 4 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 8.0);
- gst_controller_sync_values (ctrl, 5 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 5 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 8.0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test timed value handling with cubic interpolation */
GST_START_TEST (controller_interpolate_cubic_too_few_cp)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "double", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "double",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "double",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
&val_double);
fail_unless (res, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps and verify that it used linear
* interpolation as we don't gave enough control points
*/
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 0.0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 2.0);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 4.0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
* mode */
GST_START_TEST (controller_interpolate_unimplemented)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set completely bogus interpolation mode */
fail_if (gst_interpolation_control_source_set_interpolation_mode (csource,
(GstInterpolateMode) 93871));
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test _unset() */
GST_START_TEST (controller_interpolation_unset)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (res, NULL);
/* verify values */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
/* unset second */
fail_unless (res, NULL);
/* verify value again */
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
/* unset all values, reset and try to unset again */
g_object_unref (csource);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test _unset_all() */
GST_START_TEST (controller_interpolation_unset_all)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (res, NULL);
/* verify values */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
/* unset all */
g_object_unref (csource);
/* verify value again */
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test retrieval of an array of values with get_value_array() */
GST_START_TEST (controller_interpolation_linear_value_array)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
g_object_unref (csource);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
g_free (values.values);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test if values below minimum and above maximum are clipped */
GST_START_TEST (controller_interpolation_linear_invalid_values)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "float", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "float",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "float",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "float",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
/* now pull in values for some timestamps and see if clipping works */
/* 200.0 */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 100.0);
/* 100.0 */
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 100.0);
/* 50.0 */
- gst_controller_sync_values (ctrl, 1 * GST_SECOND + 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem),
+ 1 * GST_SECOND + 500 * GST_MSECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 50.0);
/* 0.0 */
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
/* -100.0 */
- gst_controller_sync_values (ctrl, 3 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 3 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
/* -200.0 */
- gst_controller_sync_values (ctrl, 4 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 4 * GST_SECOND);
fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
GST_START_TEST (controller_interpolation_linear_default_values)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
/* now pull in values for some timestamps */
/* should give the value of the first control point for timestamps before it */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 3 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 3 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
/* set control values */
/* now pull in values for some timestamps */
/* should now give our value for timestamp 0 */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test gst_controller_set_disabled() with linear interpolation */
GST_START_TEST (controller_interpolate_linear_disabled)
{
- GstController *ctrl;
GstInterpolationControlSource *csource, *csource2;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", "double", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ "double", NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
csource2 = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
fail_unless (csource2 != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "double",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double",
GST_CONTROL_SOURCE (csource2)));
/* set interpolation mode */
&val_ulong);
fail_unless (res, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* set control values */
g_value_init (&val_double, G_TYPE_DOUBLE);
g_object_unref (G_OBJECT (csource2));
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
/* now pull in values for some timestamps, prop double disabled */
GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
- gst_controller_set_property_disabled (ctrl, "double", TRUE);
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_set_controlled_property_disabled (GST_OBJECT (elem), "double",
+ TRUE);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
/* now pull in values for some timestamps, after enabling double again */
GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
- gst_controller_set_property_disabled (ctrl, "double", FALSE);
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_set_controlled_property_disabled (GST_OBJECT (elem), "double",
+ FALSE);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
/* now pull in values for some timestamps, after disabling all props */
GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
- gst_controller_set_disabled (ctrl, TRUE);
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_set_controlled_properties_disabled (GST_OBJECT (elem), TRUE);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
/* now pull in values for some timestamps, enabling double again */
GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
- gst_controller_set_property_disabled (ctrl, "double", FALSE);
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_set_controlled_property_disabled (GST_OBJECT (elem), "double",
+ FALSE);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
/* now pull in values for some timestamps, enabling all */
GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
- gst_controller_set_disabled (ctrl, FALSE);
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_set_controlled_properties_disabled (GST_OBJECT (elem), FALSE);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
GST_START_TEST (controller_interpolation_set_from_list)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstTimedValue *tval;
GstElement *elem;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
g_value_unset (&tval->value);
g_free (tval);
g_slist_free (list);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with sine waveform */
GST_START_TEST (controller_lfo_sine)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
GValue amp = { 0, }
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set amplitude and offset values */
"frequency", 1.0, "timeshift", (GstClockTime) 0,
"amplitude", &, "offset", &off, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with sine waveform and timeshift */
GST_START_TEST (controller_lfo_sine_timeshift)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
GValue amp = { 0, }
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set amplitude and offset values */
"frequency", 1.0, "timeshift", 250 * GST_MSECOND,
"amplitude", &, "offset", &off, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with square waveform */
GST_START_TEST (controller_lfo_square)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
GValue amp = { 0, }
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set amplitude and offset values */
"frequency", 1.0, "timeshift", (GstClockTime) 0,
"amplitude", &, "offset", &off, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with saw waveform */
GST_START_TEST (controller_lfo_saw)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
GValue amp = { 0, }
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set amplitude and offset values */
"frequency", 1.0, "timeshift", (GstClockTime) 0,
"amplitude", &, "offset", &off, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with reverse saw waveform */
GST_START_TEST (controller_lfo_rsaw)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
GValue amp = { 0, }
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set amplitude and offset values */
"frequency", 1.0, "timeshift", (GstClockTime) 0,
"amplitude", &, "offset", &off, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with saw waveform */
GST_START_TEST (controller_lfo_triangle)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
GValue amp = { 0, }
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set amplitude and offset values */
"frequency", 1.0, "timeshift", (GstClockTime) 0,
"amplitude", &, "offset", &off, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test lfo control source with nothing set */
GST_START_TEST (controller_lfo_none)
{
- GstController *ctrl;
GstLFOControlSource *csource;
GstElement *elem;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps */
- gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
GST_END_TEST;
-GST_START_TEST (controller_refcount_new_list)
-{
- GstController *ctrl;
- GstElement *elem;
- GList *list = NULL;
-
- /* that property should exist and should be controllable */
- elem = gst_element_factory_make ("testmonosource", "test_source");
- list = g_list_append (NULL, (char *) "ulong");
- ctrl = gst_controller_new_list (GST_OBJECT (elem), list);
- fail_unless (ctrl != NULL, NULL);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
- g_list_free (list);
- g_object_unref (ctrl);
- gst_object_unref (elem);
-
- /* try the same property twice, make sure the refcount is still 1 */
- elem = gst_element_factory_make ("testmonosource", "test_source");
- list = g_list_append (NULL, (char *) "ulong");
- list = g_list_append (list, (char *) "ulong");
- ctrl = gst_controller_new_list (GST_OBJECT (elem), list);
- fail_unless (ctrl != NULL, NULL);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
- g_list_free (list);
- g_object_unref (ctrl);
- gst_object_unref (elem);
-
- /* try two properties, make sure the refcount is still 1 */
- elem = gst_element_factory_make ("testmonosource", "test_source");
- list = g_list_append (NULL, (char *) "ulong");
- list = g_list_append (list, (char *) "boolean");
- ctrl = gst_controller_new_list (GST_OBJECT (elem), list);
- fail_unless (ctrl != NULL, NULL);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
- g_list_free (list);
- g_object_unref (ctrl);
- gst_object_unref (elem);
-}
-
-GST_END_TEST;
-
/* test linear interpolation for ts < first control point */
GST_START_TEST (controller_interpolate_linear_before_ts0)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
&val_ulong);
fail_unless (res, NULL);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
/* now pull in values for some timestamps after first control point */
- gst_controller_sync_values (ctrl, 2 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 2 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);
- gst_controller_sync_values (ctrl, 3 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 3 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 4 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 4 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
/* now pull in values for some timestamps before first control point */
- gst_controller_sync_values (ctrl, 1 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 1 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);
- gst_controller_sync_values (ctrl, 0 * GST_SECOND);
+ gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
/* test control-point handling in interpolation control source */
GST_START_TEST (controller_interpolation_cp_count)
{
- GstController *ctrl;
GstInterpolationControlSource *csource;
GstElement *elem;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
- ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
- fail_unless (ctrl != NULL, NULL);
+ fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
+ NULL));
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
- fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+ fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (res, NULL);
fail_unless (gst_interpolation_control_source_get_count (csource) == 0);
- g_object_unref (G_OBJECT (csource));
+ g_object_unref (csource);
- GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
- g_object_unref (ctrl);
gst_object_unref (elem);
}
suite_add_tcase (s, tc);
tcase_add_checked_fixture (tc, setup, teardown);
- tcase_add_test (tc, controller_refcount_new_list);
tcase_add_test (tc, controller_new_fail1);
tcase_add_test (tc, controller_new_fail2);
tcase_add_test (tc, controller_new_fail3);