From: Thibault Saunier Date: Wed, 1 May 2019 16:09:45 +0000 (-0400) Subject: ges: Move `ges_container_edit` to GESTimelineElement X-Git-Tag: 1.19.3~493^2~506 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ab26ab3066e65aeb28c95b06e2acd9c7a7b51c2;p=platform%2Fupstream%2Fgstreamer.git ges: Move `ges_container_edit` to GESTimelineElement Now that the notion of layer has been moved down to #GESTimelineElement (through the new #ges_timeline_element_get_layer_priority method), this method make much more sense directly in the base class. --- diff --git a/bindings/python/gi/overrides/GES.py b/bindings/python/gi/overrides/GES.py index be2d9bf981..631e931f9f 100644 --- a/bindings/python/gi/overrides/GES.py +++ b/bindings/python/gi/overrides/GES.py @@ -81,6 +81,12 @@ class TimelineElement(GES.TimelineElement): TimelineElement = override(TimelineElement) __all__.append('TimelineElement') +class Container(GES.Container): + def edit(self, layers, new_layer_priority, mode, edge, position): + return GES.TimelineElement.edit(self, layers, new_layer_priority, mode, edge, position) + +Container = override(Container) +__all__.append('Container') try: from gi.repository import Gst diff --git a/ges/ges-clip.c b/ges/ges-clip.c index 222fdf6a23..58ee0b8f83 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -615,50 +615,6 @@ done: } -static gboolean -_edit (GESContainer * container, GList * layers, - gint new_layer_priority, GESEditMode mode, GESEdge edge, guint64 position) -{ - GESTimeline *timeline = GES_TIMELINE_ELEMENT_TIMELINE (container); - GESTimelineElement *element = GES_TIMELINE_ELEMENT (container); - - if (!G_UNLIKELY (GES_CONTAINER_CHILDREN (container))) { - GST_WARNING_OBJECT (container, "Trying to edit, but not containing" - "any TrackElement yet."); - return FALSE; - } - - if (!timeline) { - GST_WARNING_OBJECT (container, "Trying to edit, but not in any" - "timeline."); - return FALSE; - } - - switch (mode) { - case GES_EDIT_MODE_RIPPLE: - return timeline_ripple_object (timeline, element, - new_layer_priority < - 0 ? GES_TIMELINE_ELEMENT_LAYER_PRIORITY (container) : - new_layer_priority, layers, edge, position); - case GES_EDIT_MODE_TRIM: - return timeline_trim_object (timeline, element, - new_layer_priority < - 0 ? GES_TIMELINE_ELEMENT_LAYER_PRIORITY (container) : - new_layer_priority, layers, edge, position); - case GES_EDIT_MODE_NORMAL: - return timeline_move_object (timeline, element, - new_layer_priority < - 0 ? GES_TIMELINE_ELEMENT_LAYER_PRIORITY (container) : - new_layer_priority, layers, edge, position); - case GES_EDIT_MODE_ROLL: - return timeline_roll_object (timeline, element, layers, edge, position); - case GES_EDIT_MODE_SLIDE: - GST_ERROR ("Sliding not implemented."); - return FALSE; - } - return FALSE; -} - static void _deep_copy (GESTimelineElement * element, GESTimelineElement * copy) { @@ -855,7 +811,6 @@ ges_clip_class_init (GESClipClass * klass) container_class->ungroup = _ungroup; container_class->group = _group; container_class->grouping_priority = G_MAXUINT; - container_class->edit = _edit; } static void diff --git a/ges/ges-container.c b/ges/ges-container.c index 07a5afa77a..a6b28cec76 100644 --- a/ges/ges-container.c +++ b/ges/ges-container.c @@ -1007,6 +1007,8 @@ ges_container_group (GList * containers) * * Returns: %TRUE if the container as been edited properly, %FALSE if an error * occured + * + * Deprecated: 1.18: use #ges_timeline_element_edit instead. */ gboolean ges_container_edit (GESContainer * container, GList * layers, @@ -1014,11 +1016,6 @@ ges_container_edit (GESContainer * container, GList * layers, { g_return_val_if_fail (GES_IS_CONTAINER (container), FALSE); - if (G_UNLIKELY (GES_CONTAINER_GET_CLASS (container)->edit == NULL)) { - GST_WARNING_OBJECT (container, "No edit vmethod implementation"); - return FALSE; - } - - return GES_CONTAINER_GET_CLASS (container)->edit (container, layers, - new_layer_priority, mode, edge, position); + return ges_timeline_element_edit (GES_TIMELINE_ELEMENT (container), + layers, new_layer_priority, mode, edge, position); } diff --git a/ges/ges-container.h b/ges/ges-container.h index 8b033668c2..5f40e20ec8 100644 --- a/ges/ges-container.h +++ b/ges/ges-container.h @@ -119,6 +119,8 @@ struct _GESContainerClass gboolean (*remove_child) (GESContainer *container, GESTimelineElement *element); GList* (*ungroup) (GESContainer *container, gboolean recursive); GESContainer * (*group) (GList *containers); + + /* Deprecated and not used anymore */ gboolean (*edit) (GESContainer * container, GList * layers, gint new_layer_priority, GESEditMode mode, diff --git a/ges/ges-timeline-element.c b/ges/ges-timeline-element.c index 39c65b726e..c3b4c1c52f 100644 --- a/ges/ges-timeline-element.c +++ b/ges/ges-timeline-element.c @@ -1942,3 +1942,56 @@ ges_timeline_element_set_flags (GESTimelineElement * self, self->priv->flags = flags; } + +/** + * ges_timeline_element_edit: + * @self: the #GESClip to edit + * @layers: (element-type GESLayer): The layers you want the edit to + * happen in, %NULL means that the edition is done in all the + * #GESLayers contained in the current timeline. + * @new_layer_priority: The priority of the layer @self should land in. + * If the layer you're trying to move the element to doesn't exist, it will + * be created automatically. -1 means no move. + * @mode: The #GESEditMode in which the editition will happen. + * @edge: The #GESEdge the edit should happen on. + * @position: The position at which to edit @self (in nanosecond) + * + * Edit @self in the different exisiting #GESEditMode modes. In the case of + * slide, and roll, you need to specify a #GESEdge + * + * Returns: %TRUE if @self as been edited properly, %FALSE if an error + * occured + */ +gboolean +ges_timeline_element_edit (GESTimelineElement * self, GList * layers, + gint64 new_layer_priority, GESEditMode mode, GESEdge edge, guint64 position) +{ + GESTimeline *timeline; + + g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), FALSE); + + timeline = GES_TIMELINE_ELEMENT_TIMELINE (self); + switch (mode) { + case GES_EDIT_MODE_RIPPLE: + return timeline_ripple_object (timeline, self, + new_layer_priority < + 0 ? GES_TIMELINE_ELEMENT_LAYER_PRIORITY (self) : + new_layer_priority, layers, edge, position); + case GES_EDIT_MODE_TRIM: + return timeline_trim_object (timeline, self, + new_layer_priority < + 0 ? GES_TIMELINE_ELEMENT_LAYER_PRIORITY (self) : + new_layer_priority, layers, edge, position); + case GES_EDIT_MODE_NORMAL: + return timeline_move_object (timeline, self, + new_layer_priority < + 0 ? GES_TIMELINE_ELEMENT_LAYER_PRIORITY (self) : + new_layer_priority, layers, edge, position); + case GES_EDIT_MODE_ROLL: + return timeline_roll_object (timeline, self, layers, edge, position); + case GES_EDIT_MODE_SLIDE: + GST_ERROR_OBJECT (self, "Sliding not implemented."); + return FALSE; + } + return FALSE; +} diff --git a/ges/ges-timeline-element.h b/ges/ges-timeline-element.h index 860b72b765..22cdc228d8 100644 --- a/ges/ges-timeline-element.h +++ b/ges/ges-timeline-element.h @@ -337,7 +337,15 @@ GES_API GESTrackType ges_timeline_element_get_track_types (GESTimelineElement * self); GES_API -guint32 ges_timeline_element_get_layer_priority (GESTimelineElement * self); +guint32 ges_timeline_element_get_layer_priority (GESTimelineElement * self); + +GES_API +gboolean ges_timeline_element_edit (GESTimelineElement * self, + GList * layers, + gint64 new_layer_priority, + GESEditMode mode, + GESEdge edge, + guint64 position); G_END_DECLS diff --git a/ges/ges-track-element.c b/ges/ges-track-element.c index d7006b3806..345639da55 100644 --- a/ges/ges-track-element.c +++ b/ges/ges-track-element.c @@ -1343,57 +1343,17 @@ ges_track_element_copy_bindings (GESTrackElement * element, * * Returns: %TRUE if the object as been edited properly, %FALSE if an error * occured + * + * Deprecated: 1.18: use #ges_timeline_element_edit instead. */ gboolean ges_track_element_edit (GESTrackElement * object, GList * layers, GESEditMode mode, GESEdge edge, guint64 position) { - GESTrack *track = ges_track_element_get_track (object); - GESTimeline *timeline; - g_return_val_if_fail (GES_IS_TRACK_ELEMENT (object), FALSE); - if (G_UNLIKELY (!track)) { - GST_WARNING_OBJECT (object, "Trying to edit in %d mode but not in " - "any Track yet.", mode); - return FALSE; - } - - timeline = GES_TIMELINE (ges_track_get_timeline (track)); - - if (G_UNLIKELY (!timeline)) { - GST_WARNING_OBJECT (object, "Trying to edit in %d mode but " - "track %p is not in any timeline yet.", mode, track); - return FALSE; - } - - switch (mode) { - case GES_EDIT_MODE_NORMAL: - return timeline_move_object (timeline, GES_TIMELINE_ELEMENT (object), -1, - layers, edge, position); - break; - case GES_EDIT_MODE_TRIM: - return timeline_trim_object (timeline, GES_TIMELINE_ELEMENT (object), -1, - layers, edge, position); - break; - case GES_EDIT_MODE_RIPPLE: - return timeline_ripple_object (timeline, GES_TIMELINE_ELEMENT (object), - GES_TIMELINE_ELEMENT_PRIORITY (object) / LAYER_HEIGHT, - layers, edge, position); - break; - case GES_EDIT_MODE_ROLL: - return timeline_roll_object (timeline, GES_TIMELINE_ELEMENT (object), - layers, edge, position); - break; - case GES_EDIT_MODE_SLIDE: - return timeline_slide_object (timeline, object, layers, edge, position); - break; - default: - GST_ERROR ("Unkown edit mode: %d", mode); - return FALSE; - } - - return TRUE; + return ges_timeline_element_edit (GES_TIMELINE_ELEMENT (object), + layers, -1, mode, edge, position); } /**