Index: Makefile.am
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/soup/Makefile.am,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile.am
--- Makefile.am	15 Nov 2007 17:26:25 -0000	1.1
+++ Makefile.am	12 Dec 2007 10:58:03 -0000
@@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstsouphttpsrc.l
 
 libgstsouphttpsrc_la_SOURCES = gstsouphttpsrc.c
 
-libgstsouphttpsrc_la_CFLAGS = $(GST_CFLAGS) $(SOUP_CFLAGS) 
-libgstsouphttpsrc_la_LIBADD = $(GST_BASE_LIBS) $(SOUP_LIBS)
+libgstsouphttpsrc_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(SOUP_CFLAGS) 
+libgstsouphttpsrc_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgsttag-@GST_MAJORMINOR@ $(GST_BASE_LIBS) $(SOUP_LIBS)
 libgstsouphttpsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 
 noinst_HEADERS = gstsouphttpsrc.h
Index: gstsouphttpsrc.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/soup/gstsouphttpsrc.c,v
retrieving revision 1.3
diff -u -p -r1.3 gstsouphttpsrc.c
--- gstsouphttpsrc.c	11 Dec 2007 16:39:39 -0000	1.3
+++ gstsouphttpsrc.c	12 Dec 2007 10:58:04 -0000
@@ -22,6 +22,8 @@
 #include <libsoup/soup.h>
 #include "gstsouphttpsrc.h"
 
+#include <gst/tag/tag.h>
+
 GST_DEBUG_CATEGORY_STATIC (souphttpsrc_debug);
 #define GST_CAT_DEFAULT souphttpsrc_debug
 
@@ -296,36 +298,14 @@ gst_souphttp_src_get_property (GObject *
   }
 }
 
-static char *
-unicodify (const char *str, int len, ...)
+static gchar *
+gst_souphttp_src_unicodify (const gchar * str)
 {
-  char *ret = NULL, *cset;
-  va_list args;
-  gsize bytes_read, bytes_written;
-
-  if (g_utf8_validate (str, len, NULL))
-    return g_strndup (str, len >= 0 ? len : strlen (str));
-
-  va_start (args, len);
-  while ((cset = va_arg (args, char *)) != NULL)
-  {
-    if (!strcmp (cset, "locale"))
-      ret = g_locale_to_utf8 (str, len, &bytes_read, &bytes_written, NULL);
-    else
-      ret = g_convert (str, len, "UTF-8", cset,
-          &bytes_read, &bytes_written, NULL);
-    if (ret)
-      break;
-  }
-  va_end (args);
-
-  return ret;
-}
+  const gchar *env_vars[] = { "GST_ICY_TAG_ENCODING",
+    "GST_TAG_ENCODING", NULL
+  };
 
-static char *
-gst_souphttp_src_unicodify (const char *str)
-{
-  return unicodify (str, -1, "locale", "ISO-8859-1", NULL);
+  return gst_tag_freeform_string_to_utf8 (str, -1, env_vars);
 }
 
 static GstFlowReturn
@@ -523,6 +503,7 @@ static void
 soup_got_headers (SoupMessage * msg, GstSouphttpSrc * src)
 {
   const char *value;
+  GstTagList *tag_list;
 
   GST_DEBUG_OBJECT (src, "got headers");
 
@@ -539,11 +520,14 @@ soup_got_headers (SoupMessage * msg, Gst
   }
 
   /* Icecast stuff */
+  tag_list = gst_tag_list_new ();
+
   if ((value =
           soup_message_get_header (msg->response_headers,
               "icy-metaint")) != NULL) {
     gint icy_metaint = atoi (value);
 
+    GST_DEBUG_OBJECT (src, "icy-metaint: %s (parsed: %d)", value, icy_metaint);
     if (icy_metaint > 0)
       src->icy_caps = gst_caps_new_simple ("application/x-icy",
           "metadata-interval", G_TYPE_INT, icy_metaint, NULL);
@@ -554,23 +538,40 @@ soup_got_headers (SoupMessage * msg, Gst
               "icy-name")) != NULL) {
     g_free (src->iradio_name);
     src->iradio_name = gst_souphttp_src_unicodify (value);
-    if (src->iradio_name)
+    if (src->iradio_name) {
       g_object_notify (G_OBJECT (src), "iradio-name");
+      gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION,
+                        src->iradio_name, NULL);
+    }
   }
   if ((value =
           soup_message_get_header (msg->response_headers,
               "icy-genre")) != NULL) {
     g_free (src->iradio_genre);
     src->iradio_genre = gst_souphttp_src_unicodify (value);
-    if (src->iradio_genre)
+    if (src->iradio_genre) {
       g_object_notify (G_OBJECT (src), "iradio-genre");
+      gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
+                        src->iradio_genre, NULL);
+    }
   }
   if ((value =
           soup_message_get_header (msg->response_headers, "icy-url")) != NULL) {
     g_free (src->iradio_url);
     src->iradio_url = gst_souphttp_src_unicodify (value);
-    if (src->iradio_url)
+    if (src->iradio_url) {
       g_object_notify (G_OBJECT (src), "iradio-url");
+      gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION,
+                        src->iradio_url, NULL);
+    }
+  }
+  if (!gst_tag_list_is_empty (tag_list)) {
+    GST_DEBUG_OBJECT (src,
+                      "calling gst_element_found_tags with %" GST_PTR_FORMAT,
+                      tag_list);
+    gst_element_found_tags (GST_ELEMENT_CAST (src), tag_list);
+  } else {
+    gst_tag_list_free (tag_list);
   }
 
   /* Handle HTTP errors. */
