pipeline: connect tracks when added, not only on state change.
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Tue, 28 Oct 2014 17:36:55 +0000 (18:36 +0100)
committerThibault Saunier <tsaunier@gnome.org>
Mon, 10 Nov 2014 15:22:42 +0000 (16:22 +0100)
+ ghost track src pad before calling track added so that
  pipeline has a pad to link.
+ Remove silly comment.

ges/ges-pipeline.c
ges/ges-timeline.c

index dd4f1b3..b1fb9b3 100644 (file)
@@ -201,6 +201,18 @@ ges_pipeline_set_property (GObject * object, guint property_id,
 }
 
 static void
+_timeline_track_added_cb (GESTimeline *timeline, GESTrack *track, GESPipeline *pipeline)
+{
+  _link_track (pipeline, track);
+}
+
+static void
+_timeline_track_removed_cb (GESTimeline *timeline, GESTrack *track, GESPipeline *pipeline)
+{
+  _unlink_track (pipeline, track);
+}
+
+static void
 ges_pipeline_dispose (GObject * object)
 {
   GESPipeline *self = GES_PIPELINE (object);
@@ -227,6 +239,13 @@ ges_pipeline_dispose (GObject * object)
     self->priv->profile = NULL;
   }
 
+  if (self->priv->timeline) {
+    g_signal_handlers_disconnect_by_func (self->priv->timeline,
+        _timeline_track_added_cb, self);
+    g_signal_handlers_disconnect_by_func (self->priv->timeline,
+        _timeline_track_removed_cb, self);
+  }
+
   G_OBJECT_CLASS (ges_pipeline_parent_class)->dispose (object);
 }
 
@@ -804,7 +823,6 @@ _unlink_track (GESPipeline * self, GESTrack * track)
     gst_object_unref (chain->playsinkpad);
   }
 
-  /* Unlike/remove tee */
   peer = gst_element_get_static_pad (chain->tee, "sink");
   gst_pad_unlink (pad, peer);
   gst_object_unref (peer);
@@ -846,6 +864,10 @@ ges_pipeline_set_timeline (GESPipeline * pipeline, GESTimeline * timeline)
   }
   pipeline->priv->timeline = timeline;
 
+  g_signal_connect (timeline, "track-added",
+      G_CALLBACK (_timeline_track_added_cb), pipeline);
+  g_signal_connect (timeline, "track-removed",
+      G_CALLBACK (_timeline_track_removed_cb), pipeline);
   /* FIXME Check if we should rollback if we can't sync state */
   gst_element_sync_state_with_parent (GST_ELEMENT (timeline));
 
index b87f198..c73864b 100644 (file)
@@ -2801,6 +2801,8 @@ ges_timeline_add_track (GESTimeline * timeline, GESTrack * track)
 
   GST_DEBUG ("Done adding track, emitting 'track-added' signal");
 
+  _ghost_track_srcpad (tr_priv);
+
   /* emit 'track-added' */
   g_signal_emit (timeline, ges_timeline_signals[TRACK_ADDED], 0, track);
 
@@ -2826,8 +2828,6 @@ ges_timeline_add_track (GESTimeline * timeline, GESTrack * track)
     g_list_free (objects);
   }
 
-  _ghost_track_srcpad (tr_priv);
-
   /* FIXME Check if we should rollback if we can't sync state */
   gst_element_sync_state_with_parent (GST_ELEMENT (track));
   g_object_set (track, "message-forward", TRUE, NULL);