summaryrefslogtreecommitdiffstats
path: root/ext/soup
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2007-12-28 11:44:28 +0000
committerTim-Philipp Müller <tim@centricular.net>2007-12-28 11:44:28 +0000
commite2e5d42fd3e690c2fbd3e20e7e8ae1c4589d452c (patch)
treebf092ae50cda7e5633563beac6b93fdd51266847 /ext/soup
parentbcdeaa639b88bafd2d260ec262a2a38a19dfbeb6 (diff)
ext/soup/: Use gst_tag_freeform_string_to_utf8() and post radio station info as tags on the bus.
Original commit message from CVS: * ext/soup/Makefile.am: * ext/soup/gstsouphttpsrc.c: (gst_souphttp_src_get_property), (gst_souphttp_src_unicodify), (soup_got_headers): Use gst_tag_freeform_string_to_utf8() and post radio station info as tags on the bus.
Diffstat (limited to 'ext/soup')
-rw-r--r--ext/soup/Makefile.am4
-rw-r--r--ext/soup/gstsouphttpsrc.c73
2 files changed, 36 insertions, 41 deletions
diff --git a/ext/soup/Makefile.am b/ext/soup/Makefile.am
index 39d89dda..168ca916 100644
--- a/ext/soup/Makefile.am
+++ b/ext/soup/Makefile.am
@@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstsouphttpsrc.la
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
diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c
index 4b3b66b2..845303f8 100644
--- a/ext/soup/gstsouphttpsrc.c
+++ b/ext/soup/gstsouphttpsrc.c
@@ -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 * object, guint prop_id,
}
}
-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, GstSouphttpSrc * src)
}
/* 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,39 @@ soup_got_headers (SoupMessage * msg, GstSouphttpSrc * src)
"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. */
@@ -745,22 +745,17 @@ gst_souphttp_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
iface->set_uri = gst_souphttp_src_uri_set_uri;
}
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and pad templates
- * register the features
- */
static gboolean
plugin_init (GstPlugin * plugin)
{
+ /* note: do not upgrade rank before we depend on a libsoup version where
+ * icecast is supported properly out of the box */
return gst_element_register (plugin, "souphttpsrc", GST_RANK_NONE,
GST_TYPE_SOUPHTTP_SRC);
}
-/* this is the structure that gst-register looks for
- * so keep the name plugin_desc, or you cannot get your plug-in registered */
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"soup",
"libsoup http client src",
- plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)