discoverer: Prevent stream tags from leaking in global tags

The PrivateStream should keep track of stream tags only. Likewise, the
GstDiscovererInfo should keep track of global tags only.

This patch fixes the issue where the discoverer would report duplicated tag
titles, especially for Matroska media files. The Matroska demuxer emits
correctly-scoped tags, but downstream was making no distinction of them.

Fixes #598, #836, https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/827

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1275>
This commit is contained in:
Philippe Normand 2021-09-12 10:07:49 +01:00
parent f6aea043f9
commit a55dafe341

View file

@ -539,9 +539,17 @@ _event_probe (GstPad * pad, GstPadProbeInfo * info, PrivateStream * ps)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG:{
GstTagList *tl = NULL, *tmp;
GstTagScope scope;
gst_event_parse_tag (event, &tl);
scope = gst_tag_list_get_scope (tl);
GST_DEBUG_OBJECT (pad, "tags %" GST_PTR_FORMAT, tl);
if (scope != GST_TAG_SCOPE_STREAM) {
GST_DEBUG_OBJECT (pad, "Ignoring non-stream tags");
break;
}
DISCO_LOCK (ps->dc);
/* If preroll is complete, drop these tags - the collected information is
* possibly already being processed and adding more tags would be racy */
@ -1703,10 +1711,19 @@ handle_message (GstDiscoverer * dc, GstMessage * msg)
case GST_MESSAGE_TAG:
{
GstTagList *tl, *tmp;
GstTagList *tl, *tmp = NULL;
GstTagScope scope;
gst_message_parse_tag (msg, &tl);
scope = gst_tag_list_get_scope (tl);
GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), "Got tags %" GST_PTR_FORMAT, tl);
if (scope != GST_TAG_SCOPE_GLOBAL) {
GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), "Ignoring non-global tags");
gst_tag_list_unref (tl);
break;
}
/* Merge with current tags */
tmp =
gst_tag_list_merge (dc->priv->current_info->tags, tl,