[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    gst-plugins-good: wavparse: pass on tags from upstream if there are any
From:       tpm () kemper ! freedesktop ! org (Tim Müller)
Date:       2014-04-30 0:12:51
Message-ID: 20140430001251.B410E761E3 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-good
Branch: master
Commit: b1473491cf5bdd7ffe05ec6f22012d3bd31a44fc
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=b1473491cf5bdd7ffe05ec6f22012d3bd31a44fc


Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Wed Apr 30 01:08:41 2014 +0100

wavparse: pass on tags from upstream if there are any

Don't just ignore upstream tags from e.g. an ID3 tag before
the .wav data, pass them on downstream.

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

---

 gst/wavparse/gstwavparse.c |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c
index 83a74fb..8664798 100644
--- a/gst/wavparse/gstwavparse.c
+++ b/gst/wavparse/gstwavparse.c
@@ -1775,10 +1775,33 @@ gst_wavparse_have_dts_caps (const GstCaps * caps, \
GstTypeFindProbability prob)  return gst_structure_has_field (s, "rate");
 }
 
+static GstTagList *
+gst_wavparse_get_upstream_tags (GstWavParse * wav, GstTagScope scope)
+{
+  GstTagList *tags = NULL;
+  GstEvent *ev;
+  gint i;
+
+  i = 0;
+  while ((ev = gst_pad_get_sticky_event (wav->sinkpad, GST_EVENT_TAG, i++))) {
+    gst_event_parse_tag (ev, &tags);
+    if (tags != NULL && gst_tag_list_get_scope (tags) == scope) {
+      tags = gst_tag_list_copy (tags);
+      gst_tag_list_remove_tag (tags, GST_TAG_CONTAINER_FORMAT);
+      gst_event_unref (ev);
+      break;
+    }
+    tags = NULL;
+    gst_event_unref (ev);
+  }
+  return tags;
+}
+
 static void
 gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
 {
   GstStructure *s;
+  GstTagList *tags, *utags;
 
   GST_DEBUG_OBJECT (wav, "adding src pad");
 
@@ -1816,10 +1839,27 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
     wav->start_segment = NULL;
   }
 
-  if (wav->tags) {
-    gst_pad_push_event (wav->srcpad, gst_event_new_tag (wav->tags));
+  /* upstream tags, e.g. from id3/ape tag before the wav file; assume for now
+   * that there'll be only one scope/type of tag list from upstream, if any */
+  utags = gst_wavparse_get_upstream_tags (wav, GST_TAG_SCOPE_GLOBAL);
+  if (utags == NULL)
+    utags = gst_wavparse_get_upstream_tags (wav, GST_TAG_SCOPE_STREAM);
+
+  /* if there's a tag upstream it's probably been added to override the
+   * tags from inside the wav header, so keep upstream tags if in doubt */
+  tags = gst_tag_list_merge (utags, wav->tags, GST_TAG_MERGE_KEEP);
+
+  if (wav->tags != NULL) {
+    gst_tag_list_unref (wav->tags);
     wav->tags = NULL;
   }
+
+  if (utags != NULL)
+    gst_tag_list_unref (utags);
+
+  /* send tags downstream, if any */
+  if (tags != NULL)
+    gst_pad_push_event (wav->srcpad, gst_event_new_tag (tags));
 }
 
 static GstFlowReturn



_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic