plugins:ges: Fix pushing tags after e8c782d119eccf364fa24812cdc90c40f60d65d6
authorThibault Saunier <tsaunier@igalia.com>
Mon, 10 Feb 2020 21:00:33 +0000 (18:00 -0300)
committerThibault Saunier <tsaunier@igalia.com>
Wed, 12 Feb 2020 20:50:37 +0000 (17:50 -0300)
Basically the tags we send before STREAM_START are now ignored, meaning
that we could not detect nested timelines anymore, this commits makes
sure that we send our tag event after getting pushing STREAM_START.

plugins/ges/gesbasebin.c
plugins/ges/gesdemux.c

index faf11bd..3b0abbc 100644 (file)
@@ -145,6 +145,43 @@ ges_base_bin_init (GESBaseBin * self)
   priv->flow_combiner = gst_flow_combiner_new ();
 }
 
+static gboolean
+ges_base_bin_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_STREAM_START:
+    {
+      const gchar *stream_id;
+      gchar *new_stream_id;
+      guint stream_group;
+      GstTagList *tlist = gst_tag_list_new ("is-ges-timeline", TRUE, NULL);
+      GstPad *peer = gst_pad_get_peer (pad);
+
+      gst_event_parse_stream_start (event, &stream_id);
+      gst_event_parse_group_id (event, &stream_group);
+      new_stream_id =
+          gst_pad_create_stream_id (peer,
+          GST_ELEMENT (GST_OBJECT_PARENT (parent)), stream_id);
+      gst_event_unref (event);
+      gst_object_unref (peer);
+
+      event = gst_event_new_stream_start (new_stream_id);
+      gst_event_set_group_id (event, stream_group);
+      g_free (new_stream_id);
+
+      gst_pad_event_default (pad, parent, event);
+
+      gst_tag_list_set_scope (tlist, GST_TAG_SCOPE_GLOBAL);
+
+      return gst_pad_send_event (pad, gst_event_new_tag (tlist));
+    }
+    default:
+      break;
+  }
+
+  return gst_pad_event_default (pad, parent, event);
+}
+
 static GstFlowReturn
 ges_base_bin_src_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
 {
@@ -242,6 +279,7 @@ ges_base_bin_set_timeline (GESBaseBin * self, GESTimeline * timeline)
     proxy_pad = GST_PAD (gst_proxy_pad_get_internal (GST_PROXY_PAD (gpad)));
     gst_flow_combiner_add_pad (priv->flow_combiner, proxy_pad);
     gst_pad_set_chain_function (proxy_pad, ges_base_bin_src_chain);
+    gst_pad_set_event_function (proxy_pad, ges_base_bin_event);
     gst_object_unref (proxy_pad);
     GST_DEBUG_OBJECT (sbin, "Adding pad: %" GST_PTR_FORMAT, gpad);
   }
