From 37602d1d02c63d6be6fd70a3af6c1f04f6e271ed Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 4 Aug 2023 17:57:35 -0400 Subject: [PATCH] ges: Keep internal stream selection messages internally Timeline StreamCollection are very specific to inner working of nested timelines and should not interfere with the usual stream selection process and are now handled as element messages. Stream selection inside `nleobject` need to be handled internally by the application or GES itself so we should just drop all those as they would interfere and fail if they are exposed to other elements. Part-of: --- .../gst-editing-services/ges/ges-timeline.c | 18 ++++++---- .../gst-editing-services/ges/ges-track.c | 34 +++++++++++++++---- .../gst-editing-services/ges/ges-uri-asset.c | 2 +- .../plugins/nle/nleobject.c | 5 +++ 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/subprojects/gst-editing-services/ges/ges-timeline.c b/subprojects/gst-editing-services/ges/ges-timeline.c index 5cde76c134..678e6f4d9c 100644 --- a/subprojects/gst-editing-services/ges/ges-timeline.c +++ b/subprojects/gst-editing-services/ges/ges-timeline.c @@ -514,6 +514,16 @@ forward: GST_BIN_CLASS (parent_class)->handle_message (bin, message); } +static void +ges_timeline_post_stream_collection (GESTimeline * timeline) +{ + gst_element_post_message ((GstElement *) timeline, + gst_message_new_element ((GstObject *) timeline, + gst_structure_new ("ges-timeline-collection", "collection", + GST_TYPE_STREAM_COLLECTION, timeline->priv->stream_collection, + NULL))); +} + static GstStateChangeReturn ges_timeline_change_state (GstElement * element, GstStateChange transition) { @@ -524,9 +534,7 @@ ges_timeline_change_state (GstElement * element, GstStateChange transition) transition); if (transition == GST_STATE_CHANGE_READY_TO_PAUSED) - gst_element_post_message ((GstElement *) timeline, - gst_message_new_stream_collection ((GstObject *) timeline, - timeline->priv->stream_collection)); + ges_timeline_post_stream_collection (timeline); return res; } @@ -2894,9 +2902,7 @@ ges_timeline_commit (GESTimeline * timeline) UNLOCK_DYN (timeline); if (pcollection != timeline->priv->stream_collection) { - gst_element_post_message ((GstElement *) timeline, - gst_message_new_stream_collection ((GstObject *) timeline, - timeline->priv->stream_collection)); + ges_timeline_post_stream_collection (timeline); } ges_timeline_emit_snapping (timeline, NULL, NULL, GST_CLOCK_TIME_NONE); diff --git a/subprojects/gst-editing-services/ges/ges-track.c b/subprojects/gst-editing-services/ges/ges-track.c index 3e38aacae4..905ea2fb1f 100644 --- a/subprojects/gst-editing-services/ges/ges-track.c +++ b/subprojects/gst-editing-services/ges/ges-track.c @@ -488,17 +488,37 @@ ges_track_handle_message (GstBin * bin, GstMessage * message) { GESTrack *track = GES_TRACK (bin); - if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_COLLECTION) { - GstStreamCollection *collection; + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_STREAM_COLLECTION: + g_error ("Internal stream collection messages should be kept internal"); + break; + case GST_MESSAGE_ELEMENT: + { + const GstStructure *s = gst_message_get_structure (message); - gst_message_parse_stream_collection (message, &collection); - if (GES_IS_TIMELINE (GST_MESSAGE_SRC (message))) { - ges_track_select_subtimeline_streams (track, collection, - GST_ELEMENT (GST_MESSAGE_SRC (message))); + if (gst_structure_has_name (s, "ges-timeline-collection")) { + GstStreamCollection *collection; + + gst_structure_get (s, "collection", GST_TYPE_STREAM_COLLECTION, + &collection, NULL); + + ges_track_select_subtimeline_streams (track, collection, + GST_ELEMENT (GST_MESSAGE_SRC (message))); + + GST_INFO_OBJECT (bin, + "Handled ges-timeline-collection message, dropping"); + + gst_message_unref (message); + return; + } + + break; } + default: + break; } - gst_element_post_message (GST_ELEMENT_CAST (bin), message); + GST_BIN_CLASS (ges_track_parent_class)->handle_message (bin, message); } /* GObject virtual methods */ diff --git a/subprojects/gst-editing-services/ges/ges-uri-asset.c b/subprojects/gst-editing-services/ges/ges-uri-asset.c index 2e00e63adf..f756d7bcad 100644 --- a/subprojects/gst-editing-services/ges/ges-uri-asset.c +++ b/subprojects/gst-editing-services/ges/ges-uri-asset.c @@ -752,7 +752,7 @@ _extract (GESAsset * asset, GError ** error) GESUriSourceAssetPrivate *priv = GES_URI_SOURCE_ASSET (asset)->priv; if (GST_IS_DISCOVERER_STREAM_INFO (priv->sinfo) == FALSE) { - GST_WARNING_OBJECT (asset, "Can not extract as no strean info set"); + GST_WARNING_OBJECT (asset, "Can not extract as no stream info set"); return NULL; } diff --git a/subprojects/gst-editing-services/plugins/nle/nleobject.c b/subprojects/gst-editing-services/plugins/nle/nleobject.c index fcedd22fa8..a1085619e1 100644 --- a/subprojects/gst-editing-services/plugins/nle/nleobject.c +++ b/subprojects/gst-editing-services/plugins/nle/nleobject.c @@ -140,6 +140,11 @@ nle_bin_handle_message (GstBin * bin, GstMessage * message) return; } + } else if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_COLLECTION) { + GST_INFO_OBJECT (bin, "Dropping stream collection message, " + " those are internal to and should be kept as such"); + + return; } return GST_BIN_CLASS (parent_class)->handle_message (bin, message);