/* imports from gst-interpolation.c */
extern GList
- * gst_controlled_property_find_timed_value_node (GstControlledProperty *
+ * gst_controlled_property_find_control_point_node (GstControlledProperty *
prop, GstClockTime timestamp);
extern GstInterpolateMethod *interpolation_methods[];
extern guint num_interpolation_methods;
/* helper */
/*
- * gst_timed_value_compare:
- * @p1: a pointer to a #GstTimedValue
- * @p2: a pointer to a #GstTimedValue
+ * gst_control_point_compare:
+ * @p1: a pointer to a #GstControlPoint
+ * @p2: a pointer to a #GstControlPoint
*
- * Compare function for g_list operations that operates on two #GstTimedValue
+ * Compare function for g_list operations that operates on two #GstControlPoint
* parameters.
*/
static gint
-gst_timed_value_compare (gconstpointer p1, gconstpointer p2)
+gst_control_point_compare (gconstpointer p1, gconstpointer p2)
{
- GstClockTime ct1 = ((GstTimedValue *) p1)->timestamp;
- GstClockTime ct2 = ((GstTimedValue *) p2)->timestamp;
+ GstClockTime ct1 = ((GstControlPoint *) p1)->timestamp;
+ GstClockTime ct2 = ((GstControlPoint *) p2)->timestamp;
return ((ct1 < ct2) ? -1 : ((ct1 == ct2) ? 0 : 1));
/* this does not produce an gint :(
}
/*
- * gst_timed_value_find:
- * @p1: a pointer to a #GstTimedValue
+ * gst_control_point_find:
+ * @p1: a pointer to a #GstControlPoint
* @p2: a pointer to a #GstClockTime
*
- * Compare function for g_list operations that operates on a #GstTimedValue and
+ * Compare function for g_list operations that operates on a #GstControlPoint and
* a #GstClockTime.
*/
static gint
-gst_timed_value_find (gconstpointer p1, gconstpointer p2)
+gst_control_point_find (gconstpointer p1, gconstpointer p2)
{
- GstClockTime ct1 = ((GstTimedValue *) p1)->timestamp;
+ GstClockTime ct1 = ((GstControlPoint *) p1)->timestamp;
GstClockTime ct2 = *(GstClockTime *) p2;
return ((ct1 < ct2) ? -1 : ((ct1 == ct2) ? 0 : 1));
GST_WARNING ("incomplete implementation for paramspec type '%s'",
G_PARAM_SPEC_TYPE_NAME (pspec));
}
- /* TODO what about adding a timed-val with timestamp=0 and value=default
+ /* TODO what about adding a control point with timestamp=0 and value=default
* a bit easier for interpolators, example:
* first timestamp is at 5
* requested value if for timestamp=3
}
/*
+ * gst_control_point_free:
+ * @prop: the object to free
+ *
+ * Private method which frees all data allocated by a #GstControlPoint
+ * instance.
+ */
+static void
+gst_control_point_free (GstControlPoint * cp)
+{
+ g_return_if_fail (cp);
+
+ g_value_unset (&cp->value);
+ g_free (cp);
+}
+
+/*
+
* gst_controlled_property_free:
* @prop: the object to free
*
static void
gst_controlled_property_free (GstControlledProperty * prop)
{
- GList *node;
-
- for (node = prop->values; node; node = g_list_next (node)) {
- g_free (node->data);
- }
+ g_list_foreach (prop->values, (GFunc) gst_control_point_free, NULL);
g_list_free (prop->values);
+
+ g_value_unset (&prop->default_value);
+ g_value_unset (&prop->result_value);
+ g_value_unset (&prop->last_value.value);
+ if (G_IS_VALUE (&prop->live_value.value))
+ g_value_unset (&prop->live_value.value);
+
g_free (prop);
}
g_mutex_lock (self->lock);
if ((prop = gst_controller_find_controlled_property (self, property_name))) {
if (G_VALUE_TYPE (value) == prop->type) {
- GstTimedValue *tv;
+ GstControlPoint *cp;
GList *node;
- /* check if a timed_value for the timestamp already exists */
+ /* check if a control point for the timestamp already exists */
if ((node = g_list_find_custom (prop->values, ×tamp,
- gst_timed_value_find))) {
- tv = node->data;
- memcpy (&tv->value, value, sizeof (GValue));
+ gst_control_point_find))) {
+ cp = node->data;
+ g_value_reset (&cp->value);
+ g_value_copy (value, &cp->value);
} else {
- /* create a new GstTimedValue */
- tv = g_new (GstTimedValue, 1);
- tv->timestamp = timestamp;
- memcpy (&tv->value, value, sizeof (GValue));
+ /* create a new GstControlPoint */
+ cp = g_new0 (GstControlPoint, 1);
+ cp->timestamp = timestamp;
+ g_value_init (&cp->value, prop->type);
+ g_value_copy (value, &cp->value);
/* and sort it into the prop->values list */
prop->values =
- g_list_insert_sorted (prop->values, tv, gst_timed_value_compare);
+ g_list_insert_sorted (prop->values, cp, gst_control_point_compare);
}
res = TRUE;
} else {
GstControlledProperty *prop;
GSList *node;
GstTimedValue *tv;
+ GstControlPoint *cp;
g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
g_return_val_if_fail (property_name, FALSE);
tv = node->data;
if (G_VALUE_TYPE (&tv->value) == prop->type) {
if (GST_CLOCK_TIME_IS_VALID (tv->timestamp)) {
- /* TODO copy the timed value or just link in? */
+ cp = g_new0 (GstControlPoint, 1);
+ cp->timestamp = tv->timestamp;
+ g_value_init (&cp->value, prop->type);
+ g_value_copy (&tv->value, &cp->value);
prop->values =
- g_list_insert_sorted (prop->values, tv, gst_timed_value_compare);
+ g_list_insert_sorted (prop->values, cp,
+ gst_control_point_compare);
res = TRUE;
} else {
g_warning ("GstTimedValued with invalid timestamp passed to %s "
if ((prop = gst_controller_find_controlled_property (self, property_name))) {
GList *node;
- /* check if a timed_value for the timestamp exists */
+ /* check if a control point for the timestamp exists */
if ((node = g_list_find_custom (prop->values, ×tamp,
- gst_timed_value_find))) {
- g_free (node->data); /* free GstTimedValue */
+ gst_control_point_find))) {
+ gst_control_point_free (node->data); /* free GstControlPoint */
prop->values = g_list_delete_link (prop->values, node);
res = TRUE;
}
g_mutex_lock (self->lock);
if ((prop = gst_controller_find_controlled_property (self, property_name))) {
- /* free GstTimedValue structures */
- g_list_foreach (prop->values, (GFunc) g_free, NULL);
+ /* free GstControlPoint structures */
+ g_list_foreach (prop->values, (GFunc) gst_control_point_free, NULL);
g_list_free (prop->values);
prop->values = NULL;
res = TRUE;
live = FALSE;
if (G_UNLIKELY (G_IS_VALUE (&prop->live_value.value))) {
GList *lnode =
- gst_controlled_property_find_timed_value_node (prop, timestamp);
+ gst_controlled_property_find_control_point_node (prop, timestamp);
if (G_UNLIKELY (!lnode)) {
GST_DEBUG (" no control changes in the queue");
live = TRUE;
} else {
- GstTimedValue *tv = lnode->data;
+ GstControlPoint *cp = lnode->data;
- if (prop->live_value.timestamp < tv->timestamp) {
+ if (prop->live_value.timestamp < cp->timestamp) {
g_value_unset (&prop->live_value.value);
GST_DEBUG (" live value resetted");
} else if (prop->live_value.timestamp < timestamp) {
/* common helper */
/*
- * gst_controlled_property_find_timed_value_node:
+ * gst_controlled_property_find_control_point_node:
* @prop: the controlled property to search in
* @timestamp: the search key
*
- * Find last value before given timestamp in timed value list.
+ * Find last value before given timestamp in control point list.
*
* Returns: the found #GList node or %NULL
*/
GList *
-gst_controlled_property_find_timed_value_node (GstControlledProperty * prop,
+gst_controlled_property_find_control_point_node (GstControlledProperty * prop,
GstClockTime timestamp)
{
/* GList *prev_node = NULL; */
GList *prev_node = g_list_last (prop->values);
GList *node;
- GstTimedValue *tv;
+ GstControlPoint *cp;
/*
if((prop->last_value) &&
/* iterate over timed value list */
for (node = prop->values; node; node = g_list_next (node)) {
- tv = node->data;
+ cp = node->data;
/* this timestamp is newer that the one we look for */
- if (timestamp < tv->timestamp) {
+ if (timestamp < cp->timestamp) {
/* get previous one again */
prev_node = g_list_previous (node);
break;
{
GList *node;
- if ((node = gst_controlled_property_find_timed_value_node (prop, timestamp))) {
- GstTimedValue *tv = node->data;
+ if ((node =
+ gst_controlled_property_find_control_point_node (prop, timestamp))) {
+ GstControlPoint *cp = node->data;
- return (&tv->value);
+ return (&cp->value);
}
return (&prop->default_value);
}
interpolate_trigger_get (GstControlledProperty * prop, GstClockTime timestamp)
{
GList *node;
- GstTimedValue *tv;
+ GstControlPoint *cp;
/* check if there is a value at the registered timestamp */
for (node = prop->values; node; node = g_list_next (node)) {
- tv = node->data;
- if (timestamp == tv->timestamp) {
- return (&tv->value);
+ cp = node->data;
+ if (timestamp == cp->timestamp) {
+ return (&cp->value);
}
}
{ \
GList *node; \
\
- if ((node = gst_controlled_property_find_timed_value_node (prop, timestamp))) { \
- GstTimedValue *tv1, *tv2; \
+ if ((node = gst_controlled_property_find_control_point_node (prop, timestamp))) { \
+ GstControlPoint *cp1, *cp2; \
\
- tv1 = node->data; \
+ cp1 = node->data; \
if ((node = g_list_next (node))) { \
gdouble timediff,valuediff; \
g##type value1,value2; \
\
- tv2 = node->data; \
+ cp2 = node->data; \
\
- timediff = gst_guint64_to_gdouble (tv2->timestamp - tv1->timestamp); \
- value1 = g_value_get_##type (&tv1->value); \
- value2 = g_value_get_##type (&tv2->value); \
+ timediff = gst_guint64_to_gdouble (cp2->timestamp - cp1->timestamp); \
+ value1 = g_value_get_##type (&cp1->value); \
+ value2 = g_value_get_##type (&cp2->value); \
valuediff = (gdouble) (value2 - value1); \
\
- return ((g##type) (value1 + valuediff * (gst_guint64_to_gdouble (timestamp - tv1->timestamp) / timediff))); \
+ return ((g##type) (value1 + valuediff * (gst_guint64_to_gdouble (timestamp - cp1->timestamp) / timediff))); \
} \
else { \
- return (g_value_get_##type (&tv1->value)); \
+ return (g_value_get_##type (&cp1->value)); \
} \
} \
return (g_value_get_##type (&prop->default_value)); \