summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2012-04-25 09:47:10 +0200
committerStefan Sauer <ensonic@users.sf.net>2012-04-25 20:19:23 +0200
commit772c58e255d8d0358ad21bb64b49fb49e6271bc7 (patch)
tree164741baeb36b0b618be9467b92cfd61350ad6e7 /gst
parent12eefc0442695fce2ace96ede3221b59068cd74c (diff)
controller: expand the api to offer functions for plain and GValue arrays
Rename the _get_value_array() functions to _get_g_value_array() and reintroduce the former to operate on plain unboxed c datatypes (like in 0.10). The _g_value variants are for bindings while the _value ones are more suited to processing in elements.
Diffstat (limited to 'gst')
-rw-r--r--gst/gstcontrolbinding.c57
-rw-r--r--gst/gstcontrolbinding.h5
-rw-r--r--gst/gstcontrolsource.c3
-rw-r--r--gst/gstobject.c49
-rw-r--r--gst/gstobject.h3
5 files changed, 111 insertions, 6 deletions
diff --git a/gst/gstcontrolbinding.c b/gst/gstcontrolbinding.c
index b9b7bd89a..8394dd229 100644
--- a/gst/gstcontrolbinding.c
+++ b/gst/gstcontrolbinding.c
@@ -31,6 +31,13 @@
* gst_control_binding_constructor()
* - the weak-ref on object is not nice, as is the same as gst_object_parent()
* once the object is added to the parent
+ *
+ * - another option would be do defer what I am doing in _constructor to when
+ * the parent is set (need to listen to the signal then)
+ * then basically I could
+ * a) remove the obj arg and wait the binding to be added or
+ * b) add the binding from constructor, unref object there and make obj
+ * writeonly
*/
#include "gst_private.h"
@@ -273,19 +280,23 @@ gst_control_binding_get_value (GstControlBinding * self, GstClockTime timestamp)
* @n_values: the number of values
* @values: array to put control-values in
*
- * Gets a number of values for the given controllered property starting at the
+ * Gets a number of values for the given controlled property starting at the
* requested time. The array @values need to hold enough space for @n_values of
* the same type as the objects property's type.
*
* This function is useful if one wants to e.g. draw a graph of the control
* curve or apply a control curve sample by sample.
*
+ * The values are unboxed and ready to be used. The similar function
+ * gst_control_binding_get_g_value_array() returns the array as #GValues and is
+ * better suites for bindings.
+ *
* Returns: %TRUE if the given array could be filled, %FALSE otherwise
*/
gboolean
gst_control_binding_get_value_array (GstControlBinding * self,
GstClockTime timestamp, GstClockTime interval, guint n_values,
- GValue * values)
+ gpointer values)
{
GstControlBindingClass *klass;
gboolean ret = FALSE;
@@ -306,6 +317,48 @@ gst_control_binding_get_value_array (GstControlBinding * self,
}
/**
+ * gst_control_binding_get_g_value_array:
+ * @self: the control binding
+ * @timestamp: the time that should be processed
+ * @interval: the time spacing between subsequent values
+ * @n_values: the number of values
+ * @values: array to put control-values in
+ *
+ * Gets a number of #GValues for the given controlled property starting at the
+ * requested time. The array @values need to hold enough space for @n_values of
+ * #GValue.
+ *
+ * This function is useful if one wants to e.g. draw a graph of the control
+ * curve or apply a control curve sample by sample.
+ *
+ * Returns: %TRUE if the given array could be filled, %FALSE otherwise
+ */
+gboolean
+gst_control_binding_get_g_value_array (GstControlBinding * self,
+ GstClockTime timestamp, GstClockTime interval, guint n_values,
+ GValue * values)
+{
+ GstControlBindingClass *klass;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (GST_IS_CONTROL_BINDING (self), FALSE);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE);
+ g_return_val_if_fail (values, FALSE);
+
+ klass = GST_CONTROL_BINDING_GET_CLASS (self);
+
+ if (G_LIKELY (klass->get_g_value_array != NULL)) {
+ ret =
+ klass->get_g_value_array (self, timestamp, interval, n_values, values);
+ } else {
+ GST_WARNING_OBJECT (self, "missing get_g_value_array implementation");
+ // FIXME(ensonic): emulate
+ }
+ return ret;
+}
+
+/**
* gst_control_binding_set_disabled:
* @self: the control binding
* @disabled: boolean that specifies whether to disable the controller
diff --git a/gst/gstcontrolbinding.h b/gst/gstcontrolbinding.h
index 96652fab5..7f83d3d19 100644
--- a/gst/gstcontrolbinding.h
+++ b/gst/gstcontrolbinding.h
@@ -93,7 +93,8 @@ struct _GstControlBindingClass
/* virtual methods */
gboolean (* sync_values) (GstControlBinding *self, GstObject *object, GstClockTime timestamp, GstClockTime last_sync);
GValue * (* get_value) (GstControlBinding *self, GstClockTime timestamp);
- gboolean (* get_value_array) (GstControlBinding *self, GstClockTime timestamp,GstClockTime interval, guint n_values, GValue *values);
+ gboolean (* get_value_array) (GstControlBinding *self, GstClockTime timestamp,GstClockTime interval, guint n_values, gpointer values);
+ gboolean (* get_g_value_array) (GstControlBinding *self, GstClockTime timestamp,GstClockTime interval, guint n_values, GValue *values);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
@@ -110,6 +111,8 @@ gboolean gst_control_binding_sync_values (GstControlBinding *
GValue * gst_control_binding_get_value (GstControlBinding *binding,
GstClockTime timestamp);
gboolean gst_control_binding_get_value_array (GstControlBinding *binding, GstClockTime timestamp,
+ GstClockTime interval, guint n_values, gpointer values);
+gboolean gst_control_binding_get_g_value_array (GstControlBinding *binding, GstClockTime timestamp,
GstClockTime interval, guint n_values, GValue *values);
void gst_control_binding_set_disabled (GstControlBinding * self, gboolean disabled);
diff --git a/gst/gstcontrolsource.c b/gst/gstcontrolsource.c
index b75c2eea3..611784f91 100644
--- a/gst/gstcontrolsource.c
+++ b/gst/gstcontrolsource.c
@@ -122,7 +122,8 @@ gst_control_source_get_value (GstControlSource * self, GstClockTime timestamp,
* @n_values: the number of values to fetch
* @value_array: array to put control-values in
*
- * Gets an array of values for for this #GstControlSource.
+ * Gets an array of values for for this #GstControlSource. Values that are
+ * undefined contain NANs.
*
* Returns: %TRUE if the given array could be filled, %FALSE otherwise
*/
diff --git a/gst/gstobject.c b/gst/gstobject.c
index 18dbbeb27..6f58e3dac 100644
--- a/gst/gstobject.c
+++ b/gst/gstobject.c
@@ -1300,19 +1300,23 @@ gst_object_get_value (GstObject * object, const gchar * property_name,
* @n_values: the number of values
* @values: array to put control-values in
*
- * Gets a number of values for the given controllered property starting at the
+ * Gets a number of values for the given controlled property starting at the
* requested time. The array @values need to hold enough space for @n_values of
* the same type as the objects property's type.
*
* This function is useful if one wants to e.g. draw a graph of the control
* curve or apply a control curve sample by sample.
*
+ * The values are unboxed and ready to be used. The similar function
+ * gst_object_get_g_value_array() returns the array as #GValues and is
+ * better suites for bindings.
+ *
* Returns: %TRUE if the given array could be filled, %FALSE otherwise
*/
gboolean
gst_object_get_value_array (GstObject * object, const gchar * property_name,
GstClockTime timestamp, GstClockTime interval, guint n_values,
- GValue * values)
+ gpointer values)
{
gboolean res = FALSE;
GstControlBinding *binding;
@@ -1332,6 +1336,47 @@ gst_object_get_value_array (GstObject * object, const gchar * property_name,
return res;
}
+/**
+ * gst_object_get_g_value_array:
+ * @object: the object that has controlled properties
+ * @property_name: the name of the property to get
+ * @timestamp: the time that should be processed
+ * @interval: the time spacing between subsequent values
+ * @n_values: the number of values
+ * @values: array to put control-values in
+ *
+ * Gets a number of #GValues for the given controlled property starting at the
+ * requested time. The array @values need to hold enough space for @n_values of
+ * #GValue.
+ *
+ * This function is useful if one wants to e.g. draw a graph of the control
+ * curve or apply a control curve sample by sample.
+ *
+ * Returns: %TRUE if the given array could be filled, %FALSE otherwise
+ */
+gboolean
+gst_object_get_g_value_array (GstObject * object, const gchar * property_name,
+ GstClockTime timestamp, GstClockTime interval, guint n_values,
+ GValue * values)
+{
+ gboolean res = FALSE;
+ GstControlBinding *binding;
+
+ g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
+ g_return_val_if_fail (property_name, FALSE);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
+ g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE);
+ g_return_val_if_fail (values, FALSE);
+
+ GST_OBJECT_LOCK (object);
+ if ((binding = gst_object_find_control_binding (object, property_name))) {
+ res = gst_control_binding_get_g_value_array (binding, timestamp, interval,
+ n_values, values);
+ }
+ GST_OBJECT_UNLOCK (object);
+ return res;
+}
+
/**
* gst_object_get_control_rate:
diff --git a/gst/gstobject.h b/gst/gstobject.h
index e7535166c..6c9f9f5c0 100644
--- a/gst/gstobject.h
+++ b/gst/gstobject.h
@@ -253,6 +253,9 @@ GValue * gst_object_get_value (GstObject * object, const gch
GstClockTime timestamp);
gboolean gst_object_get_value_array (GstObject * object, const gchar * property_name,
GstClockTime timestamp, GstClockTime interval,
+ guint n_values, gpointer values);
+gboolean gst_object_get_g_value_array (GstObject * object, const gchar * property_name,
+ GstClockTime timestamp, GstClockTime interval,
guint n_values, GValue *values);
GstClockTime gst_object_get_control_rate (GstObject * object);