gstclapper: Merge global tags instead replacing them

There is no guarantee that received later tags also contain values from
earlier ones, as they might come from different element.
Combine them instead while replacing old values with newer ones.
This commit is contained in:
Rafał Dzięgiel
2021-12-02 08:52:07 +01:00
parent 810aea476f
commit 50aac8cdd8

View File

@@ -1865,6 +1865,15 @@ media_info_update (GstClapper * self, GstClapperMediaInfo * info)
"image_sample: %p", info->title, info->container, info->image_sample);
}
static void
merge_tags (GstTagList **my_tags, GstTagList *tags)
{
if (*my_tags)
gst_tag_list_insert (*my_tags, tags, GST_TAG_MERGE_REPLACE);
else
*my_tags = gst_tag_list_ref (tags);
}
static void
tags_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg, gpointer user_data)
{
@@ -1880,17 +1889,12 @@ tags_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg, gpointer user_data)
if (gst_tag_list_get_scope (tags) == GST_TAG_SCOPE_GLOBAL) {
g_mutex_lock (&self->lock);
if (self->media_info) {
if (self->media_info->tags)
gst_tag_list_unref (self->media_info->tags);
self->media_info->tags = gst_tag_list_ref (tags);
merge_tags (&self->media_info->tags, tags);
media_info_update (self, self->media_info);
g_mutex_unlock (&self->lock);
} else {
if (self->global_tags)
gst_tag_list_unref (self->global_tags);
self->global_tags = gst_tag_list_ref (tags);
g_mutex_unlock (&self->lock);
merge_tags (&self->global_tags, tags);
}
g_mutex_unlock (&self->lock);
}
gst_tag_list_unref (tags);