From ee2b3f7d24fd59a53abdbe07ed95fdf5643881e7 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 28 Oct 2014 18:36:55 +0100 Subject: [PATCH] pipeline: connect tracks when added, not only on state change. + ghost track src pad before calling track added so that pipeline has a pad to link. + Remove silly comment. --- ges/ges-pipeline.c | 24 +++++++++++++++++++++++- ges/ges-timeline.c | 4 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ges/ges-pipeline.c b/ges/ges-pipeline.c index dd4f1b3..b1fb9b3 100644 --- a/ges/ges-pipeline.c +++ b/ges/ges-pipeline.c @@ -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)); diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index b87f198..c73864b 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -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); -- 2.7.4