index 3a02dd8..29afb11 100644 (file)
@@ -271,75 +271,40 @@ static gboolean
 ges_demux_src_probe (GstPad * pad, GstPadProbeInfo * info, GstElement * parent)
 {
   GESDemux *self = GES_DEMUX (parent);
-  GstEvent *event;
-
-  if (info->type & (GST_PAD_PROBE_TYPE_QUERY_UPSTREAM)) {
-    GstQuery *query = info->data;
-
-    if (GST_QUERY_TYPE (query) == GST_QUERY_CUSTOM) {
-      GstStructure *structure =
-          (GstStructure *) gst_query_get_structure (query);
-
-      if (gst_structure_has_name (structure,
-              "NleCompositionQueryNeedsTearDown")) {
-        GstQuery *uri_query = gst_query_new_uri ();
-
-        if (gst_pad_peer_query (self->sinkpad, uri_query)) {
-          gchar *upstream_uri = NULL;
-          GStatBuf stats;
-          gst_query_parse_uri (uri_query, &upstream_uri);
-
-          if (gst_uri_has_protocol (upstream_uri, "file")) {
-            gchar *location = gst_uri_get_location (upstream_uri);
-
-            g_stat (location, &stats);
-            g_free (location);
-            GST_OBJECT_LOCK (self);
-            if (g_strcmp0 (upstream_uri, self->upstream_uri)
-                || stats.st_mtime != self->stats.st_mtime
-                || stats.st_size != self->stats.st_size) {
-              GST_INFO_OBJECT (self,
-                  "Underlying file changed, asking for an update");
-              gst_structure_set (structure, "result", G_TYPE_BOOLEAN, TRUE,
-                  NULL);
-              g_free (self->upstream_uri);
-              self->upstream_uri = upstream_uri;
-              self->stats = stats;
-            } else {
-              g_free (upstream_uri);
-            }
-            GST_OBJECT_UNLOCK (self);
-          }
+  GstStructure *structure =
+      (GstStructure *) gst_query_get_structure (info->data);
+
+  if (gst_structure_has_name (structure, "NleCompositionQueryNeedsTearDown")) {
+    GstQuery *uri_query = gst_query_new_uri ();
+
+    if (gst_pad_peer_query (self->sinkpad, uri_query)) {
+      gchar *upstream_uri = NULL;
+      GStatBuf stats;
+      gst_query_parse_uri (uri_query, &upstream_uri);
+
+      if (gst_uri_has_protocol (upstream_uri, "file")) {
+        gchar *location = gst_uri_get_location (upstream_uri);
+
+        g_stat (location, &stats);
+        g_free (location);
+        GST_OBJECT_LOCK (self);
+        if (g_strcmp0 (upstream_uri, self->upstream_uri)
+            || stats.st_mtime != self->stats.st_mtime
+            || stats.st_size != self->stats.st_size) {
+          GST_INFO_OBJECT (self,
+              "Underlying file changed, asking for an update");
+          gst_structure_set (structure, "result", G_TYPE_BOOLEAN, TRUE, NULL);
+          g_free (self->upstream_uri);
+          self->upstream_uri = upstream_uri;
+          self->stats = stats;
+        } else {
+          g_free (upstream_uri);
         }
-        gst_query_unref (uri_query);
+        GST_OBJECT_UNLOCK (self);
       }
     }
-
-    return GST_PAD_PROBE_OK;
-  }
-  event = info->data;
-  switch (GST_EVENT_TYPE (event)) {
-    case GST_EVENT_STREAM_START:
-    {
-      const gchar *stream_id;
-      gchar *new_stream_id;
-      guint stream_group;
-
-      gst_event_parse_stream_start (event, &stream_id);
-      gst_event_parse_group_id (event, &stream_group);
-      new_stream_id =
-          gst_pad_create_stream_id (pad, GST_ELEMENT (parent), stream_id);
-      gst_event_unref (event);
-
-      event = gst_event_new_stream_start (new_stream_id);
-      gst_event_set_group_id (event, stream_group);
-      g_free (new_stream_id);
-      break;
-    }
-    default:
-      break;
+    gst_query_unref (uri_query);
   }
-  info->data = event;
 
   return GST_PAD_PROBE_OK;
 }
@@ -348,14 +313,9 @@ static gboolean
 ges_demux_set_srcpad_probe (GstElement * element, GstPad * pad,
     gpointer user_data)
 {
-  GstTagList *tlist = gst_tag_list_new ("is-ges-timeline", TRUE, NULL);
-
   gst_pad_add_probe (pad,
-      GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | GST_PAD_PROBE_TYPE_QUERY_UPSTREAM,
+      GST_PAD_PROBE_TYPE_QUERY_UPSTREAM,
       (GstPadProbeCallback) ges_demux_src_probe, element, NULL);
-
-  gst_tag_list_set_scope (tlist, GST_TAG_SCOPE_GLOBAL);
-  gst_pad_push_event (pad, gst_event_new_tag (tlist));
   return TRUE;
 }