summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@collabora.com>2014-02-17 13:33:51 +0100
committerThibault Saunier <thibault.saunier@collabora.com>2014-02-18 11:02:49 +0100
commite9ecfef80834a573fac4c0399fce67491de4e3e5 (patch)
tree519e635dd5802497669eda44fe323aab1b683db4
parentf921277ac20e3883d6817fc5e6464a9bdfba419f (diff)
timeline: Make sure not to add 2 times a TrackElement in the same track
Without that, if a UriClip contains several tracks of a same type (ie. video or audio...), we would add all the TrackElements to each track making everything failling as we end up with several GNL sources at the same position with the same priority.
-rw-r--r--ges/ges-timeline.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c
index 7357785a..d3bc3924 100644
--- a/ges/ges-timeline.c
+++ b/ges/ges-timeline.c
@@ -1944,7 +1944,9 @@ clip_track_element_added_cb (GESClip * clip,
{
guint i;
GESTrack *track;
+ gboolean is_source;
GPtrArray *tracks = NULL;
+ GESTrackElement *existing_src = NULL;
if (timeline->priv->ignore_track_element_added == clip) {
GST_DEBUG_OBJECT (timeline, "Ignoring element added (%" GST_PTR_FORMAT
@@ -1980,14 +1982,27 @@ clip_track_element_added_cb (GESClip * clip,
/* We add the current element to the first track */
track = g_ptr_array_index (tracks, 0);
- if (!ges_track_add_element (track, track_element)) {
- GST_WARNING_OBJECT (clip, "Failed to add track element to track");
+
+ is_source = g_type_is_a (G_OBJECT_TYPE (track_element), GES_TYPE_SOURCE);
+ if (is_source)
+ existing_src = ges_clip_find_track_element (clip, track, GES_TYPE_SOURCE);
+
+ if (existing_src == NULL) {
+ if (!ges_track_add_element (track, track_element)) {
+ GST_WARNING_OBJECT (clip, "Failed to add track element to track");
+ ges_container_remove (GES_CONTAINER (clip),
+ GES_TIMELINE_ELEMENT (track_element));
+ return;
+ }
+ } else {
+ GST_INFO_OBJECT (clip, "Already had a Source Element in %" GST_PTR_FORMAT
+ " of type %s, removing new one.", track,
+ G_OBJECT_TYPE_NAME (track_element));
ges_container_remove (GES_CONTAINER (clip),
GES_TIMELINE_ELEMENT (track_element));
- gst_object_unref (track_element);
- return;
}
gst_object_unref (track);
+ g_clear_object (&existing_src);
/* And create copies to add to other tracks */
timeline->priv->ignore_track_element_added = clip;
@@ -1996,6 +2011,22 @@ clip_track_element_added_cb (GESClip * clip,
GESTrackElement *track_element_copy;
track = g_ptr_array_index (tracks, i);
+ if (is_source)
+ existing_src = ges_clip_find_track_element (clip, track, GES_TYPE_SOURCE);
+ if (existing_src == NULL) {
+ ges_container_remove (GES_CONTAINER (clip),
+ GES_TIMELINE_ELEMENT (track_element));
+ gst_object_unref (track);
+ continue;
+ } else {
+ GST_INFO_OBJECT (clip, "Already had a Source Element in %" GST_PTR_FORMAT
+ " of type %s, removing new one.", track,
+ G_OBJECT_TYPE_NAME (track_element));
+ ges_container_remove (GES_CONTAINER (clip),
+ GES_TIMELINE_ELEMENT (track_element));
+ }
+ g_clear_object (&existing_src);
+
track_element_copy =
GES_TRACK_ELEMENT (ges_timeline_element_copy (GES_TIMELINE_ELEMENT
(track_element), TRUE));