diff options
author | Harish Fulara <harish14143@iiitd.ac.in> | 2018-02-26 04:01:33 +0530 |
---|---|---|
committer | Thibault Saunier <tsaunier@igalia.com> | 2018-03-02 08:10:50 -0300 |
commit | e944739ca50a2ce5d690937bc21f18c687b2e187 (patch) | |
tree | 23f45352921bbc968064f0aea7627c368222b0a5 | |
parent | ccc5fe4619effd4d7284a2930dfe9b580c478751 (diff) |
Added paste functionality to GESTimeline class
https://bugzilla.gnome.org/show_bug.cgi?id=793820
-rw-r--r-- | ges/ges-internal.h | 1 | ||||
-rw-r--r-- | ges/ges-timeline-element.c | 9 | ||||
-rw-r--r-- | ges/ges-timeline.c | 56 | ||||
-rw-r--r-- | ges/ges-timeline.h | 3 |
4 files changed, 69 insertions, 0 deletions
diff --git a/ges/ges-internal.h b/ges/ges-internal.h index 3e627306..19da68d8 100644 --- a/ges/ges-internal.h +++ b/ges/ges-internal.h @@ -385,6 +385,7 @@ G_GNUC_INTERNAL GESVideoTestSource * ges_video_test_source_new (void); * GESTimelineElement * ****************************************************/ G_GNUC_INTERNAL gdouble ges_timeline_element_get_media_duration_factor(GESTimelineElement *self); +G_GNUC_INTERNAL GESTimelineElement * ges_timeline_element_get_copied_from (GESTimelineElement *self); /****************************** * GESMultiFile internal API * diff --git a/ges/ges-timeline-element.c b/ges/ges-timeline-element.c index 82ddad68..583b369f 100644 --- a/ges/ges-timeline-element.c +++ b/ges/ges-timeline-element.c @@ -1857,3 +1857,12 @@ ges_timeline_element_get_media_duration_factor (GESTimelineElement * self) g_type_class_unref (class); return media_duration_factor; } + +/* Internal */ +GESTimelineElement * +ges_timeline_element_get_copied_from (GESTimelineElement * self) +{ + GESTimelineElement *copied_from = self->priv->copied_from; + self->priv->copied_from = NULL; + return copied_from; +} diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 71f5247b..9febf1f2 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -3730,3 +3730,59 @@ ges_timeline_get_layer (GESTimeline * timeline, guint priority) return layer; } + +/** + * ges_timeline_paste_element: + * @timeline: The #GESTimeline onto which the #GESTimelineElement should be pasted + * @element: The #GESTimelineElement to paste + * @position: The position in the timeline the element should + * be pasted to, meaning it will become the start of @element + * @layer_priority: The #GESLayer to which the element should be pasted to. + * -1 means paste to the same layer from which the @element has been copied from. + * + * Paste @element inside the timeline. @element must have been + * created using ges_timeline_element_copy with deep=TRUE set, + * i.e. it must be a deep copy, otherwise it will fail. + * + * Returns: (transfer none): Shallow copy of the @element pasted + */ +GESTimelineElement * +ges_timeline_paste_element (GESTimeline * timeline, + GESTimelineElement * element, GstClockTime position, gint layer_priority) +{ + GESTimelineElement *res, *copied_from; + GESTimelineElementClass *element_class; + + g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE); + g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (element), FALSE); + + element_class = GES_TIMELINE_ELEMENT_GET_CLASS (element); + copied_from = ges_timeline_element_get_copied_from (element); + + if (!copied_from) { + GST_ERROR_OBJECT (element, "Is not being 'deeply' copied!"); + + return NULL; + } + + if (!element_class->paste) { + GST_ERROR_OBJECT (element, "No paste vmethod implemented"); + + return NULL; + } + + /* + * Currently the API only supports pasting onto the same layer from which + * the @element has been copied from, i.e., @layer_priority needs to be -1. + */ + if (layer_priority != -1) { + GST_WARNING_OBJECT (timeline, + "Only -1 value for layer priority is supported"); + } + + res = element_class->paste (element, copied_from, position); + + g_clear_object (&copied_from); + + return g_object_ref (res); +} diff --git a/ges/ges-timeline.h b/ges/ges-timeline.h index 1d0527a0..477a5e42 100644 --- a/ges/ges-timeline.h +++ b/ges/ges-timeline.h @@ -158,6 +158,9 @@ GST_EXPORT GESTimelineElement * ges_timeline_get_element (GESTimeline * timeline, const gchar *name); GST_EXPORT gboolean ges_timeline_is_empty (GESTimeline * timeline); +GST_EXPORT +GESTimelineElement * ges_timeline_paste_element (GESTimeline * timeline, + GESTimelineElement * element, GstClockTime position, gint layer_priority); G_END_DECLS |