1 /* GStreamer Editing Services
2 * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
3 * 2009 Nokia Corporation
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * SECTION:ges-timeline
23 * @short_description: Multimedia timeline
25 * #GESTimeline is the central object for any multimedia timeline.
27 * Contains a list of #GESTimelineLayer which users should use to arrange the
28 * various timeline objects through time.
30 * The output type is determined by the #GESTrack that are set on
33 * To save/load a timeline, you can use the ges_timeline_load_from_uri() and
34 * ges_timeline_save_to_uri() methods to use the default format. If you wish
35 * to specify the format to save/load the timeline from, please consult the
36 * documentation about #GESFormatter.
39 #include "gesmarshal.h"
40 #include "ges-internal.h"
41 #include "ges-timeline.h"
42 #include "ges-track.h"
43 #include "ges-timeline-layer.h"
46 typedef struct _MoveContext MoveContext;
48 static inline void init_movecontext (MoveContext * mv_ctx);
50 G_DEFINE_TYPE (GESTimeline, ges_timeline, GST_TYPE_BIN);
52 #define GES_TIMELINE_PENDINGOBJS_GET_LOCK(timeline) \
53 (GES_TIMELINE(timeline)->priv->pendingobjects_lock)
54 #define GES_TIMELINE_PENDINGOBJS_LOCK(timeline) \
55 (g_mutex_lock(GES_TIMELINE_PENDINGOBJS_GET_LOCK (timeline)))
56 #define GES_TIMELINE_PENDINGOBJS_UNLOCK(timeline) \
57 (g_mutex_unlock(GES_TIMELINE_PENDINGOBJS_GET_LOCK (timeline)))
60 * The move context is used for the timeline editing modes functions in order to
61 * + Ripple / Roll / Slide / Move / Trim
63 * The context aims at avoiding to recalculate values/objects on each call of the
68 GESTimelineObject *obj;
72 /* Ripple and Roll Objects */
73 GList *moving_tckobjs;
75 /* We use it as a set of TimelineObject to move between layers */
76 GHashTable *moving_tlobjs;
77 /* Min priority of the objects currently in moving_tlobjs */
79 /* Max priority of the objects currently in moving_tlobjs */
82 /* Never trim so duration would becomes < 0 */
85 /* fields to force/avoid new context */
86 /* Set to %TRUE when the track is doing updates of track objects
87 * properties so we don't end up always needing new move context */
88 gboolean ignore_needs_ctx;
89 gboolean needs_move_ctx;
92 struct _GESTimelinePrivate
94 GList *layers; /* A list of GESTimelineLayer sorted by priority */
95 GList *tracks; /* A list of private track data */
97 /* The duration of the timeline */
100 /* discoverer used for virgin sources */
101 GstDiscoverer *discoverer;
102 GList *pendingobjects;
103 /* lock to avoid discovery of objects that will be removed */
104 GMutex *pendingobjects_lock;
106 /* Whether we are changing state asynchronously or not */
107 gboolean async_pending;
109 /* Timeline edition modes and snapping management */
110 guint64 snapping_distance;
112 /* FIXME: Should we offer an API over those fields ?
113 * FIXME: Should other classes than subclasses of TrackSource also
116 /* Snapping fields */
117 GHashTable *by_start; /* {TrackSource: start} */
118 GHashTable *by_end; /* {TrackSource: end} */
119 GHashTable *by_object; /* {timecode: TrackSource} */
120 GSequence *starts_ends; /* Sorted list of starts/ends */
121 /* We keep 1 reference to our trackobject here */
122 GSequence *tracksources; /* TrackSource-s sorted by start/priorities */
124 MoveContext movecontext;
127 /* private structure to contain our track-related information */
131 GESTimeline *timeline;
133 GstPad *pad; /* Pad from the track */
141 PROP_SNAPPING_DISTANCE,
145 static GParamSpec *properties[PROP_LAST];
158 static GstBinClass *parent_class;
160 static guint ges_timeline_signals[LAST_SIGNAL] = { 0 };
162 static gint custom_find_track (TrackPrivate * tr_priv, GESTrack * track);
163 static GstStateChangeReturn
164 ges_timeline_change_state (GstElement * element, GstStateChange transition);
166 discoverer_finished_cb (GstDiscoverer * discoverer, GESTimeline * timeline);
168 discoverer_discovered_cb (GstDiscoverer * discoverer,
169 GstDiscovererInfo * info, GError * err, GESTimeline * timeline);
171 /* GObject Standard vmethods*/
173 ges_timeline_get_property (GObject * object, guint property_id,
174 GValue * value, GParamSpec * pspec)
176 GESTimeline *timeline = GES_TIMELINE (object);
178 switch (property_id) {
180 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
182 g_value_set_uint64 (value, timeline->priv->duration);
184 case PROP_SNAPPING_DISTANCE:
185 g_value_set_uint64 (value, timeline->priv->snapping_distance);
191 ges_timeline_set_property (GObject * object, guint property_id,
192 const GValue * value, GParamSpec * pspec)
194 GESTimeline *timeline = GES_TIMELINE (object);
196 switch (property_id) {
197 case PROP_SNAPPING_DISTANCE:
198 timeline->priv->snapping_distance = g_value_get_uint64 (value);
201 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
206 ges_timeline_dispose (GObject * object)
208 GESTimelinePrivate *priv = GES_TIMELINE (object)->priv;
210 if (priv->discoverer) {
211 gst_discoverer_stop (priv->discoverer);
212 g_object_unref (priv->discoverer);
213 priv->discoverer = NULL;
216 while (priv->layers) {
217 GESTimelineLayer *layer = (GESTimelineLayer *) priv->layers->data;
218 ges_timeline_remove_layer (GES_TIMELINE (object), layer);
221 /* FIXME: it should be possible to remove tracks before removing
222 * layers, but at the moment this creates a problem because the track
223 * objects aren't notified that their gnlobjects have been destroyed.
226 while (priv->tracks) {
227 TrackPrivate *tr_priv = (TrackPrivate *) priv->tracks->data;
228 ges_timeline_remove_track (GES_TIMELINE (object), tr_priv->track);
231 g_hash_table_unref (priv->by_start);
232 g_hash_table_unref (priv->by_end);
233 g_hash_table_unref (priv->by_object);
234 g_sequence_free (priv->starts_ends);
235 g_sequence_free (priv->tracksources);
237 G_OBJECT_CLASS (ges_timeline_parent_class)->dispose (object);
241 ges_timeline_finalize (GObject * object)
243 GESTimeline *timeline = GES_TIMELINE (object);
245 g_mutex_free (timeline->priv->pendingobjects_lock);
247 G_OBJECT_CLASS (ges_timeline_parent_class)->finalize (object);
251 ges_timeline_class_init (GESTimelineClass * klass)
253 GObjectClass *object_class = G_OBJECT_CLASS (klass);
254 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
256 g_type_class_add_private (klass, sizeof (GESTimelinePrivate));
258 parent_class = g_type_class_peek_parent (klass);
260 element_class->change_state = ges_timeline_change_state;
262 object_class->get_property = ges_timeline_get_property;
263 object_class->set_property = ges_timeline_set_property;
264 object_class->dispose = ges_timeline_dispose;
265 object_class->finalize = ges_timeline_finalize;
268 * GESTimelineObject:duration
270 * Current duration (in nanoseconds) of the #GESTimeline
274 properties[PROP_DURATION] =
275 g_param_spec_uint64 ("duration", "Duration",
276 "The duration of the timeline", 0, G_MAXUINT64,
277 GST_CLOCK_TIME_NONE, G_PARAM_READABLE);
278 g_object_class_install_property (object_class, PROP_DURATION,
279 properties[PROP_DURATION]);
282 * GESTimeline:snapping-distance
284 * Distance (in nanoseconds) from which a moving object will snap
285 * with it neighboors. 0 means no snapping.
287 properties[PROP_SNAPPING_DISTANCE] =
288 g_param_spec_uint64 ("snapping-distance", "Snapping distance",
289 "Distance from which moving an object will snap with neighboors", 0,
290 G_MAXUINT64, 0, G_PARAM_READWRITE);
291 g_object_class_install_property (object_class, PROP_SNAPPING_DISTANCE,
292 properties[PROP_SNAPPING_DISTANCE]);
295 * GESTimeline::track-added
296 * @timeline: the #GESTimeline
297 * @track: the #GESTrack that was added to the timeline
299 * Will be emitted after the track was added to the timeline.
301 ges_timeline_signals[TRACK_ADDED] =
302 g_signal_new ("track-added", G_TYPE_FROM_CLASS (klass),
303 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_added), NULL,
304 NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TRACK);
307 * GESTimeline::track-removed
308 * @timeline: the #GESTimeline
309 * @track: the #GESTrack that was removed from the timeline
311 * Will be emitted after the track was removed from the timeline.
313 ges_timeline_signals[TRACK_REMOVED] =
314 g_signal_new ("track-removed", G_TYPE_FROM_CLASS (klass),
315 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_removed),
316 NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TRACK);
319 * GESTimeline::layer-added
320 * @timeline: the #GESTimeline
321 * @layer: the #GESTimelineLayer that was added to the timeline
323 * Will be emitted after the layer was added to the timeline.
325 ges_timeline_signals[LAYER_ADDED] =
326 g_signal_new ("layer-added", G_TYPE_FROM_CLASS (klass),
327 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_added), NULL,
328 NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TIMELINE_LAYER);
331 * GESTimeline::layer-removed
332 * @timeline: the #GESTimeline
333 * @layer: the #GESTimelineLayer that was removed from the timeline
335 * Will be emitted after the layer was removed from the timeline.
337 ges_timeline_signals[LAYER_REMOVED] =
338 g_signal_new ("layer-removed", G_TYPE_FROM_CLASS (klass),
339 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed),
340 NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
341 GES_TYPE_TIMELINE_LAYER);
344 * GESTimeline::discovery-error:
345 * @timeline: the #GESTimeline
346 * @formatter: the #GESFormatter
347 * @source: The #GESTimelineFileSource that could not be discovered properly
348 * @error: (type GLib.Error): #GError, which will be non-NULL if an error
349 * occurred during discovery
351 ges_timeline_signals[DISCOVERY_ERROR] =
352 g_signal_new ("discovery-error", G_TYPE_FROM_CLASS (klass),
353 G_SIGNAL_RUN_FIRST, 0, NULL, NULL, gst_marshal_VOID__OBJECT_BOXED,
354 G_TYPE_NONE, 2, GES_TYPE_TIMELINE_FILE_SOURCE, GST_TYPE_G_ERROR);
357 * GESTimeline::track-objects-snapping:
358 * @timeline: the #GESTimeline
359 * @obj1: the first #GESTrackObject that was snapping.
360 * @obj2: the second #GESTrackObject that was snapping.
361 * @position: the position where the two objects finally snapping.
363 * Will be emitted after two track objects snapped together.
367 ges_timeline_signals[OBJECT_SNAPPING] =
368 g_signal_new ("track-objects-snapping", G_TYPE_FROM_CLASS (klass),
369 G_SIGNAL_RUN_LAST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
370 G_TYPE_NONE, 3, GES_TYPE_TRACK_OBJECT, GES_TYPE_TRACK_OBJECT,
375 ges_timeline_init (GESTimeline * self)
377 GESTimelinePrivate *priv;
379 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
380 GES_TYPE_TIMELINE, GESTimelinePrivate);
386 priv->snapping_distance = 0;
388 /* Move context initialization */
389 init_movecontext (&self->priv->movecontext);
390 priv->movecontext.ignore_needs_ctx = FALSE;
392 priv->by_start = g_hash_table_new (g_direct_hash, g_direct_equal);
393 priv->by_end = g_hash_table_new (g_direct_hash, g_direct_equal);
394 priv->by_object = g_hash_table_new (g_direct_hash, g_direct_equal);
395 priv->starts_ends = g_sequence_new (g_free);
396 priv->tracksources = g_sequence_new (g_object_unref);
398 priv->pendingobjects_lock = g_mutex_new ();
399 /* New discoverer with a 15s timeout */
400 priv->discoverer = gst_discoverer_new (15 * GST_SECOND, NULL);
401 g_signal_connect (priv->discoverer, "finished",
402 G_CALLBACK (discoverer_finished_cb), self);
403 g_signal_connect (priv->discoverer, "discovered",
404 G_CALLBACK (discoverer_discovered_cb), self);
405 gst_discoverer_start (priv->discoverer);
408 /* Private methods */
412 sort_layers (gpointer a, gpointer b)
414 GESTimelineLayer *layer_a, *layer_b;
415 guint prio_a, prio_b;
417 layer_a = GES_TIMELINE_LAYER (a);
418 layer_b = GES_TIMELINE_LAYER (b);
420 prio_a = ges_timeline_layer_get_priority (layer_a);
421 prio_b = ges_timeline_layer_get_priority (layer_b);
423 if ((gint) prio_a > (guint) prio_b)
425 if ((guint) prio_a < (guint) prio_b)
432 objects_start_compare (GESTrackObject * a, GESTrackObject * b)
434 if (a->start == b->start) {
435 if (a->priority < b->priority)
437 if (a->priority > b->priority)
441 if (a->start < b->start)
443 if (a->start > b->start)
449 sort_track_objects (GESTimeline * timeline)
451 g_sequence_sort (timeline->priv->tracksources,
452 (GCompareDataFunc) objects_start_compare, NULL);
456 compare_uint64 (guint64 * a, guint64 * b, gpointer user_data)
467 custom_find_track (TrackPrivate * tr_priv, GESTrack * track)
469 if (tr_priv->track == track)
474 /* Look for the pointer passed as @value */
475 static GSequenceIter *
476 lookup_pointer_uint (GSequence * seq, guint64 * value)
478 GSequenceIter *iter, *tmpiter;
479 guint64 *found, *tmpval;
481 iter = g_sequence_lookup (seq, value,
482 (GCompareDataFunc) compare_uint64, NULL);
484 found = g_sequence_get (iter);
486 /* We have the same pointer so we are all fine */
490 if (!g_sequence_iter_is_end (iter)) {
491 /* Looking frontward for the good pointer */
493 while ((tmpiter = g_sequence_iter_next (tmpiter))) {
494 if (g_sequence_iter_is_end (tmpiter))
497 tmpval = g_sequence_get (tmpiter);
500 else if (*tmpval != *value)
505 if (!g_sequence_iter_is_begin (iter)) {
506 /* Looking backward for the good pointer */
508 while ((tmpiter = g_sequence_iter_prev (tmpiter))) {
509 tmpval = g_sequence_get (tmpiter);
512 else if (*tmpval != *value || g_sequence_iter_is_begin (tmpiter))
517 GST_ERROR ("Missing timecode %p %" GST_TIME_FORMAT
518 " this should never happen", value, GST_TIME_ARGS (*value));
524 sort_starts_ends_end (GESTimeline * timeline, GESTrackObject * obj)
528 GESTimelinePrivate *priv = timeline->priv;
529 guint64 *end = g_hash_table_lookup (priv->by_end, obj);
531 iter = lookup_pointer_uint (priv->starts_ends, end);
532 *end = obj->start + obj->duration;
534 g_sequence_sort_changed (iter, (GCompareDataFunc) compare_uint64, NULL);
538 sort_starts_ends_start (GESTimeline * timeline, GESTrackObject * obj)
542 GESTimelinePrivate *priv = timeline->priv;
543 guint64 *start = g_hash_table_lookup (priv->by_start, obj);
545 iter = lookup_pointer_uint (priv->starts_ends, start);
548 g_sequence_sort_changed (iter, (GCompareDataFunc) compare_uint64, NULL);
552 resort_all_starts_ends (GESTimeline * timeline)
555 GESTrackObject *tckobj;
556 guint64 *start, *end;
558 GESTimelinePrivate *priv = timeline->priv;
560 for (iter = g_sequence_get_begin_iter (priv->tracksources);
561 !g_sequence_iter_is_end (iter); iter = g_sequence_iter_next (iter)) {
562 tckobj = GES_TRACK_OBJECT (g_sequence_get (iter));
564 start = g_hash_table_lookup (priv->by_start, tckobj);
565 end = g_hash_table_lookup (priv->by_end, tckobj);
567 *start = tckobj->start;
568 *end = tckobj->start + tckobj->duration;
571 g_sequence_sort (priv->starts_ends, (GCompareDataFunc) compare_uint64, NULL);
575 sort_all (GESTimeline * timeline)
577 sort_track_objects (timeline);
578 resort_all_starts_ends (timeline);
581 /* Timeline edition functions */
583 init_movecontext (MoveContext * mv_ctx)
585 mv_ctx->moving_tckobjs = NULL;
586 mv_ctx->moving_tlobjs = g_hash_table_new (g_direct_hash, g_direct_equal);
587 mv_ctx->max_trim_pos = G_MAXUINT64;
588 mv_ctx->min_move_layer = G_MAXUINT;
589 mv_ctx->max_layer_prio = 0;
593 clean_movecontext (MoveContext * mv_ctx)
595 g_list_free (mv_ctx->moving_tckobjs);
596 g_hash_table_unref (mv_ctx->moving_tlobjs);
597 init_movecontext (mv_ctx);
601 stop_tracking_for_snapping (GESTimeline * timeline, GESTrackObject * tckobj)
603 guint64 *start, *end;
604 GESTimelinePrivate *priv = timeline->priv;
605 GSequenceIter *iter_start, *iter_end, *tckobj_iter;
608 start = g_hash_table_lookup (priv->by_start, tckobj);
609 end = g_hash_table_lookup (priv->by_end, tckobj);
611 iter_start = lookup_pointer_uint (priv->starts_ends, start);
612 iter_end = lookup_pointer_uint (priv->starts_ends, end);
613 tckobj_iter = g_sequence_lookup (timeline->priv->tracksources, tckobj,
614 (GCompareDataFunc) objects_start_compare, NULL);
616 g_hash_table_remove (priv->by_start, tckobj);
617 g_hash_table_remove (priv->by_end, tckobj);
618 g_hash_table_remove (priv->by_object, end);
619 g_hash_table_remove (priv->by_object, start);
621 g_sequence_remove (iter_start);
622 g_sequence_remove (iter_end);
623 g_sequence_remove (tckobj_iter);
628 start_tracking_track_obj (GESTimeline * timeline, GESTrackObject * tckobj)
630 guint64 *pstart, *pend;
631 GESTimelinePrivate *priv = timeline->priv;
633 pstart = g_malloc (sizeof (guint64));
634 pend = g_malloc (sizeof (guint64));
635 *pstart = tckobj->start;
636 *pend = *pstart + tckobj->duration;
638 g_sequence_insert_sorted (priv->starts_ends, pstart,
639 (GCompareDataFunc) compare_uint64, NULL);
640 g_sequence_insert_sorted (priv->starts_ends, pend,
641 (GCompareDataFunc) compare_uint64, NULL);
642 g_sequence_insert_sorted (priv->tracksources, g_object_ref (tckobj),
643 (GCompareDataFunc) objects_start_compare, NULL);
645 g_hash_table_insert (priv->by_start, tckobj, pstart);
646 g_hash_table_insert (priv->by_object, pstart, tckobj);
647 g_hash_table_insert (priv->by_end, tckobj, pend);
648 g_hash_table_insert (priv->by_object, pend, tckobj);
650 timeline->priv->movecontext.needs_move_ctx = TRUE;
654 ges_timeline_emit_snappig (GESTimeline * timeline, GESTrackObject * obj1,
657 GESTrackObject *obj2;
659 obj2 = g_hash_table_lookup (timeline->priv->by_object, timecode);
661 g_signal_emit (timeline, ges_timeline_signals[OBJECT_SNAPPING], 0,
662 obj1, obj2, *timecode);
664 /* We then need to recalculate the moving context */
665 timeline->priv->movecontext.needs_move_ctx = TRUE;
668 /* If passing @trackobj will emit the snapping signal, otherwize it won't */
670 ges_timeline_snap_position (GESTimeline * timeline, GESTrackObject * trackobj,
671 guint64 * current, guint64 timecode)
673 GESTimelinePrivate *priv = timeline->priv;
674 GSequenceIter *iter, *prev_iter, *nxt_iter;
675 GESTrackObject *tmp_tckobj;
676 GESTimelineObject *tmp_tlobj, *tlobj;
678 guint64 snap_distance = timeline->priv->snapping_distance;
680 guint64 *prev_tc, *next_tc, *ret = NULL, off = G_MAXUINT64, off1 =
683 /* Avoid useless calculations */
684 if (snap_distance == 0)
687 tlobj = ges_track_object_get_timeline_object (trackobj);
689 iter = g_sequence_search (priv->starts_ends, &timecode,
690 (GCompareDataFunc) compare_uint64, NULL);
692 /* Getting the next/previous values, and use the closest one if any "respects"
693 * the snap_distance value */
695 while (!g_sequence_iter_is_end (nxt_iter)) {
696 next_tc = g_sequence_get (iter);
697 tmp_tckobj = g_hash_table_lookup (timeline->priv->by_object, next_tc);
698 tmp_tlobj = ges_track_object_get_timeline_object (tmp_tckobj);
700 off = timecode > *next_tc ? timecode - *next_tc : *next_tc - timecode;
701 if (next_tc != current && off <= snap_distance && tlobj != tmp_tlobj) {
707 nxt_iter = g_sequence_iter_next (nxt_iter);
710 prev_iter = g_sequence_iter_prev (iter);
711 while (!g_sequence_iter_is_begin (prev_iter)) {
712 prev_tc = g_sequence_get (prev_iter);
713 tmp_tckobj = g_hash_table_lookup (timeline->priv->by_object, prev_tc);
714 tmp_tlobj = ges_track_object_get_timeline_object (tmp_tckobj);
716 off1 = timecode > *prev_tc ? timecode - *prev_tc : *prev_tc - timecode;
717 if (prev_tc != current && off1 < off && off1 <= snap_distance &&
718 tlobj != tmp_tlobj) {
724 prev_iter = g_sequence_iter_prev (prev_iter);
727 /* We emit the snapping signal only if we snapped with a different value
728 * than the current one */
730 ges_timeline_emit_snappig (timeline, trackobj, ret);
735 static inline GESTimelineObject *
736 add_moving_timeline_object (MoveContext * mv_ctx, GESTrackObject * tckobj)
738 GESTimelineObject *tlobj;
739 GESTimelineLayer *layer;
742 tlobj = ges_track_object_get_timeline_object (tckobj);
744 /* Avoid recalculating */
745 if (!g_hash_table_lookup (mv_ctx->moving_tlobjs, tlobj)) {
746 layer = ges_timeline_object_get_layer (tlobj);
748 GST_WARNING_OBJECT (tlobj, "Not in any layer, can not move"
753 g_hash_table_insert (mv_ctx->moving_tlobjs, tlobj, tlobj);
755 layer_prio = ges_timeline_layer_get_priority (layer);
756 mv_ctx->min_move_layer = MIN (mv_ctx->min_move_layer, layer_prio);
757 mv_ctx->max_layer_prio = MAX (mv_ctx->max_layer_prio, layer_prio);
759 g_object_unref (layer);
767 ges_move_context_set_objects (GESTimeline * timeline, GESTrackObject * obj,
770 GSequenceIter *iter, *tckobj_iter;
771 guint64 start, end, tmpend;
772 GESTrackObject *tmptckobj;
774 MoveContext *mv_ctx = &timeline->priv->movecontext;
776 tckobj_iter = g_sequence_lookup (timeline->priv->tracksources, obj,
777 (GCompareDataFunc) objects_start_compare, NULL);
781 /* set it properly int the context of "trimming" */
782 mv_ctx->max_trim_pos = 0;
785 if (g_sequence_iter_is_begin (tckobj_iter))
788 /* Look for the objects */
789 for (iter = g_sequence_iter_prev (tckobj_iter);
790 iter && !g_sequence_iter_is_end (iter);
791 iter = g_sequence_iter_prev (iter)) {
793 tmptckobj = GES_TRACK_OBJECT (g_sequence_get (iter));
794 tmpend = tmptckobj->start + tmptckobj->duration;
796 if (tmpend <= start) {
797 mv_ctx->max_trim_pos = MAX (mv_ctx->max_trim_pos, tmptckobj->start);
798 mv_ctx->moving_tckobjs =
799 g_list_prepend (mv_ctx->moving_tckobjs, tmptckobj);
802 if (g_sequence_iter_is_begin (iter))
808 case GES_EDGE_NONE: /* In this case only works for ripple */
809 end = ges_track_object_get_start (obj) +
810 ges_track_object_get_duration (obj);
812 mv_ctx->max_trim_pos = G_MAXUINT64;
814 /* Look for folowing objects */
815 for (iter = g_sequence_iter_next (tckobj_iter);
816 iter && !g_sequence_iter_is_end (iter);
817 iter = g_sequence_iter_next (iter)) {
818 tmptckobj = GES_TRACK_OBJECT (g_sequence_get (iter));
820 if (tmptckobj->start >= end) {
821 tmpend = tmptckobj->start + tmptckobj->duration;
822 mv_ctx->max_trim_pos = MIN (mv_ctx->max_trim_pos, tmpend);
823 mv_ctx->moving_tckobjs =
824 g_list_prepend (mv_ctx->moving_tckobjs, tmptckobj);
829 GST_DEBUG ("Edge type %d no supported", edge);
837 ges_timeline_set_moving_context (GESTimeline * timeline, GESTrackObject * obj,
838 GESEditMode mode, GESEdge edge, GList * layers)
840 MoveContext *mv_ctx = &timeline->priv->movecontext;
841 GESTimelineObject *tlobj = ges_track_object_get_timeline_object (obj);
843 /* Still in the same mv_ctx */
844 if ((mv_ctx->obj == tlobj && mv_ctx->mode == mode &&
845 mv_ctx->edge == edge && !mv_ctx->needs_move_ctx)) {
847 GST_DEBUG ("Keeping the same moving mv_ctx");
851 GST_DEBUG_OBJECT (tlobj,
852 "Changing context:\nold: obj: %p, mode: %d, edge: %d \n"
853 "new: obj: %p, mode: %d, edge: %d ! Has changed %i", mv_ctx->obj,
854 mv_ctx->mode, mv_ctx->edge, tlobj, mode, edge, mv_ctx->needs_move_ctx);
856 clean_movecontext (mv_ctx);
860 mv_ctx->needs_move_ctx = FALSE;
863 case GES_EDIT_MODE_RIPPLE:
864 case GES_EDIT_MODE_ROLL:
865 if (!(ges_move_context_set_objects (timeline, obj, edge)))
871 /* And we add the main object to the moving_tlobjs set */
872 add_moving_timeline_object (&timeline->priv->movecontext, obj);
879 ges_timeline_trim_object_simple (GESTimeline * timeline, GESTrackObject * obj,
880 GList * layers, GESEdge edge, guint64 position, gboolean snapping)
882 guint64 nstart, start, inpoint, duration, max_duration, *snapped, *cur;
886 GST_DEBUG_OBJECT (obj, "Trimming to %" GST_TIME_FORMAT " %s snaping, edge %i",
887 GST_TIME_ARGS (position), snapping ? "Is" : "Not", edge);
889 start = ges_track_object_get_start (obj);
890 g_object_get (obj, "max-duration", &max_duration, NULL);
894 inpoint = obj->inpoint;
895 duration = obj->duration;
898 cur = g_hash_table_lookup (timeline->priv->by_start, obj);
900 snapped = ges_timeline_snap_position (timeline, obj, cur, position);
907 /* Calculate new values */
908 position = MAX (start > inpoint ? start - inpoint : 0, position);
909 position = MIN (position, start + duration);
910 inpoint = MAX (0, inpoint + position - start);
912 real_dur = start + duration - nstart;
913 /* FIXME: Why CLAMP (0, real_dur, max_duration) doesn't work? */
914 duration = MAX (0, real_dur);
915 duration = MIN (duration, max_duration - obj->inpoint);
917 ges_track_object_set_start (obj, nstart);
918 ges_track_object_set_duration (obj, duration);
919 ges_track_object_set_inpoint (obj, inpoint);
923 cur = g_hash_table_lookup (timeline->priv->by_end, obj);
924 snapped = ges_timeline_snap_position (timeline, obj, cur, position);
928 /* Calculate new values */
929 real_dur = position - start;
930 duration = MAX (0, real_dur);
931 duration = MIN (duration, max_duration - obj->inpoint);
933 ges_track_object_set_duration (obj, duration);
937 GST_WARNING ("Can not trim with %i GESEdge", edge);
945 timeline_ripple_object (GESTimeline * timeline, GESTrackObject * obj,
946 GList * layers, GESEdge edge, guint64 position)
948 GList *tmp, *moved_tlobjs = NULL;
949 GESTrackObject *tckobj;
950 GESTimelineObject *tlobj;
951 guint64 duration, new_start, *snapped, *cur;
954 MoveContext *mv_ctx = &timeline->priv->movecontext;
956 mv_ctx->ignore_needs_ctx = TRUE;
958 if (!ges_timeline_set_moving_context (timeline, obj, GES_EDIT_MODE_RIPPLE,
964 GST_DEBUG ("Simply rippling");
966 cur = g_hash_table_lookup (timeline->priv->by_end, obj);
967 snapped = ges_timeline_snap_position (timeline, obj, cur, position);
971 offset = position - obj->start;
973 for (tmp = mv_ctx->moving_tckobjs; tmp; tmp = tmp->next) {
974 tckobj = GES_TRACK_OBJECT (tmp->data);
975 new_start = tckobj->start + offset;
977 tlobj = add_moving_timeline_object (mv_ctx, tckobj);
979 if (ges_track_object_is_locked (tckobj) == TRUE) {
981 /* Make sure not to move 2 times the same TimelineObject */
982 if (g_list_find (moved_tlobjs, tlobj) == NULL) {
983 ges_track_object_set_start (tckobj, new_start);
984 moved_tlobjs = g_list_prepend (moved_tlobjs, tlobj);
988 ges_track_object_set_start (tckobj, new_start);
991 g_list_free (moved_tlobjs);
992 ges_track_object_set_start (obj, position);
996 GST_DEBUG ("Rippling end");
998 cur = g_hash_table_lookup (timeline->priv->by_end, obj);
999 snapped = ges_timeline_snap_position (timeline, obj, cur, position);
1001 position = *snapped;
1003 duration = obj->duration;
1005 ges_track_object_set_duration (obj, position - obj->start);
1007 offset = obj->duration - duration;
1008 for (tmp = mv_ctx->moving_tckobjs; tmp; tmp = tmp->next) {
1009 tckobj = GES_TRACK_OBJECT (tmp->data);
1010 new_start = tckobj->start + offset;
1012 tlobj = add_moving_timeline_object (mv_ctx, tckobj);
1014 if (ges_track_object_is_locked (tckobj) == TRUE) {
1016 /* Make sure not to move 2 times the same TimelineObject */
1017 if (g_list_find (moved_tlobjs, tlobj) == NULL) {
1018 ges_track_object_set_start (tckobj, new_start);
1019 moved_tlobjs = g_list_prepend (moved_tlobjs, tlobj);
1023 ges_track_object_set_start (tckobj, new_start);
1027 g_list_free (moved_tlobjs);
1028 GST_DEBUG ("Done Rippling end");
1030 case GES_EDGE_START:
1031 GST_WARNING ("Ripple start doesn't exist!");
1035 GST_DEBUG ("Can not ripple edge: %i", edge);
1040 mv_ctx->ignore_needs_ctx = FALSE;
1045 mv_ctx->ignore_needs_ctx = FALSE;
1051 timeline_slide_object (GESTimeline * timeline, GESTrackObject * obj,
1052 GList * layers, GESEdge edge, guint64 position)
1055 /* FIXME implement me! */
1056 GST_WARNING ("Slide mode editing not implemented yet");
1062 timeline_trim_object (GESTimeline * timeline, GESTrackObject * object,
1063 GList * layers, GESEdge edge, guint64 position)
1065 gboolean ret = FALSE;
1066 MoveContext *mv_ctx = &timeline->priv->movecontext;
1068 mv_ctx->ignore_needs_ctx = TRUE;
1070 if (!ges_timeline_set_moving_context (timeline, object, GES_EDIT_MODE_TRIM,
1075 ges_timeline_trim_object_simple (timeline, object, layers, edge, position,
1079 mv_ctx->ignore_needs_ctx = FALSE;
1085 timeline_roll_object (GESTimeline * timeline, GESTrackObject * obj,
1086 GList * layers, GESEdge edge, guint64 position)
1088 MoveContext *mv_ctx = &timeline->priv->movecontext;
1089 guint64 start, duration, end, tmpstart, tmpduration, tmpend, *snapped, *cur;
1090 gboolean ret = TRUE;
1093 mv_ctx->ignore_needs_ctx = TRUE;
1095 GST_DEBUG_OBJECT (obj, "Rolling object to %" GST_TIME_FORMAT,
1096 GST_TIME_ARGS (position));
1098 if (!ges_timeline_set_moving_context (timeline, obj, GES_EDIT_MODE_ROLL,
1102 start = ges_track_object_get_start (obj);
1103 duration = ges_track_object_get_duration (obj);
1104 end = start + duration;
1107 case GES_EDGE_START:
1109 /* Avoid negative durations */
1110 if (position < mv_ctx->max_trim_pos || position > end)
1113 cur = g_hash_table_lookup (timeline->priv->by_start, obj);
1114 snapped = ges_timeline_snap_position (timeline, obj, cur, position);
1116 position = *snapped;
1119 ges_timeline_trim_object_simple (timeline, obj, layers,
1120 GES_EDGE_START, position, FALSE);
1122 /* In the case we reached max_duration we just make sure to roll
1123 * everything to the real new position */
1124 position = obj->start;
1126 /* Send back changes to the neighbourhood */
1127 for (tmp = mv_ctx->moving_tckobjs; tmp; tmp = tmp->next) {
1128 GESTrackObject *tmptckobj = GES_TRACK_OBJECT (tmp->data);
1130 tmpstart = ges_track_object_get_start (tmptckobj);
1131 tmpduration = ges_track_object_get_duration (tmptckobj);
1132 tmpend = tmpstart + tmpduration;
1134 /* Check that the object should be resized at this position
1135 * even if an error accurs, we keep doing our job */
1136 if (tmpend == start) {
1137 ret &= ges_timeline_trim_object_simple (timeline, tmptckobj, NULL,
1138 GES_EDGE_END, position, FALSE);
1145 /* Avoid negative durations */
1146 if (position > mv_ctx->max_trim_pos || position < start)
1149 end = obj->start + obj->duration;
1151 cur = g_hash_table_lookup (timeline->priv->by_end, obj);
1152 snapped = ges_timeline_snap_position (timeline, obj, cur, position);
1154 position = *snapped;
1156 ret &= ges_timeline_trim_object_simple (timeline, obj, NULL, GES_EDGE_END,
1159 /* In the case we reached max_duration we just make sure to roll
1160 * everything to the real new position */
1161 position = obj->start + obj->duration;
1163 /* Send back changes to the neighbourhood */
1164 for (tmp = mv_ctx->moving_tckobjs; tmp; tmp = tmp->next) {
1165 GESTrackObject *tmptckobj = GES_TRACK_OBJECT (tmp->data);
1167 tmpstart = ges_track_object_get_start (tmptckobj);
1168 tmpduration = ges_track_object_get_duration (tmptckobj);
1169 tmpend = tmpstart + tmpduration;
1171 /* Check that the object should be resized at this position
1172 * even if an error accure, we keep doing our job */
1173 if (end == tmpstart) {
1174 ret &= ges_timeline_trim_object_simple (timeline, tmptckobj, NULL,
1175 GES_EDGE_START, position, FALSE);
1180 GST_DEBUG ("Edge type %i not handled here", edge);
1184 mv_ctx->ignore_needs_ctx = FALSE;
1189 mv_ctx->ignore_needs_ctx = FALSE;
1191 GST_DEBUG_OBJECT (obj, "Could not roll edge %d to %" GST_TIME_FORMAT,
1192 edge, GST_TIME_ARGS (position));
1198 timeline_move_object (GESTimeline * timeline, GESTrackObject * object,
1199 GList * layers, GESEdge edge, guint64 position)
1201 if (!ges_timeline_set_moving_context (timeline, object, GES_EDIT_MODE_RIPPLE,
1203 GST_DEBUG_OBJECT (object, "Could not move to %" GST_TIME_FORMAT,
1204 GST_TIME_ARGS (position));
1209 return ges_timeline_move_object_simple (timeline, object, layers, edge,
1214 ges_timeline_move_object_simple (GESTimeline * timeline,
1215 GESTrackObject * object, GList * layers, GESEdge edge, guint64 position)
1217 guint64 *snap_end, *snap_st, *cur, off1, off2, end;
1219 end = position + object->duration;
1220 cur = g_hash_table_lookup (timeline->priv->by_end, object);
1221 snap_end = ges_timeline_snap_position (timeline, object, cur, end);
1223 off1 = end > *snap_end ? end - *snap_end : *snap_end - end;
1227 cur = g_hash_table_lookup (timeline->priv->by_start, object);
1228 snap_st = ges_timeline_snap_position (timeline, object, cur, position);
1230 off2 = position > *snap_st ? position - *snap_st : *snap_st - position;
1234 if (snap_end && off1 <= off2) {
1235 position = position + *snap_end - end;
1236 ges_timeline_emit_snappig (timeline, object, snap_end);
1237 } else if (snap_st) {
1238 position = position + *snap_st - position;
1239 ges_timeline_emit_snappig (timeline, object, snap_st);
1243 ges_track_object_set_start (object, position);
1249 timeline_context_to_layer (GESTimeline * timeline, gint offset)
1251 gboolean ret = TRUE;
1252 MoveContext *mv_ctx = &timeline->priv->movecontext;
1256 /* Layer's priority is always positive */
1257 if (offset != 0 && (offset > 0 || mv_ctx->min_move_layer >= -offset)) {
1258 GHashTableIter iter;
1259 GESTimelineObject *key, *value;
1260 GESTimelineLayer *new_layer, *layer;
1263 mv_ctx->ignore_needs_ctx = TRUE;
1265 GST_DEBUG ("Moving %d object, offset %d",
1266 g_hash_table_size (mv_ctx->moving_tlobjs), offset);
1268 g_hash_table_iter_init (&iter, mv_ctx->moving_tlobjs);
1269 while (g_hash_table_iter_next (&iter, (gpointer *) & key,
1270 (gpointer *) & value)) {
1271 layer = ges_timeline_object_get_layer (value);
1272 prio = ges_timeline_layer_get_priority (layer);
1274 /* We know that the layer exists as we created it */
1275 new_layer = GES_TIMELINE_LAYER (g_list_nth_data (timeline->priv->layers,
1278 if (new_layer == NULL) {
1280 new_layer = ges_timeline_append_layer (timeline);
1281 } while (ges_timeline_layer_get_priority (new_layer) < prio + offset);
1284 ret &= ges_timeline_object_move_to_layer (key, new_layer);
1286 g_object_unref (layer);
1289 /* Readjust min_move_layer */
1290 mv_ctx->min_move_layer = mv_ctx->min_move_layer + offset;
1292 mv_ctx->ignore_needs_ctx = FALSE;
1299 add_object_to_track (GESTimelineObject * object, GESTrack * track)
1301 if (!ges_timeline_object_create_track_objects (object, track)) {
1302 if ((track->type & ges_timeline_object_get_supported_formats (object))) {
1303 GST_WARNING ("Error creating track objects");
1309 add_object_to_tracks (GESTimeline * timeline, GESTimelineObject * object)
1313 for (tmp = timeline->priv->tracks; tmp; tmp = g_list_next (tmp)) {
1314 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
1315 GESTrack *track = tr_priv->track;
1317 GST_LOG ("Trying with track %p", track);
1318 add_object_to_track (object, track);
1323 do_async_start (GESTimeline * timeline)
1325 GstMessage *message;
1328 timeline->priv->async_pending = TRUE;
1330 /* Freeze state of tracks */
1331 for (tmp = timeline->priv->tracks; tmp; tmp = tmp->next) {
1332 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
1333 gst_element_set_locked_state ((GstElement *) tr_priv->track, TRUE);
1336 message = gst_message_new_async_start (GST_OBJECT_CAST (timeline), FALSE);
1337 parent_class->handle_message (GST_BIN_CAST (timeline), message);
1341 do_async_done (GESTimeline * timeline)
1343 GstMessage *message;
1345 if (timeline->priv->async_pending) {
1347 /* Unfreeze state of tracks */
1348 for (tmp = timeline->priv->tracks; tmp; tmp = tmp->next) {
1349 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
1350 gst_element_set_locked_state ((GstElement *) tr_priv->track, FALSE);
1351 gst_element_sync_state_with_parent ((GstElement *) tr_priv->track);
1354 GST_DEBUG_OBJECT (timeline, "Emitting async-done");
1355 message = gst_message_new_async_done (GST_OBJECT_CAST (timeline));
1356 parent_class->handle_message (GST_BIN_CAST (timeline), message);
1358 timeline->priv->async_pending = FALSE;
1364 discoverer_finished_cb (GstDiscoverer * discoverer, GESTimeline * timeline)
1366 do_async_done (timeline);
1370 discoverer_discovered_cb (GstDiscoverer * discoverer,
1371 GstDiscovererInfo * info, GError * err, GESTimeline * timeline)
1375 GESTrackType tfs_supportedformats;
1377 gboolean found = FALSE;
1378 gboolean is_image = FALSE;
1379 GESTimelineFileSource *tfs = NULL;
1380 GESTimelinePrivate *priv = timeline->priv;
1381 const gchar *uri = gst_discoverer_info_get_uri (info);
1383 GES_TIMELINE_PENDINGOBJS_LOCK (timeline);
1385 /* Find corresponding TimelineFileSource in the sources */
1386 for (tmp = priv->pendingobjects; tmp; tmp = tmp->next) {
1387 tfs = (GESTimelineFileSource *) tmp->data;
1389 if (!g_strcmp0 (ges_timeline_filesource_get_uri (tfs), uri)) {
1396 GST_WARNING ("Discovered %s, that seems not to be in the list of sources"
1397 "to discover", uri);
1398 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1403 GError *propagate_error = NULL;
1405 priv->pendingobjects = g_list_delete_link (priv->pendingobjects, tmp);
1406 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1407 GST_WARNING ("Error while discovering %s: %s", uri, err->message);
1409 g_propagate_error (&propagate_error, err);
1410 g_signal_emit (timeline, ges_timeline_signals[DISCOVERY_ERROR], 0, tfs,
1416 /* Everything went fine... let's do our job! */
1417 GST_DEBUG ("Discovered uri %s", uri);
1419 /* The timeline file source will be updated with discovered information
1420 * so it needs to not be finalized during this process */
1423 /* Remove object from list */
1424 priv->pendingobjects = g_list_delete_link (priv->pendingobjects, tmp);
1425 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1427 /* FIXME : Handle errors in discovery */
1428 stream_list = gst_discoverer_info_get_stream_list (info);
1430 tfs_supportedformats = ges_timeline_filesource_get_supported_formats (tfs);
1431 if (tfs_supportedformats != GES_TRACK_TYPE_UNKNOWN)
1434 /* Update timelinefilesource properties based on info */
1435 for (tmp = stream_list; tmp; tmp = tmp->next) {
1436 GstDiscovererStreamInfo *sinf = (GstDiscovererStreamInfo *) tmp->data;
1438 if (GST_IS_DISCOVERER_AUDIO_INFO (sinf)) {
1439 tfs_supportedformats |= GES_TRACK_TYPE_AUDIO;
1440 ges_timeline_filesource_set_supported_formats (tfs, tfs_supportedformats);
1441 } else if (GST_IS_DISCOVERER_VIDEO_INFO (sinf)) {
1442 tfs_supportedformats |= GES_TRACK_TYPE_VIDEO;
1443 ges_timeline_filesource_set_supported_formats (tfs, tfs_supportedformats);
1444 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
1446 tfs_supportedformats |= GES_TRACK_TYPE_AUDIO;
1447 ges_timeline_filesource_set_supported_formats (tfs,
1448 tfs_supportedformats);
1455 gst_discoverer_stream_info_list_free (stream_list);
1460 /* don't set max-duration on still images */
1461 g_object_set (tfs, "is_image", (gboolean) TRUE, NULL);
1464 /* Continue the processing on tfs */
1465 add_object_to_tracks (timeline, GES_TIMELINE_OBJECT (tfs));
1468 g_object_set (tfs, "max-duration",
1469 gst_discoverer_info_get_duration (info), NULL);
1472 /* Remove the ref as the timeline file source is no longer needed here */
1473 g_object_unref (tfs);
1477 layer_object_added_cb (GESTimelineLayer * layer, GESTimelineObject * object,
1478 GESTimeline * timeline)
1480 if (ges_timeline_object_is_moving_from_layer (object)) {
1481 GST_DEBUG ("TimelineObject %p is moving from a layer to another, not doing"
1482 " anything on it", object);
1483 if (!timeline->priv->movecontext.ignore_needs_ctx)
1484 timeline->priv->movecontext.needs_move_ctx = TRUE;
1488 GST_DEBUG ("New TimelineObject %p added to layer %p", object, layer);
1490 if (GES_IS_TIMELINE_FILE_SOURCE (object)) {
1491 GESTimelineFileSource *tfs = GES_TIMELINE_FILE_SOURCE (object);
1492 GESTrackType tfs_supportedformats =
1493 ges_timeline_filesource_get_supported_formats (tfs);
1494 guint64 tfs_maxdur = ges_timeline_filesource_get_max_duration (tfs);
1495 const gchar *tfs_uri;
1497 /* Send the filesource to the discoverer if:
1498 * * it doesn't have specified supported formats
1499 * * OR it doesn't have a specified max-duration
1500 * * OR it doesn't have a valid duration */
1502 if (tfs_supportedformats == GES_TRACK_TYPE_UNKNOWN ||
1503 tfs_maxdur == GST_CLOCK_TIME_NONE || object->duration == 0) {
1504 GST_LOG ("Incomplete TimelineFileSource, discovering it");
1505 tfs_uri = ges_timeline_filesource_get_uri (tfs);
1507 GES_TIMELINE_PENDINGOBJS_LOCK (timeline);
1508 timeline->priv->pendingobjects =
1509 g_list_append (timeline->priv->pendingobjects, object);
1510 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1512 gst_discoverer_discover_uri_async (timeline->priv->discoverer, tfs_uri);
1514 add_object_to_tracks (timeline, object);
1516 add_object_to_tracks (timeline, object);
1523 layer_priority_changed_cb (GESTimelineLayer * layer,
1524 GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
1526 timeline->priv->layers = g_list_sort (timeline->priv->layers, (GCompareFunc)
1531 layer_object_removed_cb (GESTimelineLayer * layer, GESTimelineObject * object,
1532 GESTimeline * timeline)
1534 GList *trackobjects, *tmp;
1536 if (ges_timeline_object_is_moving_from_layer (object)) {
1537 GST_DEBUG ("TimelineObject %p is moving from a layer to another, not doing"
1538 " anything on it", object);
1542 GST_DEBUG ("TimelineObject %p removed from layer %p", object, layer);
1544 /* Go over the object's track objects and figure out which one belongs to
1545 * the list of tracks we control */
1547 trackobjects = ges_timeline_object_get_track_objects (object);
1548 for (tmp = trackobjects; tmp; tmp = tmp->next) {
1549 GESTrackObject *trobj = (GESTrackObject *) tmp->data;
1551 GST_DEBUG ("Trying to remove TrackObject %p", trobj);
1552 if (G_LIKELY (g_list_find_custom (timeline->priv->tracks,
1553 ges_track_object_get_track (trobj),
1554 (GCompareFunc) custom_find_track))) {
1555 GST_DEBUG ("Belongs to one of the tracks we control");
1556 ges_track_remove_object (ges_track_object_get_track (trobj), trobj);
1558 ges_timeline_object_release_track_object (object, trobj);
1560 /* removing the reference added by _get_track_objects() */
1561 g_object_unref (trobj);
1564 g_list_free (trackobjects);
1566 /* if the object is a timeline file source that has not yet been discovered,
1567 * it no longer needs to be discovered so remove it from the pendingobjects
1568 * list if it belongs to this layer */
1569 if (GES_IS_TIMELINE_FILE_SOURCE (object)) {
1570 GES_TIMELINE_PENDINGOBJS_LOCK (timeline);
1571 timeline->priv->pendingobjects =
1572 g_list_remove_all (timeline->priv->pendingobjects, object);
1573 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1580 trackobj_start_changed_cb (GESTrackObject * child,
1581 GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
1583 sort_track_objects (timeline);
1584 sort_starts_ends_start (timeline, child);
1585 sort_starts_ends_end (timeline, child);
1587 if (!timeline->priv->movecontext.ignore_needs_ctx)
1588 timeline->priv->movecontext.needs_move_ctx = TRUE;
1592 trackobj_duration_changed_cb (GESTrackObject * child,
1593 GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
1595 sort_starts_ends_end (timeline, child);
1597 if (!timeline->priv->movecontext.ignore_needs_ctx)
1598 timeline->priv->movecontext.needs_move_ctx = TRUE;
1602 trackobj_inpoint_changed_cb (GESTrackObject * child,
1603 GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
1605 if (!timeline->priv->movecontext.ignore_needs_ctx)
1606 timeline->priv->movecontext.needs_move_ctx = TRUE;
1610 track_object_added_cb (GESTrack * track, GESTrackObject * object,
1611 GESTimeline * timeline)
1613 /* We only work with sources */
1614 if (GES_IS_TRACK_SOURCE (object)) {
1615 start_tracking_track_obj (timeline, object);
1617 g_signal_connect (GES_TRACK_OBJECT (object), "notify::start",
1618 G_CALLBACK (trackobj_start_changed_cb), timeline);
1619 g_signal_connect (GES_TRACK_OBJECT (object), "notify::duration",
1620 G_CALLBACK (trackobj_duration_changed_cb), timeline);
1621 g_signal_connect (GES_TRACK_OBJECT (object), "notify::in-point",
1622 G_CALLBACK (trackobj_inpoint_changed_cb), timeline);
1627 track_object_removed_cb (GESTrack * track, GESTrackObject * object,
1628 GESTimeline * timeline)
1630 /* We only work with sources */
1631 if (GES_IS_TRACK_SOURCE (object)) {
1632 g_signal_handlers_disconnect_by_func (object, trackobj_start_changed_cb,
1634 g_signal_handlers_disconnect_by_func (object, trackobj_duration_changed_cb,
1636 g_signal_handlers_disconnect_by_func (object, trackobj_inpoint_changed_cb,
1639 /* Make sure to reinitialise the moving context next time */
1640 timeline->priv->movecontext.needs_move_ctx = TRUE;
1641 stop_tracking_for_snapping (timeline, object);
1646 track_duration_cb (GstElement * track,
1647 GParamSpec * arg G_GNUC_UNUSED, GESTimeline * timeline)
1649 guint64 duration, max_duration = 0;
1652 for (tmp = timeline->priv->tracks; tmp; tmp = g_list_next (tmp)) {
1653 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
1654 g_object_get (tr_priv->track, "duration", &duration, NULL);
1656 GST_DEBUG_OBJECT (track, "track duration : %" GST_TIME_FORMAT,
1657 GST_TIME_ARGS (duration));
1658 max_duration = MAX (duration, max_duration);
1661 if (timeline->priv->duration != max_duration) {
1662 GST_DEBUG ("track duration : %" GST_TIME_FORMAT " current : %"
1663 GST_TIME_FORMAT, GST_TIME_ARGS (max_duration),
1664 GST_TIME_ARGS (timeline->priv->duration));
1666 timeline->priv->duration = max_duration;
1668 #if GLIB_CHECK_VERSION(2,26,0)
1669 g_object_notify_by_pspec (G_OBJECT (timeline), properties[PROP_DURATION]);
1671 g_object_notify (G_OBJECT (timeline), "duration");
1676 static GstStateChangeReturn
1677 ges_timeline_change_state (GstElement * element, GstStateChange transition)
1679 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
1680 GESTimeline *timeline = GES_TIMELINE (element);
1682 switch (transition) {
1683 case GST_STATE_CHANGE_READY_TO_PAUSED:
1684 GES_TIMELINE_PENDINGOBJS_LOCK (timeline);
1685 if (timeline->priv->pendingobjects) {
1686 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1687 do_async_start (timeline);
1688 ret = GST_STATE_CHANGE_ASYNC;
1690 GES_TIMELINE_PENDINGOBJS_UNLOCK (timeline);
1698 GstStateChangeReturn bret;
1700 bret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
1701 if (G_UNLIKELY (bret == GST_STATE_CHANGE_NO_PREROLL)) {
1702 do_async_done (timeline);
1707 switch (transition) {
1708 case GST_STATE_CHANGE_PAUSED_TO_READY:
1709 do_async_done (timeline);
1722 * Creates a new empty #GESTimeline.
1724 * Returns: The new timeline.
1728 ges_timeline_new (void)
1730 return g_object_new (GES_TYPE_TIMELINE, NULL);
1734 * ges_timeline_new_from_uri:
1735 * @uri: the URI to load from
1737 * Creates a timeline from the given URI.
1739 * Returns: A new timeline if the uri was loaded successfully, or NULL if the
1740 * uri could not be loaded
1744 ges_timeline_new_from_uri (const gchar * uri)
1748 /* FIXME : we should have a GError** argument so the user can know why
1749 * it wasn't able to load the uri
1752 ret = ges_timeline_new ();
1754 if (!ges_timeline_load_from_uri (ret, uri)) {
1755 g_object_unref (ret);
1764 * ges_timeline_load_from_uri:
1765 * @timeline: an empty #GESTimeline into which to load the formatter
1766 * @uri: The URI to load from
1768 * Loads the contents of URI into the given timeline.
1770 * Returns: TRUE if the timeline was loaded successfully, or FALSE if the uri
1771 * could not be loaded.
1775 ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri)
1777 GESFormatter *p = NULL;
1778 gboolean ret = FALSE;
1780 /* FIXME : we should have a GError** argument so the user can know why
1781 * it wasn't able to load the uri
1784 if (!(p = ges_formatter_new_for_uri (uri))) {
1785 GST_ERROR ("unsupported uri '%s'", uri);
1789 if (!ges_formatter_load_from_uri (p, timeline, uri)) {
1790 GST_ERROR ("error deserializing formatter");
1803 * ges_timeline_save_to_uri:
1804 * @timeline: a #GESTimeline
1805 * @uri: The location to save to
1807 * Saves the timeline to the given location
1809 * Returns: TRUE if the timeline was successfully saved to the given location,
1814 ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri)
1816 GESFormatter *p = NULL;
1817 gboolean ret = FALSE;
1819 /* FIXME : How will the user be able to chose the format he
1820 * wishes to store to ? */
1822 /* FIXME : How will we ensure a timeline loaded with a certain format
1823 * will be saved with the same one by default ? We need to make this
1824 * easy from an API perspective */
1826 /* FIXME : we should have a GError** argument so the user can know why
1827 * it wasn't able to save
1830 if (!(p = ges_formatter_new_for_uri (uri))) {
1831 GST_ERROR ("unsupported uri '%s'", uri);
1835 if (!ges_formatter_save_to_uri (p, timeline, uri)) {
1836 GST_ERROR ("error serializing formatter");
1849 * ges_timeline_append_layer:
1850 * @timeline: a #GESTimeline
1852 * Append a newly creater #GESTimelineLayer to @timeline
1853 * Note that you do not own any reference to the returned layer.
1855 * Returns: (transfer none): The newly created #GESTimelineLayer, or the last (empty)
1856 * #GESTimelineLayer of @timeline.
1859 ges_timeline_append_layer (GESTimeline * timeline)
1862 GESTimelinePrivate *priv = timeline->priv;
1863 GESTimelineLayer *layer;
1865 layer = ges_timeline_layer_new ();
1866 priority = g_list_length (priv->layers);
1867 ges_timeline_layer_set_priority (layer, priority);
1869 ges_timeline_add_layer (timeline, layer);
1875 * ges_timeline_add_layer:
1876 * @timeline: a #GESTimeline
1877 * @layer: the #GESTimelineLayer to add
1879 * Add the layer to the timeline. The reference to the @layer will be stolen
1882 * Returns: TRUE if the layer was properly added, else FALSE.
1885 ges_timeline_add_layer (GESTimeline * timeline, GESTimelineLayer * layer)
1887 GList *objects, *tmp;
1888 GESTimelinePrivate *priv = timeline->priv;
1890 GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
1892 /* We can only add a layer that doesn't already belong to another timeline */
1893 if (G_UNLIKELY (layer->timeline)) {
1894 GST_WARNING ("Layer belongs to another timeline, can't add it");
1898 /* Add to the list of layers, make sure we don't already control it */
1899 if (G_UNLIKELY (g_list_find (priv->layers, (gconstpointer) layer))) {
1900 GST_WARNING ("Layer is already controlled by this timeline");
1904 g_object_ref_sink (layer);
1905 priv->layers = g_list_insert_sorted (priv->layers, layer,
1906 (GCompareFunc) sort_layers);
1908 /* Inform the layer that it belongs to a new timeline */
1909 ges_timeline_layer_set_timeline (layer, timeline);
1911 /* Connect to 'object-added'/'object-removed' signal from the new layer */
1912 g_signal_connect (layer, "object-added", G_CALLBACK (layer_object_added_cb),
1914 g_signal_connect (layer, "object-removed",
1915 G_CALLBACK (layer_object_removed_cb), timeline);
1916 g_signal_connect (layer, "notify::priority",
1917 G_CALLBACK (layer_priority_changed_cb), timeline);
1919 GST_DEBUG ("Done adding layer, emitting 'layer-added' signal");
1920 g_signal_emit (timeline, ges_timeline_signals[LAYER_ADDED], 0, layer);
1922 /* add any existing timeline objects to the timeline */
1923 objects = ges_timeline_layer_get_objects (layer);
1924 for (tmp = objects; tmp; tmp = tmp->next) {
1925 layer_object_added_cb (layer, tmp->data, timeline);
1926 g_object_unref (tmp->data);
1929 g_list_free (objects);
1935 * ges_timeline_remove_layer:
1936 * @timeline: a #GESTimeline
1937 * @layer: the #GESTimelineLayer to remove
1939 * Removes the layer from the timeline. The reference that the @timeline holds on
1940 * the layer will be dropped. If you wish to use the @layer after calling this
1941 * method, you need to take a reference before calling.
1943 * Returns: TRUE if the layer was properly removed, else FALSE.
1947 ges_timeline_remove_layer (GESTimeline * timeline, GESTimelineLayer * layer)
1949 GList *layer_objects, *tmp;
1950 GESTimelinePrivate *priv = timeline->priv;
1952 GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
1954 if (G_UNLIKELY (!g_list_find (priv->layers, layer))) {
1955 GST_WARNING ("Layer doesn't belong to this timeline");
1959 /* remove objects from any private data structures */
1961 layer_objects = ges_timeline_layer_get_objects (layer);
1962 for (tmp = layer_objects; tmp; tmp = tmp->next) {
1963 layer_object_removed_cb (layer, GES_TIMELINE_OBJECT (tmp->data), timeline);
1964 g_object_unref (G_OBJECT (tmp->data));
1967 g_list_free (layer_objects);
1969 /* Disconnect signals */
1970 GST_DEBUG ("Disconnecting signal callbacks");
1971 g_signal_handlers_disconnect_by_func (layer, layer_object_added_cb, timeline);
1972 g_signal_handlers_disconnect_by_func (layer, layer_object_removed_cb,
1975 priv->layers = g_list_remove (priv->layers, layer);
1977 ges_timeline_layer_set_timeline (layer, NULL);
1979 g_signal_emit (timeline, ges_timeline_signals[LAYER_REMOVED], 0, layer);
1981 g_object_unref (layer);
1987 pad_added_cb (GESTrack * track, GstPad * pad, TrackPrivate * tr_priv)
1993 GST_DEBUG ("track:%p, pad:%s:%s", track, GST_DEBUG_PAD_NAME (pad));
1995 if (G_UNLIKELY (tr_priv->pad)) {
1996 GST_WARNING ("We are already controlling a pad for this track");
2000 /* Remember the pad */
2001 GST_OBJECT_LOCK (track);
2005 for (tmp = tr_priv->timeline->priv->tracks; tmp; tmp = g_list_next (tmp)) {
2006 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
2008 if (!tr_priv->pad) {
2009 GST_LOG ("Found track without pad %p", tr_priv->track);
2013 GST_OBJECT_UNLOCK (track);
2016 GST_DEBUG ("Ghosting pad and adding it to ourself");
2017 padname = g_strdup_printf ("track_%p_src", track);
2018 tr_priv->ghostpad = gst_ghost_pad_new (padname, pad);
2020 gst_pad_set_active (tr_priv->ghostpad, TRUE);
2021 gst_element_add_pad (GST_ELEMENT (tr_priv->timeline), tr_priv->ghostpad);
2024 GST_DEBUG ("Signaling no-more-pads");
2025 gst_element_no_more_pads (GST_ELEMENT (tr_priv->timeline));
2030 pad_removed_cb (GESTrack * track, GstPad * pad, TrackPrivate * tr_priv)
2032 GST_DEBUG ("track:%p, pad:%s:%s", track, GST_DEBUG_PAD_NAME (pad));
2034 if (G_UNLIKELY (tr_priv->pad != pad)) {
2035 GST_WARNING ("Not the pad we're controlling");
2039 if (G_UNLIKELY (tr_priv->ghostpad == NULL)) {
2040 GST_WARNING ("We don't have a ghostpad for this pad !");
2044 GST_DEBUG ("Removing ghostpad");
2045 gst_pad_set_active (tr_priv->ghostpad, FALSE);
2046 gst_element_remove_pad (GST_ELEMENT (tr_priv->timeline), tr_priv->ghostpad);
2047 tr_priv->ghostpad = NULL;
2048 tr_priv->pad = NULL;
2052 * ges_timeline_add_track:
2053 * @timeline: a #GESTimeline
2054 * @track: the #GESTrack to add
2056 * Add a track to the timeline. The reference to the track will be stolen by the
2059 * Returns: TRUE if the track was properly added, else FALSE.
2062 /* FIXME: create track objects for timeline objects which have already been
2063 * added to existing layers.
2067 ges_timeline_add_track (GESTimeline * timeline, GESTrack * track)
2069 TrackPrivate *tr_priv;
2070 GESTimelinePrivate *priv = timeline->priv;
2073 GST_DEBUG ("timeline:%p, track:%p", timeline, track);
2075 /* make sure we don't already control it */
2076 if (G_UNLIKELY (g_list_find_custom (priv->tracks, (gconstpointer) track,
2077 (GCompareFunc) custom_find_track))) {
2078 GST_WARNING ("Track is already controlled by this timeline");
2082 /* Add the track to ourself (as a GstBin)
2083 * Reference is stolen ! */
2084 if (G_UNLIKELY (!gst_bin_add (GST_BIN (timeline), GST_ELEMENT (track)))) {
2085 GST_WARNING ("Couldn't add track to ourself (GST)");
2089 tr_priv = g_new0 (TrackPrivate, 1);
2090 tr_priv->timeline = timeline;
2091 tr_priv->track = track;
2093 /* Add the track to the list of tracks we track */
2094 priv->tracks = g_list_append (priv->tracks, tr_priv);
2096 /* Listen to pad-added/-removed */
2097 g_signal_connect (track, "pad-added", (GCallback) pad_added_cb, tr_priv);
2098 g_signal_connect (track, "pad-removed", (GCallback) pad_removed_cb, tr_priv);
2100 /* Inform the track that it's currently being used by ourself */
2101 ges_track_set_timeline (track, timeline);
2103 GST_DEBUG ("Done adding track, emitting 'track-added' signal");
2105 /* emit 'track-added' */
2106 g_signal_emit (timeline, ges_timeline_signals[TRACK_ADDED], 0, track);
2108 /* ensure that each existing timeline object has the opportunity to create a
2109 * track object for this track*/
2111 /* We connect to the duration change notify, so we can update
2112 * our duration accordingly */
2113 g_signal_connect (G_OBJECT (track), "notify::duration",
2114 G_CALLBACK (track_duration_cb), timeline);
2116 /* We connect to the object for the timeline editing mode management */
2117 g_signal_connect (G_OBJECT (track), "track-object-added",
2118 G_CALLBACK (track_object_added_cb), timeline);
2119 g_signal_connect (G_OBJECT (track), "track-object-removed",
2120 G_CALLBACK (track_object_removed_cb), timeline);
2122 for (tmp = priv->layers; tmp; tmp = tmp->next) {
2123 GList *objects, *obj;
2124 objects = ges_timeline_layer_get_objects (tmp->data);
2126 for (obj = objects; obj; obj = obj->next) {
2127 add_object_to_track (obj->data, track);
2128 g_object_unref (obj->data);
2131 g_list_free (objects);
2134 track_duration_cb (GST_ELEMENT (track), NULL, timeline);
2140 * ges_timeline_remove_track:
2141 * @timeline: a #GESTimeline
2142 * @track: the #GESTrack to remove
2144 * Remove the @track from the @timeline. The reference stolen when adding the
2145 * @track will be removed. If you wish to use the @track after calling this
2146 * function you must ensure that you have a reference to it.
2148 * Returns: TRUE if the @track was properly removed, else FALSE.
2151 /* FIXME: release any track objects associated with this layer. currenly this
2152 * will not happen if you remove the track before removing *all*
2153 * timelineobjects which have a track object in this track.
2157 ges_timeline_remove_track (GESTimeline * timeline, GESTrack * track)
2160 TrackPrivate *tr_priv;
2161 GESTimelinePrivate *priv = timeline->priv;
2163 GST_DEBUG ("timeline:%p, track:%p", timeline, track);
2165 if (G_UNLIKELY (!(tmp =
2166 g_list_find_custom (priv->tracks, (gconstpointer) track,
2167 (GCompareFunc) custom_find_track)))) {
2168 GST_WARNING ("Track doesn't belong to this timeline");
2172 tr_priv = tmp->data;
2173 priv->tracks = g_list_remove (priv->tracks, tr_priv);
2175 ges_track_set_timeline (track, NULL);
2177 /* Remove ghost pad */
2178 if (tr_priv->ghostpad) {
2179 GST_DEBUG ("Removing ghostpad");
2180 gst_pad_set_active (tr_priv->ghostpad, FALSE);
2181 gst_ghost_pad_set_target ((GstGhostPad *) tr_priv->ghostpad, NULL);
2182 gst_element_remove_pad (GST_ELEMENT (timeline), tr_priv->ghostpad);
2185 /* Remove pad-added/-removed handlers */
2186 g_signal_handlers_disconnect_by_func (track, pad_added_cb, tr_priv);
2187 g_signal_handlers_disconnect_by_func (track, pad_removed_cb, tr_priv);
2188 g_signal_handlers_disconnect_by_func (track, track_duration_cb,
2190 g_signal_handlers_disconnect_by_func (track, track_object_added_cb, timeline);
2191 g_signal_handlers_disconnect_by_func (track, track_object_removed_cb,
2194 /* Signal track removal to all layers/objects */
2195 g_signal_emit (timeline, ges_timeline_signals[TRACK_REMOVED], 0, track);
2197 /* remove track from our bin */
2198 gst_object_ref (track);
2199 if (G_UNLIKELY (!gst_bin_remove (GST_BIN (timeline), GST_ELEMENT (track)))) {
2200 GST_WARNING ("Couldn't remove track to ourself (GST)");
2201 gst_object_unref (track);
2205 /* set track state to NULL */
2207 gst_element_set_state (GST_ELEMENT (track), GST_STATE_NULL);
2209 gst_object_unref (track);
2217 * ges_timeline_get_track_for_pad:
2218 * @timeline: The #GESTimeline
2221 * Search the #GESTrack corresponding to the given @timeline's @pad.
2223 * Returns: (transfer none): The corresponding #GESTrack if it is found,
2224 * or %NULL if there is an error.
2228 ges_timeline_get_track_for_pad (GESTimeline * timeline, GstPad * pad)
2232 for (tmp = timeline->priv->tracks; tmp; tmp = g_list_next (tmp)) {
2233 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
2234 if (pad == tr_priv->ghostpad)
2235 return tr_priv->track;
2242 * ges_timeline_get_tracks:
2243 * @timeline: a #GESTimeline
2245 * Returns the list of #GESTrack used by the Timeline.
2247 * Returns: (transfer full) (element-type GESTrack): A list of #GESTrack.
2248 * The caller should unref each track once he is done with them.
2251 ges_timeline_get_tracks (GESTimeline * timeline)
2253 GList *tmp, *res = NULL;
2255 for (tmp = timeline->priv->tracks; tmp; tmp = g_list_next (tmp)) {
2256 TrackPrivate *tr_priv = (TrackPrivate *) tmp->data;
2257 res = g_list_append (res, g_object_ref (tr_priv->track));
2264 * ges_timeline_get_layers:
2265 * @timeline: a #GESTimeline
2267 * Get the list of #GESTimelineLayer present in the Timeline.
2269 * Returns: (transfer full) (element-type GESTimelineLayer): the list of
2270 * #GESTimelineLayer present in the Timeline sorted by priority.
2271 * The caller should unref each Layer once he is done with them.
2274 ges_timeline_get_layers (GESTimeline * timeline)
2276 GList *tmp, *res = NULL;
2278 for (tmp = timeline->priv->layers; tmp; tmp = g_list_next (tmp)) {
2279 res = g_list_insert_sorted (res, g_object_ref (tmp->data),
2280 (GCompareFunc) sort_layers);
2287 * ges_timeline_is_updating:
2288 * @timeline: a #GESTimeline
2290 * Get whether the timeline is updated for every change happening within or not.
2292 * Returns: %TRUE if @timeline is updating on every changes, else %FALSE.
2295 ges_timeline_is_updating (GESTimeline * timeline)
2299 g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
2301 for (tmp = timeline->priv->tracks; tmp; tmp = tmp->next) {
2302 if (!ges_track_is_updating (((TrackPrivate *) tmp->data)->track))
2310 * ges_timeline_enable_update:
2311 * @timeline: a #GESTimeline
2312 * @enabled: Whether the timeline should update on every change or not.
2314 * Control whether the timeline is updated for every change happening within.
2316 * Users will want to use this method with %FALSE before doing lots of changes,
2317 * and then call again with %TRUE for the changes to take effect in one go.
2319 * Returns: %TRUE if the update status could be changed, else %FALSE.
2322 ges_timeline_enable_update (GESTimeline * timeline, gboolean enabled)
2325 gboolean res = TRUE;
2327 GST_DEBUG_OBJECT (timeline, "%s updates", enabled ? "Enabling" : "Disabling");
2329 for (tmp = timeline->priv->tracks; tmp; tmp = tmp->next) {
2330 if (!ges_track_enable_update (((TrackPrivate *) tmp->data)->track, enabled))
2334 /* Make sure we reset the context */
2335 timeline->priv->movecontext.needs_move_ctx = TRUE;