From 15782c6ecd6589219eb693ca77d9eadc4283c9c1 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Mon, 26 Mar 2018 12:13:25 -0300 Subject: [PATCH] ges: Update the media-duration-factor each time a child property is set Otherwise the changes won't be reflected in the NLE backend. This makes speed changes working inside ges-launch-1.0 ges-launch-1.0 +clip /path/to/file i=10 d=5 +effect videorate set-rate 5.0 https://bugzilla.gnome.org/show_bug.cgi?id=794699 --- ges/ges-effect.c | 40 ++++++++++++++++++++++++++++++++------ ges/ges-timeline-element.c | 18 +++++++++++++++-- ges/ges-timeline-element.h | 4 +++- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/ges/ges-effect.c b/ges/ges-effect.c index c13b2cfadd..eb9c9e577f 100644 --- a/ges/ges-effect.c +++ b/ges/ges-effect.c @@ -114,6 +114,37 @@ ges_extractable_interface_init (GESExtractableInterface * iface) iface->get_id = extractable_get_id; } +static int +property_name_compare (gconstpointer s1, gconstpointer s2) +{ + return g_strcmp0 ((const gchar *) s1, (const gchar *) s2); +} + +static void +_set_child_property (GESTimelineElement * self G_GNUC_UNUSED, GObject * child, + GParamSpec * pspec, GValue * value) +{ + GESEffectClass *klass = GES_EFFECT_GET_CLASS (self); + gchar *full_property_name; + + GES_TIMELINE_ELEMENT_CLASS + (ges_effect_parent_class)->set_child_property (self, child, pspec, value); + + full_property_name = g_strdup_printf ("%s::%s", G_OBJECT_TYPE_NAME (child), + pspec->name); + + if (g_list_find_custom (klass->rate_properties, full_property_name, + property_name_compare)) { + GstElement *nleobject = + ges_track_element_get_nleobject (GES_TRACK_ELEMENT (self)); + gdouble media_duration_factor = + ges_timeline_element_get_media_duration_factor (self); + + g_object_set (nleobject, "media-duration-factor", media_duration_factor, + NULL); + } +} + static void ges_effect_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) @@ -149,9 +180,11 @@ ges_effect_class_init (GESEffectClass * klass) { GObjectClass *object_class; GESTrackElementClass *obj_bg_class; + GESTimelineElementClass *element_class; object_class = G_OBJECT_CLASS (klass); obj_bg_class = GES_TRACK_ELEMENT_CLASS (klass); + element_class = GES_TIMELINE_ELEMENT_CLASS (klass); g_type_class_add_private (klass, sizeof (GESEffectPrivate)); @@ -161,6 +194,7 @@ ges_effect_class_init (GESEffectClass * klass) object_class->finalize = ges_effect_finalize; obj_bg_class->create_element = ges_effect_create_element; + element_class->set_child_property = _set_child_property; klass->rate_properties = NULL; ges_effect_class_register_rate_property (klass, "scaletempo", "rate"); @@ -280,12 +314,6 @@ ges_effect_new (const gchar * bin_description) return effect; } -static int -property_name_compare (gconstpointer s1, gconstpointer s2) -{ - return g_strcmp0 ((const gchar *) s1, (const gchar *) s2); -} - /** * ges_effect_class_register_rate_property: * @klass: Instance of the GESEffectClass diff --git a/ges/ges-timeline-element.c b/ges/ges-timeline-element.c index 583b369f80..f68acdadbe 100644 --- a/ges/ges-timeline-element.c +++ b/ges/ges-timeline-element.c @@ -107,6 +107,13 @@ typedef struct GESTimelineElement *self; } EmitDeepNotifyInIdleData; +static void +_set_child_property (GESTimelineElement * self G_GNUC_UNUSED, GObject * child, + GParamSpec * pspec, GValue * value) +{ + g_object_set_property (child, pspec->name, value); +} + static gboolean _lookup_child (GESTimelineElement * self, const gchar * prop_name, GObject ** child, GParamSpec ** pspec) @@ -434,6 +441,7 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass) klass->list_children_properties = default_list_children_properties; klass->lookup_child = _lookup_child; + klass->set_child_property = _set_child_property; } static void @@ -1385,6 +1393,7 @@ ges_timeline_element_set_child_property_by_pspec (GESTimelineElement * self, GParamSpec * pspec, GValue * value) { ChildPropHandler *handler; + GESTimelineElementClass *klass; g_return_if_fail (GES_IS_TRACK_ELEMENT (self)); @@ -1393,7 +1402,9 @@ ges_timeline_element_set_child_property_by_pspec (GESTimelineElement * self, if (!handler) goto not_found; - g_object_set_property (handler->child, pspec->name, value); + klass = GES_TIMELINE_ELEMENT_GET_CLASS (self); + g_assert (klass->set_child_property); + klass->set_child_property (self, handler->child, pspec, value); return; @@ -1423,6 +1434,7 @@ ges_timeline_element_set_child_property (GESTimelineElement * self, const gchar * property_name, GValue * value) { GParamSpec *pspec; + GESTimelineElementClass *klass; GObject *child; g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), FALSE); @@ -1430,7 +1442,9 @@ ges_timeline_element_set_child_property (GESTimelineElement * self, if (!ges_timeline_element_lookup_child (self, property_name, &child, &pspec)) goto not_found; - g_object_set_property (child, pspec->name, value); + klass = GES_TIMELINE_ELEMENT_GET_CLASS (self); + g_assert (klass->set_child_property); + klass->set_child_property (self, child, pspec, value); gst_object_unref (child); g_param_spec_unref (pspec); diff --git a/ges/ges-timeline-element.h b/ges/ges-timeline-element.h index 7743948c46..d779434332 100644 --- a/ges/ges-timeline-element.h +++ b/ges/ges-timeline-element.h @@ -194,11 +194,13 @@ struct _GESTimelineElementClass GParamSpec** (*list_children_properties) (GESTimelineElement * self, guint *n_properties); gboolean (*lookup_child) (GESTimelineElement *self, const gchar *prop_name, GObject **child, GParamSpec **pspec); + void (*set_child_property) (GESTimelineElement * self, GObject *child, + GParamSpec *pspec, GValue *value); GESTrackType (*get_track_types) (GESTimelineElement * self); /*< private > */ /* Padding for API extension */ - gpointer _ges_reserved[GES_PADDING_LARGE - 2]; + gpointer _ges_reserved[GES_PADDING_LARGE - 3]; }; GES_API