Mercurial > audlegacy-plugins
changeset 1742:4f4634573e41
- Free memory for ICY tags
- Add content-type parsing for metadata
author | Ralf Ertzinger <ralf@skytale.net> |
---|---|
date | Wed, 19 Sep 2007 14:36:37 +0200 |
parents | f86ddc8e543b |
children | 46cda76dcd2a d2e3eef90719 |
files | src/neon/neon.c src/neon/neon.h |
diffstat | 2 files changed, 43 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/neon/neon.c Wed Sep 19 12:06:35 2007 +0200 +++ b/src/neon/neon.c Wed Sep 19 14:36:37 2007 +0200 @@ -68,6 +68,7 @@ h->icy_metadata.stream_name = NULL; h->icy_metadata.stream_title = NULL; h->icy_metadata.stream_url = NULL; + h->icy_metadata.stream_contenttype = NULL; h->reader = NULL; h->reader_status.mutex = g_mutex_new(); h->reader_status.cond = g_cond_new(); @@ -88,6 +89,18 @@ ne_uri_free(h->purl); destroy_rb(&h->rb); + if (NULL != h->icy_metadata.stream_name) { + free(h->icy_metadata.stream_name); + } + if (NULL != h->icy_metadata.stream_title) { + free(h->icy_metadata.stream_title); + } + if (NULL != h->icy_metadata.stream_url) { + free(h->icy_metadata.stream_url); + } + if (NULL != h->icy_metadata.stream_contenttype) { + free(h->icy_metadata.stream_contenttype); + } free(h); _LEAVE; @@ -161,15 +174,13 @@ * ----- */ -#define TAGSIZE 4096 - static void parse_icy(struct icy_metadata* m, gchar* metadata, int len) { gchar* p; gchar* tstart; gchar* tend; - gchar name[TAGSIZE]; - gchar value[TAGSIZE]; + gchar name[4096]; + gchar value[4096]; int state; int pos; @@ -193,7 +204,7 @@ * End of tag name. */ *p = '\0'; - g_strlcpy(name, tstart, TAGSIZE); + strcpy(name, tstart); _DEBUG("Found tag name: %s", name); state = 2; } else { @@ -222,7 +233,7 @@ * End of value */ *p = '\0'; - g_strlcpy(value, tstart, TAGSIZE); + strcpy(value, tstart); _DEBUG("Found tag value: %s", value); add_icy(m, name, value); state = 4; @@ -341,6 +352,8 @@ _DEBUG("server can_ranges"); h->can_ranges = TRUE; } + + continue; } if (0 == g_ascii_strncasecmp("content-length", name, 14)) { @@ -357,6 +370,21 @@ } else { _ERROR("Invalid content length header: %s", value); } + + continue; + } + + if (0 == g_ascii_strncasecmp("content-type", name, 12)) { + /* + * The server sent us a content type. Save it for later + */ + _DEBUG("Content-Type: %s", value); + if (NULL != h->icy_metadata.stream_contenttype) { + free(h->icy_metadata.stream_contenttype); + } + h->icy_metadata.stream_contenttype = g_strdup(value); + + continue; } if (0 == g_ascii_strncasecmp("icy-metaint", name, 11)) { @@ -374,6 +402,8 @@ } else { _ERROR("Invalid ICY MetaInt header: %s", value); } + + continue; } if (0 == g_ascii_strncasecmp("icy-name", name, 8)) { @@ -386,6 +416,8 @@ } h->icy_metadata.stream_name = g_strdup(value); } + + continue; } _LEAVE; @@ -1145,6 +1177,10 @@ _LEAVE g_strdup(h->icy_metadata.stream_name); } + if (0 == g_ascii_strncasecmp(field, "content-type", 12)) { + _LEAVE g_strdup(h->icy_metadata.stream_contenttype); + } + _LEAVE NULL; }