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"
47 G_DEFINE_TYPE (GESTimeline, ges_timeline, GST_TYPE_BIN);
49 /* private structure to contain our track-related information */
53 GESTimeline *timeline;
55 GstPad *pad; /* Pad from the track */
68 static GstBinClass *parent_class;
70 static guint ges_timeline_signals[LAST_SIGNAL] = { 0 };
72 gint custom_find_track (TrackPrivate * priv, GESTrack * track);
73 static GstStateChangeReturn
74 ges_timeline_change_state (GstElement * element, GstStateChange transition);
76 discoverer_finished_cb (GstDiscoverer * discoverer, GESTimeline * timeline);
78 discoverer_discovered_cb (GstDiscoverer * discoverer,
79 GstDiscovererInfo * info, GError * err, GESTimeline * timeline);
82 ges_timeline_get_property (GObject * object, guint property_id,
83 GValue * value, GParamSpec * pspec)
85 switch (property_id) {
87 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
92 ges_timeline_set_property (GObject * object, guint property_id,
93 const GValue * value, GParamSpec * pspec)
95 switch (property_id) {
97 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
102 ges_timeline_dispose (GObject * object)
104 GESTimeline *timeline = GES_TIMELINE (object);
106 if (timeline->discoverer) {
107 gst_discoverer_stop (timeline->discoverer);
108 g_object_unref (timeline->discoverer);
109 timeline->discoverer = NULL;
112 while (timeline->layers) {
113 GESTimelineLayer *layer = (GESTimelineLayer *) timeline->layers->data;
114 ges_timeline_remove_layer (timeline, layer);
117 /* FIXME: it should be possible to remove tracks before removing
118 * layers, but at the moment this creates a problem because the track
119 * objects aren't notified that their gnlobjects have been destroyed.
122 while (timeline->tracks) {
123 TrackPrivate *priv = (TrackPrivate *) timeline->tracks->data;
124 ges_timeline_remove_track (timeline, priv->track);
127 G_OBJECT_CLASS (ges_timeline_parent_class)->dispose (object);
131 ges_timeline_finalize (GObject * object)
133 G_OBJECT_CLASS (ges_timeline_parent_class)->finalize (object);
137 ges_timeline_class_init (GESTimelineClass * klass)
139 GObjectClass *object_class = G_OBJECT_CLASS (klass);
140 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
142 parent_class = g_type_class_peek_parent (klass);
144 element_class->change_state = ges_timeline_change_state;
146 object_class->get_property = ges_timeline_get_property;
147 object_class->set_property = ges_timeline_set_property;
148 object_class->dispose = ges_timeline_dispose;
149 object_class->finalize = ges_timeline_finalize;
152 * GESTimeline::track-added
153 * @timeline: the #GESTimeline
154 * @track: the #GESTrack that was added to the timeline
156 * Will be emitted after the track was added to the timeline.
158 ges_timeline_signals[TRACK_ADDED] =
159 g_signal_new ("track-added", G_TYPE_FROM_CLASS (klass),
160 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_added), NULL,
161 NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TRACK);
164 * GESTimeline::track-removed
165 * @timeline: the #GESTimeline
166 * @track: the #GESTrack that was removed from the timeline
168 * Will be emitted after the track was removed from the timeline.
170 ges_timeline_signals[TRACK_REMOVED] =
171 g_signal_new ("track-removed", G_TYPE_FROM_CLASS (klass),
172 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, track_removed),
173 NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TRACK);
176 * GESTimeline::layer-added
177 * @timeline: the #GESTimeline
178 * @layer: the #GESTimelineLayer that was added to the timeline
180 * Will be emitted after the layer was added to the timeline.
182 ges_timeline_signals[LAYER_ADDED] =
183 g_signal_new ("layer-added", G_TYPE_FROM_CLASS (klass),
184 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_added), NULL,
185 NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GES_TYPE_TIMELINE_LAYER);
188 * GESTimeline::layer-removed
189 * @timeline: the #GESTimeline
190 * @layer: the #GESTimelineLayer that was removed from the timeline
192 * Will be emitted after the layer was removed from the timeline.
194 ges_timeline_signals[LAYER_REMOVED] =
195 g_signal_new ("layer-removed", G_TYPE_FROM_CLASS (klass),
196 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed),
197 NULL, NULL, ges_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
198 GES_TYPE_TIMELINE_LAYER);
202 ges_timeline_init (GESTimeline * self)
207 /* New discoverer with a 15s timeout */
208 self->discoverer = gst_discoverer_new (15 * GST_SECOND, NULL);
209 g_signal_connect (self->discoverer, "finished",
210 G_CALLBACK (discoverer_finished_cb), self);
211 g_signal_connect (self->discoverer, "discovered",
212 G_CALLBACK (discoverer_discovered_cb), self);
213 gst_discoverer_start (self->discoverer);
219 * Creates a new empty #GESTimeline.
221 * Returns: The new timeline.
225 ges_timeline_new (void)
227 return g_object_new (GES_TYPE_TIMELINE, NULL);
231 * ges_timeline_new_from_uri:
232 * @uri: the URI to load from
234 * Creates a timeline from the given URI.
236 * Returns: A new timeline if the uri was loaded successfully, or NULL if the
237 * uri could not be loaded
241 ges_timeline_new_from_uri (gchar * uri)
245 /* FIXME : we should have a GError** argument so the user can know why
246 * it wasn't able to load the uri
249 ret = ges_timeline_new ();
251 if (!ges_timeline_load_from_uri (ret, uri)) {
252 g_object_unref (ret);
261 * ges_timeline_load_from_uri:
262 * @timeline: an empty #GESTimeline into which to load the formatter
263 * @uri: The URI to load from
265 * Loads the contents of URI into the given timeline.
267 * Returns: TRUE if the timeline was loaded successfully, or FALSE if the uri
268 * could not be loaded.
272 ges_timeline_load_from_uri (GESTimeline * timeline, gchar * uri)
274 GESFormatter *p = NULL;
275 gboolean ret = FALSE;
277 /* FIXME : we should have a GError** argument so the user can know why
278 * it wasn't able to load the uri
281 if (!(p = ges_formatter_new_for_uri (uri))) {
282 GST_ERROR ("unsupported uri '%s'", uri);
286 if (!ges_formatter_load_from_uri (p, timeline, uri)) {
287 GST_ERROR ("error deserializing formatter");
300 * ges_timeline_save_to_uri:
301 * @timeline: a #GESTimeline
302 * @uri: The location to save to
304 * Saves the timeline to the given location
306 * Returns: TRUE if the timeline was successfully saved to the given location,
311 ges_timeline_save_to_uri (GESTimeline * timeline, gchar * uri)
313 GESFormatter *p = NULL;
314 gboolean ret = FALSE;
316 /* FIXME : How will the user be able to chose the format he
317 * wishes to store to ? */
319 /* FIXME : How will we ensure a timeline loaded with a certain format
320 * will be saved with the same one by default ? We need to make this
321 * easy from an API perspective */
323 /* FIXME : we should have a GError** argument so the user can know why
324 * it wasn't able to save
327 if (!(p = ges_formatter_new_for_uri (uri))) {
328 GST_ERROR ("unsupported uri '%s'", uri);
332 if (!ges_formatter_save_to_uri (p, timeline, uri)) {
333 GST_ERROR ("error serializing formatter");
346 add_object_to_track (GESTimelineObject * object, GESTrack * track)
348 if (!ges_timeline_object_create_track_objects (object, track)) {
349 GST_WARNING ("error creating track objects");
354 add_object_to_tracks (GESTimeline * timeline, GESTimelineObject * object)
358 for (tmp = timeline->tracks; tmp; tmp = g_list_next (tmp)) {
359 TrackPrivate *priv = (TrackPrivate *) tmp->data;
360 GESTrack *track = priv->track;
362 GST_LOG ("Trying with track %p", track);
363 add_object_to_track (object, track);
369 do_async_start (GESTimeline * timeline)
374 timeline->async_pending = TRUE;
376 /* Freeze state of tracks */
377 for (tmp = timeline->tracks; tmp; tmp = tmp->next) {
378 TrackPrivate *priv = (TrackPrivate *) tmp->data;
379 gst_element_set_locked_state ((GstElement *) priv->track, TRUE);
382 message = gst_message_new_async_start (GST_OBJECT_CAST (timeline), FALSE);
383 parent_class->handle_message (GST_BIN_CAST (timeline), message);
387 do_async_done (GESTimeline * timeline)
391 if (timeline->async_pending) {
393 /* Unfreeze state of tracks */
394 for (tmp = timeline->tracks; tmp; tmp = tmp->next) {
395 TrackPrivate *priv = (TrackPrivate *) tmp->data;
396 gst_element_set_locked_state ((GstElement *) priv->track, FALSE);
397 gst_element_sync_state_with_parent ((GstElement *) priv->track);
400 GST_DEBUG_OBJECT (timeline, "Emitting async-done");
401 message = gst_message_new_async_done (GST_OBJECT_CAST (timeline));
402 parent_class->handle_message (GST_BIN_CAST (timeline), message);
404 timeline->async_pending = FALSE;
409 discoverer_finished_cb (GstDiscoverer * discoverer, GESTimeline * timeline)
411 do_async_done (timeline);
415 discoverer_discovered_cb (GstDiscoverer * discoverer,
416 GstDiscovererInfo * info, GError * err, GESTimeline * timeline)
419 gboolean found = FALSE;
420 gboolean is_image = FALSE;
421 GESTimelineFileSource *tfs = NULL;
422 const gchar *uri = gst_discoverer_info_get_uri (info);
424 GST_DEBUG ("Discovered uri %s", uri);
426 /* Find corresponding TimelineFileSource in the sources */
427 for (tmp = timeline->pendingobjects; tmp; tmp = tmp->next) {
428 tfs = (GESTimelineFileSource *) tmp->data;
430 if (!g_strcmp0 (tfs->uri, uri)) {
439 /* Remove object from list */
440 timeline->pendingobjects =
441 g_list_delete_link (timeline->pendingobjects, tmp);
443 /* FIXME : Handle errors in discovery */
444 stream_list = gst_discoverer_info_get_stream_list (info);
446 /* Update timelinefilesource properties based on info */
447 for (tmp = stream_list; tmp; tmp = tmp->next) {
448 GstDiscovererStreamInfo *sinf = (GstDiscovererStreamInfo *) tmp->data;
450 if (GST_IS_DISCOVERER_AUDIO_INFO (sinf))
451 tfs->supportedformats |= GES_TRACK_TYPE_AUDIO;
452 else if (GST_IS_DISCOVERER_VIDEO_INFO (sinf)) {
453 tfs->supportedformats |= GES_TRACK_TYPE_VIDEO;
454 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
456 tfs->supportedformats |= GES_TRACK_TYPE_AUDIO;
463 gst_discoverer_stream_info_list_free (stream_list);
466 /* don't set max-duration on still images */
467 g_object_set (tfs, "is_image", (gboolean) TRUE, NULL);
471 g_object_set (tfs, "max-duration",
472 gst_discoverer_info_get_duration (info), NULL);
475 /* Continue the processing on tfs */
476 add_object_to_tracks (timeline, GES_TIMELINE_OBJECT (tfs));
480 static GstStateChangeReturn
481 ges_timeline_change_state (GstElement * element, GstStateChange transition)
483 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
484 GESTimeline *timeline = GES_TIMELINE (element);
486 switch (transition) {
487 case GST_STATE_CHANGE_READY_TO_PAUSED:
488 if (timeline->pendingobjects) {
489 do_async_start (timeline);
490 ret = GST_STATE_CHANGE_ASYNC;
498 GstStateChangeReturn bret;
500 bret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
501 if (G_UNLIKELY (bret == GST_STATE_CHANGE_NO_PREROLL)) {
502 do_async_done (timeline);
507 switch (transition) {
508 case GST_STATE_CHANGE_PAUSED_TO_READY:
509 do_async_done (timeline);
520 layer_object_added_cb (GESTimelineLayer * layer, GESTimelineObject * object,
521 GESTimeline * timeline)
523 GST_DEBUG ("New TimelineObject %p added to layer %p", object, layer);
525 if (GES_IS_TIMELINE_FILE_SOURCE (object)) {
526 GESTimelineFileSource *tfs = GES_TIMELINE_FILE_SOURCE (object);
528 /* Send the filesource to the discoverer if:
529 * * it doesn't have specified supported formats
530 * * OR it doesn't have a specified max-duration
531 * * OR it doesn't have a valid duration */
533 if (tfs->supportedformats == GES_TRACK_TYPE_UNKNOWN ||
534 tfs->maxduration == GST_CLOCK_TIME_NONE || object->duration == 0) {
535 GST_LOG ("Incomplete TimelineFileSource, discovering it");
536 timeline->pendingobjects =
537 g_list_append (timeline->pendingobjects, object);
538 gst_discoverer_discover_uri_async (timeline->discoverer,
539 GES_TIMELINE_FILE_SOURCE (object)->uri);
541 add_object_to_tracks (timeline, object);
543 add_object_to_tracks (timeline, object);
551 layer_object_removed_cb (GESTimelineLayer * layer, GESTimelineObject * object,
552 GESTimeline * timeline)
554 GList *tmp, *next, *trackobjects;
556 GST_DEBUG ("TimelineObject %p removed from layer %p", object, layer);
558 /* Go over the object's track objects and figure out which one belongs to
559 * the list of tracks we control */
561 trackobjects = ges_timeline_object_get_track_objects (object);
562 for (tmp = trackobjects; tmp; tmp = tmp->next) {
563 GESTrackObject *trobj = (GESTrackObject *) tmp->data;
565 next = g_list_next (tmp);
567 GST_DEBUG ("Trying to remove TrackObject %p", trobj);
568 if (G_LIKELY (g_list_find_custom (timeline->tracks,
569 (gconstpointer) trobj->track,
570 (GCompareFunc) custom_find_track))) {
571 GST_DEBUG ("Belongs to one of the tracks we control");
572 ges_track_remove_object (trobj->track, trobj);
574 ges_timeline_object_release_track_object (object, trobj);
577 g_object_unref (GES_TRACK_OBJECT (tmp->data));
579 g_list_free (trackobjects);
585 * ges_timeline_add_layer:
586 * @timeline: a #GESTimeline
587 * @layer: the #GESTimelineLayer to add
589 * Add the layer to the timeline. The reference to the @layer will be stolen
592 * Returns: TRUE if the layer was properly added, else FALSE.
595 ges_timeline_add_layer (GESTimeline * timeline, GESTimelineLayer * layer)
597 GList *objects, *tmp;
599 GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
601 /* We can only add a layer that doesn't already belong to another timeline */
602 if (G_UNLIKELY (layer->timeline)) {
603 GST_WARNING ("Layer belongs to another timeline, can't add it");
607 /* Add to the list of layers, make sure we don't already control it */
608 if (G_UNLIKELY (g_list_find (timeline->layers, (gconstpointer) layer))) {
609 GST_WARNING ("Layer is already controlled by this timeline");
613 /* Reference is stolen */
614 timeline->layers = g_list_append (timeline->layers, layer);
616 /* Inform the layer that it belongs to a new timeline */
617 ges_timeline_layer_set_timeline (layer, timeline);
619 /* Connect to 'object-added'/'object-removed' signal from the new layer */
620 g_signal_connect (layer, "object-added", G_CALLBACK (layer_object_added_cb),
622 g_signal_connect (layer, "object-removed",
623 G_CALLBACK (layer_object_removed_cb), timeline);
625 GST_DEBUG ("Done adding layer, emitting 'layer-added' signal");
626 g_signal_emit (timeline, ges_timeline_signals[LAYER_ADDED], 0, layer);
628 /* add any existing timeline objects to the timeline */
629 objects = ges_timeline_layer_get_objects (layer);
630 for (tmp = objects; tmp; tmp = tmp->next) {
631 layer_object_added_cb (layer, tmp->data, timeline);
632 g_object_unref (tmp->data);
635 g_list_free (objects);
641 * ges_timeline_remove_layer:
642 * @timeline: a #GESTimeline
643 * @layer: the #GESTimelineLayer to remove
645 * Removes the layer from the timeline. The reference that the @timeline holds on
646 * the layer will be dropped. If you wish to use the @layer after calling this
647 * method, you need to take a reference before calling.
649 * Returns: TRUE if the layer was properly removed, else FALSE.
653 ges_timeline_remove_layer (GESTimeline * timeline, GESTimelineLayer * layer)
655 GList *layer_objects, *tmp;
657 GST_DEBUG ("timeline:%p, layer:%p", timeline, layer);
659 if (G_UNLIKELY (!g_list_find (timeline->layers, layer))) {
660 GST_WARNING ("Layer doesn't belong to this timeline");
664 /* remove objects from any private data structures */
666 layer_objects = ges_timeline_layer_get_objects (layer);
667 for (tmp = layer_objects; tmp; tmp = tmp->next) {
668 layer_object_removed_cb (layer, GES_TIMELINE_OBJECT (tmp->data), timeline);
669 g_object_unref (G_OBJECT (tmp->data));
672 g_list_free (layer_objects);
674 /* Disconnect signals */
675 GST_DEBUG ("Disconnecting signal callbacks");
676 g_signal_handlers_disconnect_by_func (layer, layer_object_added_cb, timeline);
677 g_signal_handlers_disconnect_by_func (layer, layer_object_removed_cb,
680 timeline->layers = g_list_remove (timeline->layers, layer);
682 ges_timeline_layer_set_timeline (layer, NULL);
684 g_signal_emit (timeline, ges_timeline_signals[LAYER_REMOVED], 0, layer);
686 g_object_unref (layer);
692 pad_added_cb (GESTrack * track, GstPad * pad, TrackPrivate * priv)
697 GST_DEBUG ("track:%p, pad:%s:%s", track, GST_DEBUG_PAD_NAME (pad));
699 if (G_UNLIKELY (priv->pad)) {
700 GST_WARNING ("We are already controlling a pad for this track");
704 /* Remember the pad */
708 GST_DEBUG ("Ghosting pad and adding it to ourself");
709 padname = g_strdup_printf ("track_%p_src", track);
710 priv->ghostpad = gst_ghost_pad_new (padname, pad);
712 gst_pad_set_active (priv->ghostpad, TRUE);
713 gst_element_add_pad (GST_ELEMENT (priv->timeline), priv->ghostpad);
717 pad_removed_cb (GESTrack * track, GstPad * pad, TrackPrivate * priv)
719 GST_DEBUG ("track:%p, pad:%s:%s", track, GST_DEBUG_PAD_NAME (pad));
721 if (G_UNLIKELY (priv->pad != pad)) {
722 GST_WARNING ("Not the pad we're controlling");
726 if (G_UNLIKELY (priv->ghostpad == NULL)) {
727 GST_WARNING ("We don't have a ghostpad for this pad !");
731 GST_DEBUG ("Removing ghostpad");
732 gst_pad_set_active (priv->ghostpad, FALSE);
733 gst_element_remove_pad (GST_ELEMENT (priv->timeline), priv->ghostpad);
734 priv->ghostpad = NULL;
739 custom_find_track (TrackPrivate * priv, GESTrack * track)
741 if (priv->track == track)
747 * ges_timeline_add_track:
748 * @timeline: a #GESTimeline
749 * @track: the #GESTrack to add
751 * Add a track to the timeline. The reference to the track will be stolen by the
754 * Returns: TRUE if the track was properly added, else FALSE.
757 /* FIXME: create track objects for timeline objects which have already been
758 * added to existing layers.
762 ges_timeline_add_track (GESTimeline * timeline, GESTrack * track)
767 GST_DEBUG ("timeline:%p, track:%p", timeline, track);
769 /* make sure we don't already control it */
770 if (G_UNLIKELY (g_list_find_custom (timeline->tracks, (gconstpointer) track,
771 (GCompareFunc) custom_find_track))) {
772 GST_WARNING ("Track is already controlled by this timeline");
776 /* Add the track to ourself (as a GstBin)
777 * Reference is stolen ! */
778 if (G_UNLIKELY (!gst_bin_add (GST_BIN (timeline), GST_ELEMENT (track)))) {
779 GST_WARNING ("Couldn't add track to ourself (GST)");
783 priv = g_new0 (TrackPrivate, 1);
784 priv->timeline = timeline;
787 /* Add the track to the list of tracks we track */
788 timeline->tracks = g_list_append (timeline->tracks, priv);
790 /* Listen to pad-added/-removed */
791 g_signal_connect (track, "pad-added", (GCallback) pad_added_cb, priv);
792 g_signal_connect (track, "pad-removed", (GCallback) pad_removed_cb, priv);
794 /* Inform the track that it's currently being used by ourself */
795 ges_track_set_timeline (track, timeline);
797 GST_DEBUG ("Done adding track, emitting 'track-added' signal");
799 /* emit 'track-added' */
800 g_signal_emit (timeline, ges_timeline_signals[TRACK_ADDED], 0, track);
802 /* ensure that each existing timeline object has the opportunity to create a
803 * track object for this track*/
805 for (tmp = timeline->layers; tmp; tmp = tmp->next) {
806 GList *objects, *obj;
807 objects = ges_timeline_layer_get_objects (tmp->data);
809 for (obj = objects; obj; obj = obj->next) {
810 add_object_to_track (obj->data, track);
811 g_object_unref (obj->data);
814 g_list_free (objects);
821 * ges_timeline_remove_track:
822 * @timeline: a #GESTimeline
823 * @track: the #GESTrack to remove
825 * Remove the @track from the @timeline. The reference stolen when adding the
826 * @track will be removed. If you wish to use the @track after calling this
827 * function you must ensure that you have a reference to it.
829 * Returns: TRUE if the @track was properly removed, else FALSE.
832 /* FIXME: release any track objects associated with this layer. currenly this
833 * will not happen if you remove the track before removing *all*
834 * timelineobjects which have a track object in this track.
838 ges_timeline_remove_track (GESTimeline * timeline, GESTrack * track)
843 GST_DEBUG ("timeline:%p, track:%p", timeline, track);
845 if (G_UNLIKELY (!(tmp =
846 g_list_find_custom (timeline->tracks, (gconstpointer) track,
847 (GCompareFunc) custom_find_track)))) {
848 GST_WARNING ("Track doesn't belong to this timeline");
853 timeline->tracks = g_list_remove (timeline->tracks, priv);
855 ges_track_set_timeline (track, NULL);
857 /* Remove ghost pad */
858 if (priv->ghostpad) {
859 GST_DEBUG ("Removing ghostpad");
860 gst_pad_set_active (priv->ghostpad, FALSE);
861 gst_ghost_pad_set_target ((GstGhostPad *) priv->ghostpad, NULL);
862 gst_element_remove_pad (GST_ELEMENT (timeline), priv->ghostpad);
865 /* Remove pad-added/-removed handlers */
866 g_signal_handlers_disconnect_by_func (track, pad_added_cb, priv);
867 g_signal_handlers_disconnect_by_func (track, pad_removed_cb, priv);
869 /* Signal track removal to all layers/objects */
870 g_signal_emit (timeline, ges_timeline_signals[TRACK_REMOVED], 0, track);
872 /* remove track from our bin */
873 gst_object_ref (track);
874 if (G_UNLIKELY (!gst_bin_remove (GST_BIN (timeline), GST_ELEMENT (track)))) {
875 GST_WARNING ("Couldn't remove track to ourself (GST)");
876 gst_object_unref (track);
880 /* set track state to NULL */
882 gst_element_set_state (GST_ELEMENT (track), GST_STATE_NULL);
884 gst_object_unref (track);
892 * ges_timeline_get_track_for_pad:
893 * @timeline: The #GESTimeline
896 * Search the #GESTrack corresponding to the given @timeline's @pad.
898 * Returns: The corresponding #GESTrack if it is found, or #NULL if there is
903 ges_timeline_get_track_for_pad (GESTimeline * timeline, GstPad * pad)
907 for (tmp = timeline->tracks; tmp; tmp = g_list_next (tmp)) {
908 TrackPrivate *priv = (TrackPrivate *) tmp->data;
909 if (pad == priv->ghostpad)
917 * ges_timeline_get_tracks:
918 * @timeline: a #GESTimeline
920 * Returns the list of #GESTrack used by the Timeline.
922 * Returns: A list of #GESTrack. The caller should unref each track
923 * once he is done with them.
926 ges_timeline_get_tracks (GESTimeline * timeline)
928 GList *tmp, *res = NULL;
930 for (tmp = timeline->tracks; tmp; tmp = g_list_next (tmp)) {
931 TrackPrivate *priv = (TrackPrivate *) tmp->data;
932 res = g_list_append (res, g_object_ref (priv->track));