diff -u -u -r1.24 Makefile.am
--- ext/vorbis/Makefile.am	22 Nov 2005 11:33:07 -0000	1.24
+++ ext/vorbis/Makefile.am	19 May 2006 03:58:37 -0000
@@ -1,7 +1,7 @@
 plugin_LTLIBRARIES = libgstvorbis.la
 
 libgstvorbis_la_SOURCES = vorbis.c \
-	vorbisdec.c vorbisenc.c vorbisparse.c
+	vorbisdec.c vorbisenc.c vorbisparse.c vorbistag.c
 libgstvorbis_la_CFLAGS = $(GST_CFLAGS) $(VORBIS_CFLAGS) 
 
 ## AM_PATH_VORBIS also sets VORBISENC_LIBS
@@ -12,4 +12,4 @@
 	$(GST_LIBS) \
 	$(VORBIS_LIBS) $(VORBISENC_LIBS)
 
-noinst_HEADERS = vorbisenc.h vorbisdec.h vorbisparse.h
+noinst_HEADERS = vorbisenc.h vorbisdec.h vorbisparse.h vorbistag.h
diff -u -u -r1.32 vorbis.c
--- ext/vorbis/vorbis.c	7 Feb 2006 18:32:00 -0000	1.32
+++ ext/vorbis/vorbis.c	19 May 2006 03:58:37 -0000
@@ -26,10 +26,12 @@
 #include "vorbisenc.h"
 #include "vorbisdec.h"
 #include "vorbisparse.h"
+#include "vorbistag.h"
 
 GST_DEBUG_CATEGORY (vorbisenc_debug);
 GST_DEBUG_CATEGORY (vorbisdec_debug);
 GST_DEBUG_CATEGORY (vorbisparse_debug);
+GST_DEBUG_CATEGORY (vorbistag_debug);
 
 static gboolean
 plugin_init (GstPlugin * plugin)
@@ -46,12 +48,18 @@
           gst_vorbis_parse_get_type ()))
     return FALSE;
 
+  if (!gst_element_register (plugin, "vorbistag", GST_RANK_NONE,
+          gst_vorbis_tag_get_type ()))
+    return FALSE;
+
   GST_DEBUG_CATEGORY_INIT (vorbisenc_debug, "vorbisenc", 0,
       "vorbis encoding element");
   GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0,
       "vorbis decoding element");
   GST_DEBUG_CATEGORY_INIT (vorbisparse_debug, "vorbisparse", 0,
       "vorbis parsing element");
+  GST_DEBUG_CATEGORY_INIT (vorbistag_debug, "vorbistag", 0,
+      "vorbis tagging element");
 
   gst_tag_register_musicbrainz_tags ();
 
