matroskaparse: send global tags
authorRamiro Polla <ramiro.polla@collabora.co.uk>
Sat, 14 Mar 2015 16:07:05 +0000 (17:07 +0100)
committerThiago Santos <thiagoss@osg.samsung.com>
Sat, 28 Mar 2015 13:24:57 +0000 (10:24 -0300)
Global tags are already being read in matroskaparse, but they are not
currently being sent.

This patch makes global tags get sent incrementally whenever new ones
are found.

https://bugzilla.gnome.org/show_bug.cgi?id=746242

gst/matroska/matroska-parse.c
gst/matroska/matroska-read-common.c
gst/matroska/matroska-read-common.h

index 1e86a25..0e36613 100644 (file)
@@ -1071,6 +1071,27 @@ gst_matroska_parse_handle_src_query (GstPad * pad, GstObject * parent,
   return ret;
 }
 
+static void
+gst_matroska_parse_send_tags (GstMatroskaParse * parse)
+{
+  if (G_UNLIKELY (parse->common.global_tags_changed)) {
+    GstEvent *tag_event;
+    gst_tag_list_add (parse->common.global_tags, GST_TAG_MERGE_REPLACE,
+        GST_TAG_CONTAINER_FORMAT, "Matroska", NULL);
+    GST_DEBUG_OBJECT (parse, "Sending global_tags %p : %" GST_PTR_FORMAT,
+        parse->common.global_tags, parse->common.global_tags);
+
+    /* Send a copy as we want to keep our local ref writable to add more tags
+     * if any are found */
+    tag_event =
+        gst_event_new_tag (gst_tag_list_copy (parse->common.global_tags));
+
+    gst_pad_push_event (parse->srcpad, tag_event);
+
+    parse->common.global_tags_changed = FALSE;
+  }
+}
+
 /* returns FALSE if there are no pads to deliver event to,
  * otherwise TRUE (whatever the outcome of event sending),
  * takes ownership of the passed event! */
@@ -2567,6 +2588,8 @@ gst_matroska_parse_parse_id (GstMatroskaParse * parse, guint32 id,
           if (!parse->common.segmentinfo_parsed) {
             ret = gst_matroska_read_common_parse_info (&parse->common,
                 GST_ELEMENT_CAST (parse), &ebml);
+            if (ret == GST_FLOW_OK)
+              gst_matroska_parse_send_tags (parse);
           }
           gst_matroska_parse_accumulate_streamheader (parse, ebml.buf);
           break;
@@ -2660,6 +2683,8 @@ gst_matroska_parse_parse_id (GstMatroskaParse * parse, guint32 id,
           if (!parse->common.attachments_parsed) {
             ret = gst_matroska_read_common_parse_attachments (&parse->common,
                 GST_ELEMENT_CAST (parse), &ebml);
+            if (ret == GST_FLOW_OK)
+              gst_matroska_parse_send_tags (parse);
           }
           gst_matroska_parse_output (parse, ebml.buf, FALSE);
           break;
@@ -2667,6 +2692,8 @@ gst_matroska_parse_parse_id (GstMatroskaParse * parse, guint32 id,
           GST_READ_CHECK (gst_matroska_parse_take (parse, read, &ebml));
           ret = gst_matroska_read_common_parse_metadata (&parse->common,
               GST_ELEMENT_CAST (parse), &ebml);
+          if (ret == GST_FLOW_OK)
+            gst_matroska_parse_send_tags (parse);
           gst_matroska_parse_accumulate_streamheader (parse, ebml.buf);
           break;
         case GST_MATROSKA_ID_CHAPTERS:
index 59feb9c..8d35690 100644 (file)
@@ -452,6 +452,7 @@ gst_matroska_read_common_found_global_tag (GstMatroskaReadCommon * common,
   } else {
     common->global_tags = taglist;
   }
+  common->global_tags_changed = TRUE;
 }
 
 gint64
@@ -2923,6 +2924,7 @@ gst_matroska_read_common_reset (GstElement * element,
   ctx->chapters_parsed = FALSE;
 
   /* tags */
+  ctx->global_tags_changed = FALSE;
   g_list_foreach (ctx->tags_parsed,
       (GFunc) gst_matroska_read_common_free_parsed_el, NULL);
   g_list_free (ctx->tags_parsed);
index de21026..3be9542 100644 (file)
@@ -90,6 +90,7 @@ typedef struct _GstMatroskaReadCommon {
   GstSegment               segment;
 
   GstTagList              *global_tags;
+  gboolean                 global_tags_changed;
 
   /* pull mode caching */
   GstBuffer *cached_buffer;