matroska-mux: If a stream has a TITLE tag, use it for the name.
authorJan Schmidt <jan@centricular.com>
Sat, 26 Feb 2022 16:17:26 +0000 (03:17 +1100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 1 Mar 2022 13:17:40 +0000 (13:17 +0000)
If a title tag is pushed to a pad, store it as the Track name.
This means that players will use it as the human readable
description of the track, instead of something generic like 'Video'
or 'Subtitle'

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1798>

subprojects/gst-plugins-good/gst/matroska/matroska-mux.c

index 5d48b67..b9063ce 100644 (file)
@@ -865,12 +865,22 @@ gst_matroska_mux_handle_sink_event (GstCollectPads * pads,
         g_free (lang);
       }
 
-      /* FIXME: what about stream-specific tags? */
       if (gst_tag_list_get_scope (list) == GST_TAG_SCOPE_GLOBAL) {
         gst_tag_setter_merge_tags (GST_TAG_SETTER (mux), list,
             gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (mux)));
       } else {
+        gchar *title = NULL;
+
+        /* Stream specific tags */
         gst_tag_list_insert (collect_pad->tags, list, GST_TAG_MERGE_REPLACE);
+
+        /* If the tags contain a title, update the context name to write it there */
+        if (gst_tag_list_get_string (list, GST_TAG_TITLE, &title)) {
+          GST_INFO_OBJECT (pad, "Setting track name to '%s'", title);
+          g_free (context->name);
+          context->name = g_strdup (title);
+        }
+        g_free (title);
       }
 
       gst_event_unref (event);