--- /dev/null	2006-05-17 03:49:49.000000000 +1000
+++ ext/vorbis/vorbistag.h	2006-05-19 12:58:06.000000000 +1000
@@ -0,0 +1,65 @@
+/* -*- c-basic-offset: 2 -*-
+ * GStreamer
+ * Copyright (C) <2006> James Livingston <doclivingston@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_VORBIS_TAG_H__
+#define __GST_VORBIS_TAG_H__
+
+#include "vorbisparse.h"
+
+
+G_BEGIN_DECLS
+
+
+#define GST_TYPE_VORBIS_TAG \
+  (gst_vorbis_tag_get_type())
+#define GST_VORBIS_TAG(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VORBIS_TAG,GstVorbisTag))
+#define GST_VORBIS_TAG_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VORBIS_TAG,GstVorbisTag))
+#define GST_IS_VORBIS_TAG(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VORBIS_TAG))
+#define GST_IS_VORBIS_TAG_CLASS(obj) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VORBIS_TAG))
+
+
+typedef struct _GstVorbisTag GstVorbisTag;
+typedef struct _GstVorbisTagClass GstVorbisTagClass;
+
+/**
+ * GstVorbisTag:
+ *
+ * Opaque data structure.
+ */
+struct _GstVorbisTag {
+  GstVorbisParse        parse;
+
+  GstPadChainFunction   parent_chain;
+};
+
+struct _GstVorbisTagClass {
+  GstVorbisParseClass parent_class;
+};
+
+GType gst_vorbis_tag_get_type(void);
+
+G_END_DECLS
+
+#endif /* __GST_VORBIS_TAG_H__ */
--- /dev/null	2006-05-17 03:49:49.000000000 +1000
+++ ext/vorbis/vorbistag.c	2006-05-19 15:05:55.000000000 +1000
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2006 James Livingston <doclivingston@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <gst/tag/tag.h>
+#include <gst/gsttagsetter.h>
+
+#include <vorbis/codec.h>
+
+#include "vorbistag.h"
+
+
+GST_DEBUG_CATEGORY_EXTERN (vorbisparse_debug);
+#define GST_CAT_DEFAULT vorbisparse_debug
+
+static void gst_vorbis_tag_base_init (gpointer g_class);
+static void gst_vorbis_tag_class_init (GstVorbisTagClass *klass);
+static void gst_vorbis_tag_init (GstVorbisTag *tagger, GstVorbisTagClass *g_class);
+
+static GstFlowReturn gst_vorbis_tag_chain (GstPad *pad, GstBuffer *buffer);
+
+#define _do_init(type)                                                          \
+  G_STMT_START{                                                                 \
+    static const GInterfaceInfo tag_setter_info = {                             \
+      NULL,                                                                     \
+      NULL,                                                                     \
+      NULL                                                                      \
+    };                                                                          \
+    g_type_add_interface_static (type, GST_TYPE_TAG_SETTER,                     \
+                                 &tag_setter_info);                             \
+  }G_STMT_END
+
+GST_BOILERPLATE_FULL (GstVorbisTag, gst_vorbis_tag, GstElement,
+    GST_TYPE_VORBIS_PARSE, _do_init);
+
+static GstElementDetails vorbis_tag_details = {
+  "VorbisTag",
+  "Formatter/Metadata",
+  "Retags vorbis streams",
+  "James Livingston <doclivingston@gmail.com>"
+};
+
+
+static void
+gst_vorbis_tag_base_init (gpointer g_class)
+{
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+  gst_element_class_set_details (element_class, &vorbis_tag_details);
+}
+
+static void
+gst_vorbis_tag_class_init (GstVorbisTagClass * klass)
+{
+  /*GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);*/
+}
+
+static void
+gst_vorbis_tag_init (GstVorbisTag *tagger, GstVorbisTagClass * g_class)
+{
+  /* override vorbisparse's chain function */
+  tagger->parent_chain = GST_VORBIS_PARSE(tagger)->sinkpad->chainfunc;
+  gst_pad_set_chain_function (GST_VORBIS_PARSE(tagger)->sinkpad, gst_vorbis_tag_chain);
+}
+
+static GstFlowReturn
+gst_vorbis_tag_chain (GstPad *pad, GstBuffer *buffer)
+{
+  GstVorbisTag *tagger;
+  ogg_packet packet;
+  const GstTagList *user_tags;
+  GstTagList *old_tags, *new_tags;
+  gchar *encoder = NULL;
+  GstBuffer *new_buf;
+
+  tagger = GST_VORBIS_TAG (GST_PAD_PARENT (pad));
+
+  packet.packet = GST_BUFFER_DATA (buffer);
+
+  /* just pass everything except the comments packet */
+  if (packet.packet[0] != 0x03) {
+    return tagger->parent_chain (pad, buffer);
+  }
+
+  old_tags = gst_tag_list_from_vorbiscomment_buffer (buffer, (guint8 *) "\003vorbis", 7, &encoder);
+  user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (tagger));
+ 
+  /* build new tag list */
+  new_tags = gst_tag_list_merge (user_tags, old_tags,
+                                 gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (tagger)));
+  gst_tag_list_free (old_tags);
+
+  new_buf = gst_tag_list_to_vorbiscomment_buffer (new_tags, (guint8 *) "\003vorbis", 7, encoder);
+ 
+  GST_BUFFER_OFFSET (new_buf) = GST_BUFFER_OFFSET (buffer);
+  GST_BUFFER_OFFSET_END (new_buf) = GST_BUFFER_OFFSET_END (buffer);
+  GST_BUFFER_DURATION (new_buf) = GST_BUFFER_DURATION (buffer);
+  GST_BUFFER_TIMESTAMP (new_buf) = GST_BUFFER_TIMESTAMP (buffer);
+
+  gst_tag_list_free (new_tags);
+  g_free (encoder);
+  gst_buffer_unref (buffer);
+
+  return tagger->parent_chain (pad, new_buf);
+}
+
