mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 15:22:11 +02:00
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:
20
lib/gst/clapper/gstclapper.c
vendored
20
lib/gst/clapper/gstclapper.c
vendored
@@ -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);
|
||||
|
Reference in New Issue
Block a user