From 1cc5221d49965b197b30f58e0ad9715b910675c0 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Thu, 5 Mar 2020 19:00:20 +0000 Subject: [PATCH] pipeline: don't link tracks unnecessarily Unless the pipeline is in certain modes, we do not want to try and link every track. The previous debug message implied this, but the method did not actually end early. Also, we always end early if we receive a track that is neither video nor audio. --- ges/ges-pipeline.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/ges/ges-pipeline.c b/ges/ges-pipeline.c index d3292f8dbd..b4c56f6f86 100644 --- a/ges/ges-pipeline.c +++ b/ges/ges-pipeline.c @@ -780,6 +780,7 @@ _link_track (GESPipeline * self, GESTrack * track) GstCaps *caps; GstPadLinkReturn lret; gboolean reconfigured = FALSE; + gboolean ignore; pad = ges_timeline_get_pad_for_track (self->priv->timeline, track); if (G_UNLIKELY (!pad)) { @@ -799,21 +800,28 @@ _link_track (GESPipeline * self, GESTrack * track) * video or text tracks. Also provide a way to switch between these. */ /* Don't connect track if it's not going to be used */ - if (track->type == GES_TRACK_TYPE_VIDEO && - !(self->priv->mode & GES_PIPELINE_MODE_PREVIEW_VIDEO) && - !(self->priv->mode & GES_PIPELINE_MODE_RENDER) && - !(self->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)) { - GST_DEBUG_OBJECT (self, "Video track... but we don't need it. Not linking"); - /* FIXME: why are we not returning early at this point? */ + ignore = TRUE; + /* only support audio and video. Technically, preview mode could support + * text quite easily, but this isn't yet the case for rendering using + * encodebin */ + if (track->type == GES_TRACK_TYPE_AUDIO || + track->type == GES_TRACK_TYPE_VIDEO) { + if (IN_RENDERING_MODE (self)) + ignore = FALSE; + else if (track->type == GES_TRACK_TYPE_VIDEO && + self->priv->mode & GES_PIPELINE_MODE_PREVIEW_VIDEO) + ignore = FALSE; + else if (track->type == GES_TRACK_TYPE_AUDIO && + self->priv->mode & GES_PIPELINE_MODE_PREVIEW_AUDIO) + ignore = FALSE; } - if (track->type == GES_TRACK_TYPE_AUDIO && - !(self->priv->mode & GES_PIPELINE_MODE_PREVIEW_AUDIO) && - !(self->priv->mode & GES_PIPELINE_MODE_RENDER) && - !(self->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)) { - GST_DEBUG_OBJECT (self, "Audio track... but we don't need it. Not linking"); - /* FIXME: why are we not returning early at this point? */ + + if (ignore) { + gst_object_unref (pad); + GST_DEBUG_OBJECT (self, "Ignoring track (type %u). Not linking", + track->type); + return; } - /* FIXME: what about text and custom tracks? */ /* Get an existing chain or create it */ if (!(chain = get_output_chain_for_track (self, track)))