static gfloat
interpolate_values_for_position (GstTimedValue * first_value,
- GstTimedValue * second_value, guint64 position)
+ GstTimedValue * second_value, guint64 position, gboolean absolute)
{
gfloat diff;
GstClockTime interval;
first_value->value - ((float) (first_value->timestamp -
position) / (float) interval) * diff;
- value_at_pos = CLAMP (value_at_pos, 0.0, 1.0);
+ if (!absolute)
+ value_at_pos = CLAMP (value_at_pos, 0.0, 1.0);
return value_at_pos;
}
for (n = 0; n < n_specs; ++n) {
GList *values, *tmp;
+ gboolean absolute;
GstTimedValue *last, *first, *prev = NULL, *next = NULL;
gfloat value_at_pos;
g_object_get (binding, "control_source", &source, NULL);
+ g_object_get (binding, "absolute", &absolute, NULL);
if (duration == 0) {
gst_timed_value_control_source_unset_all (GST_TIMED_VALUE_CONTROL_SOURCE
(source));
break;
}
- value_at_pos = interpolate_values_for_position (first, next, inpoint);
+ value_at_pos =
+ interpolate_values_for_position (first, next, inpoint, absolute);
gst_timed_value_control_source_unset (source, first->timestamp);
gst_timed_value_control_source_set (source, inpoint, value_at_pos);
}
value_at_pos =
- interpolate_values_for_position (prev, last, duration + inpoint);
+ interpolate_values_for_position (prev, last, duration + inpoint,
+ absolute);
gst_timed_value_control_source_unset (source, last->timestamp);
gst_timed_value_control_source_set (source, duration + inpoint,
for (n = 0; n < n_specs; ++n) {
GList *values, *tmp;
GstTimedValue *last_value = NULL;
- gboolean past_position = FALSE;
+ gboolean past_position = FALSE, absolute;
GstInterpolationMode mode;
binding = ges_track_element_get_control_binding (element, specs[n]->name);
if (!GST_IS_TIMED_VALUE_CONTROL_SOURCE (source))
continue;
+ g_object_get (binding, "absolute", &absolute, NULL);
+
new_source =
GST_TIMED_VALUE_CONTROL_SOURCE (gst_interpolation_control_source_new
());
* we are looking for is between two actual keyframes which is not enough
* in our case. bug #706621 */
value_at_pos =
- interpolate_values_for_position (last_value, value, position);
+ interpolate_values_for_position (last_value, value, position,
+ absolute);
past_position = TRUE;
last_value = value;
}
- /* We only manage direct bindings, see TODO in set_control_source */
- ges_track_element_set_control_source (new_element,
- GST_CONTROL_SOURCE (new_source), specs[n]->name, "direct");
+ /* We only manage direct (absolute) bindings, see TODO in set_control_source */
+ if (absolute)
+ ges_track_element_set_control_source (new_element,
+ GST_CONTROL_SOURCE (new_source), specs[n]->name, "direct-absolute");
+ else
+ ges_track_element_set_control_source (new_element,
+ GST_CONTROL_SOURCE (new_source), specs[n]->name, "direct");
}
g_free (specs);
GstElement *element;
GParamSpec *pspec;
GstControlBinding *binding;
+ gboolean direct, direct_absolute;
g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE);
priv = GES_TRACK_ELEMENT (object)->priv;
}
/* TODO : update this according to new types of bindings */
- if (!g_strcmp0 (binding_type, "direct")) {
+ direct = !g_strcmp0 (binding_type, "direct");
+ direct_absolute = !g_strcmp0 (binding_type, "direct-absolute");
+
+ if (direct || direct_absolute) {
/* First remove existing binding */
binding =
(GstControlBinding *) g_hash_table_lookup (priv->bindings_hashtable,
property_name);
gst_object_remove_control_binding (GST_OBJECT (element), binding);
}
- binding =
- gst_direct_control_binding_new (GST_OBJECT (element), property_name,
- source);
+
+ if (direct_absolute)
+ binding =
+ gst_direct_control_binding_new_absolute (GST_OBJECT (element),
+ property_name, source);
+ else
+ binding =
+ gst_direct_control_binding_new (GST_OBJECT (element), property_name,
+ source);
+
gst_object_add_control_binding (GST_OBJECT (element), binding);
g_hash_table_insert (priv->bindings_hashtable, g_strdup (property_name),
binding);
while (g_hash_table_iter_next (&iter, &key, &value)) {
if (GST_IS_DIRECT_CONTROL_BINDING ((GstControlBinding *) value)) {
GstControlSource *source;
+ gboolean absolute = FALSE;
GstDirectControlBinding *binding;
binding = (GstDirectControlBinding *) value;
- g_object_get (binding, "control-source", &source, NULL);
+ g_object_get (binding, "control-source", &source,
+ "absolute", &absolute, NULL);
if (GST_IS_INTERPOLATION_CONTROL_SOURCE (source)) {
GList *timed_values, *tmp;
append_escaped (str,
g_markup_printf_escaped
- (" <binding type='direct' source_type='interpolation' property='%s'",
- (gchar *) key));
+ (" <binding type='%s' source_type='interpolation' property='%s'",
+ absolute ? "direct-absolute" : "direct", (gchar *) key));
+
g_object_get (source, "mode", &mode, NULL);
append_escaped (str, g_markup_printf_escaped (" mode='%d'", mode));
append_escaped (str, g_markup_printf_escaped (" track_id='%d'", index));
} else
GST_DEBUG ("control source not in [interpolation]");
} else
- GST_DEBUG ("Binding type not in [direct]");
+ GST_DEBUG ("Binding type not in [direct, direct-absolute]");
}
}