plugins:ges: Fix pushing tags after e8c782d119

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.
This commit is contained in:
Thibault Saunier 2020-02-10 18:00:33 -03:00
parent 3c3176516e
commit f30b7f05b5
2 changed files with 65 additions and 67 deletions

View file

@ -145,6 +145,43 @@ ges_base_bin_init (GESBaseBin * self)
priv->flow_combiner = gst_flow_combiner_new (); 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 static GstFlowReturn
ges_base_bin_src_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) 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))); proxy_pad = GST_PAD (gst_proxy_pad_get_internal (GST_PROXY_PAD (gpad)));
gst_flow_combiner_add_pad (priv->flow_combiner, proxy_pad); 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_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_object_unref (proxy_pad);
GST_DEBUG_OBJECT (sbin, "Adding pad: %" GST_PTR_FORMAT, gpad); GST_DEBUG_OBJECT (sbin, "Adding pad: %" GST_PTR_FORMAT, gpad);
} }

View file

@ -271,75 +271,40 @@ static gboolean
ges_demux_src_probe (GstPad * pad, GstPadProbeInfo * info, GstElement * parent) ges_demux_src_probe (GstPad * pad, GstPadProbeInfo * info, GstElement * parent)
{ {
GESDemux *self = GES_DEMUX (parent); GESDemux *self = GES_DEMUX (parent);
GstEvent *event; GstStructure *structure =
(GstStructure *) gst_query_get_structure (info->data);
if (info->type & (GST_PAD_PROBE_TYPE_QUERY_UPSTREAM)) { if (gst_structure_has_name (structure, "NleCompositionQueryNeedsTearDown")) {
GstQuery *query = info->data; GstQuery *uri_query = gst_query_new_uri ();
if (GST_QUERY_TYPE (query) == GST_QUERY_CUSTOM) { if (gst_pad_peer_query (self->sinkpad, uri_query)) {
GstStructure *structure = gchar *upstream_uri = NULL;
(GstStructure *) gst_query_get_structure (query); GStatBuf stats;
gst_query_parse_uri (uri_query, &upstream_uri);
if (gst_structure_has_name (structure, if (gst_uri_has_protocol (upstream_uri, "file")) {
"NleCompositionQueryNeedsTearDown")) { gchar *location = gst_uri_get_location (upstream_uri);
GstQuery *uri_query = gst_query_new_uri ();
if (gst_pad_peer_query (self->sinkpad, uri_query)) { g_stat (location, &stats);
gchar *upstream_uri = NULL; g_free (location);
GStatBuf stats; GST_OBJECT_LOCK (self);
gst_query_parse_uri (uri_query, &upstream_uri); if (g_strcmp0 (upstream_uri, self->upstream_uri)
|| stats.st_mtime != self->stats.st_mtime
if (gst_uri_has_protocol (upstream_uri, "file")) { || stats.st_size != self->stats.st_size) {
gchar *location = gst_uri_get_location (upstream_uri); GST_INFO_OBJECT (self,
"Underlying file changed, asking for an update");
g_stat (location, &stats); gst_structure_set (structure, "result", G_TYPE_BOOLEAN, TRUE, NULL);
g_free (location); g_free (self->upstream_uri);
GST_OBJECT_LOCK (self); self->upstream_uri = upstream_uri;
if (g_strcmp0 (upstream_uri, self->upstream_uri) self->stats = stats;
|| stats.st_mtime != self->stats.st_mtime } else {
|| stats.st_size != self->stats.st_size) { g_free (upstream_uri);
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);
}
} }
gst_query_unref (uri_query); GST_OBJECT_UNLOCK (self);
} }
} }
gst_query_unref (uri_query);
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;
}
info->data = event;
return GST_PAD_PROBE_OK; return GST_PAD_PROBE_OK;
} }
@ -348,14 +313,9 @@ static gboolean
ges_demux_set_srcpad_probe (GstElement * element, GstPad * pad, ges_demux_set_srcpad_probe (GstElement * element, GstPad * pad,
gpointer user_data) gpointer user_data)
{ {
GstTagList *tlist = gst_tag_list_new ("is-ges-timeline", TRUE, NULL);
gst_pad_add_probe (pad, 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); (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; return TRUE;
} }