From 5234885c8a86c113fdc243e6a66f70a37b00fac3 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 17 Oct 2019 16:19:11 +0200 Subject: [PATCH] pipeline: Be smarter about how we match encoding profiles and tracks --- ges/ges-pipeline.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/ges/ges-pipeline.c b/ges/ges-pipeline.c index 6dd5316..a30b12b 100644 --- a/ges/ges-pipeline.c +++ b/ges/ges-pipeline.c @@ -1041,6 +1041,7 @@ ges_pipeline_set_render_settings (GESPipeline * pipeline, { GError *err = NULL; GstEncodingProfile *set_profile; + guint n_videotracks = 0, n_audiotracks = 0; g_return_val_if_fail (GES_IS_PIPELINE (pipeline), FALSE); CHECK_THREAD (pipeline); @@ -1056,21 +1057,27 @@ ges_pipeline_set_render_settings (GESPipeline * pipeline, GList *tmptrack, *tracks = ges_timeline_get_tracks (pipeline->priv->timeline); - for (; tmpprofiles; tmpprofiles = tmpprofiles->next) { - for (tmptrack = tracks; tmptrack; tmptrack = tmptrack->next) { - if ((GST_IS_ENCODING_AUDIO_PROFILE (tmpprofiles->data) && - GES_IS_AUDIO_TRACK (tmptrack->data)) || - (GST_IS_ENCODING_VIDEO_PROFILE (tmpprofiles->data) && - GES_IS_VIDEO_TRACK (tmptrack->data))) { - GST_DEBUG_OBJECT (pipeline, "Setting presence to 1!"); - gst_encoding_profile_set_presence (tmpprofiles->data, 1); - gst_encoding_profile_set_allow_dynamic_output (tmpprofiles->data, - FALSE); - } - } + for (tmptrack = tracks; tmptrack; tmptrack = tmptrack->next) { + if (GES_IS_AUDIO_TRACK (tmptrack->data)) + n_audiotracks++; + else if (GES_IS_VIDEO_TRACK (tmptrack->data)) + n_videotracks++; } - g_list_free_full (tracks, gst_object_unref); + + for (; tmpprofiles; tmpprofiles = tmpprofiles->next) { + if ((GST_IS_ENCODING_AUDIO_PROFILE (tmpprofiles->data) && n_audiotracks)) + n_audiotracks--; + else if ((GST_IS_ENCODING_VIDEO_PROFILE (tmpprofiles->data) + && n_videotracks)) + n_videotracks--; + else + continue; + + GST_DEBUG_OBJECT (pipeline, "Setting presence to 1!"); + gst_encoding_profile_set_presence (tmpprofiles->data, 1); + gst_encoding_profile_set_allow_dynamic_output (tmpprofiles->data, FALSE); + } } /* Clear previous URI sink if it existed */ -- 2.7.4