Mercurial > audlegacy-plugins
changeset 585:2d20bc58a290 trunk
[svn] tweak xspf plugin to conform xspf specification version 1.
- arrange the order of elements to pass several validators.
- specify character set and encoding as UTF-8.
- now urls beginning with file:// can be used.
- prepend file:// onto local file entry to save (tentative).
author | yaz |
---|---|
date | Tue, 30 Jan 2007 23:14:02 -0800 |
parents | 5e2b137a24fe |
children | 26519231a4f4 |
files | ChangeLog src/xspf/xspf.c |
diffstat | 2 files changed, 66 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jan 30 13:41:14 2007 -0800 +++ b/ChangeLog Tue Jan 30 23:14:02 2007 -0800 @@ -1,3 +1,12 @@ +2007-01-30 21:41:14 +0000 Michael Farber <01mf02@gmail.com> + revision [1254] + - Cleaned up AAC plugin a bit more, but still couldn't fix the bug + + + trunk/src/aac/src/libmp4.c | 300 ++++++++++++++++++++++----------------------- + 1 file changed, 148 insertions(+), 152 deletions(-) + + 2007-01-30 20:55:38 +0000 Michael Farber <01mf02@gmail.com> revision [1252] - Fixed crash at opening AAC files
--- a/src/xspf/xspf.c Tue Jan 30 13:41:14 2007 -0800 +++ b/src/xspf/xspf.c Tue Jan 30 23:14:02 2007 -0800 @@ -64,39 +64,46 @@ for(nptr = track->children; nptr != NULL; nptr = nptr->next){ if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "location")){ GError *err = NULL; - gchar *tmp = NULL; + gchar *tmp = NULL, *tmp2 = NULL; xmlChar *str = xmlNodeGetContent(nptr); tmp = g_locale_from_utf8(str, -1, NULL, NULL, &err); //for backward compatibility - if(err != NULL) - location = xspf_url_decode(str); - else - location = xspf_url_decode(tmp); - + if(err != NULL) { + tmp2 = xspf_url_decode(str); + } + else { + tmp2= xspf_url_decode(tmp); + } + if(strstr(tmp2, "file://")){ + location = g_strdup(tmp2+7); + } + else { + location = g_strdup(tmp2); + } xmlFree(str); - g_free(tmp); g_free(err); + g_free(tmp); g_free(err); g_free(tmp2); + } + else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "title")){ + tuple->track_name = (gchar *)xmlNodeGetContent(nptr); } else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "creator")){ tuple->performer = (gchar *)xmlNodeGetContent(nptr); } + else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "annotation")){ + tuple->comment = (gchar *)xmlNodeGetContent(nptr); + continue; + } else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "album")){ tuple->album_name = (gchar *)xmlNodeGetContent(nptr); } - else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "title")){ - tuple->track_name = (gchar *)xmlNodeGetContent(nptr); - } - else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "duration")){ - xmlChar *str = xmlNodeGetContent(nptr); - tuple->length = atol(str); - xmlFree(str); - } else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "trackNum")){ xmlChar *str = xmlNodeGetContent(nptr); tuple->track_number = atol(str); xmlFree(str); } - else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "annotation")){ - tuple->comment = (gchar *)xmlNodeGetContent(nptr); - continue; + else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, "duration")){ + xmlChar *str = xmlNodeGetContent(nptr); + tuple->length = atol(str); + xmlFree(str); } // @@ -224,6 +231,9 @@ doc = xmlNewDoc("1.0"); + doc->charset = XML_CHAR_ENCODING_UTF8; + doc->encoding = xmlStrdup("UTF-8"); + rootnode = xmlNewNode(NULL, XSPF_ROOT_NODE_NAME); xmlSetProp(rootnode, "xmlns", XSPF_XMLNS); xmlSetProp(rootnode, "version", "1"); @@ -249,12 +259,15 @@ /* url encode file name. exclude streaming for now. */ if (strncasecmp("http://", entry->filename, 7) && - strncasecmp("https://", entry->filename, 8)) { - filename = (gchar *)xspf_url_encode(entry->filename); + strncasecmp("https://", entry->filename, 8)) { /* the rest */ + gchar *tmp = (gchar *)xspf_url_encode(entry->filename); + filename = g_strdup_printf("file://%s", tmp); + g_free(tmp); } - else { + else { /* streaming */ filename = strdup(entry->filename); } + if(!g_utf8_validate(filename, -1, NULL)) continue; @@ -265,6 +278,14 @@ /* do we have a tuple? */ if (entry->tuple != NULL) { + if (entry->tuple->track_name != NULL && + g_utf8_validate(entry->tuple->track_name, -1, NULL)) + { + tmp = xmlNewNode(NULL, "title"); + xmlAddChild(tmp, xmlNewText(entry->tuple->track_name)); + xmlAddChild(track, tmp); + } + if (entry->tuple->performer != NULL && g_utf8_validate(entry->tuple->performer, -1, NULL)) { @@ -273,6 +294,14 @@ xmlAddChild(track, tmp); } + if (entry->tuple->comment != NULL && + g_utf8_validate(entry->tuple->comment, -1, NULL)) + { + tmp = xmlNewNode(NULL, "annotation"); + xmlAddChild(tmp, xmlNewText(entry->tuple->comment)); + xmlAddChild(track, tmp); + } + if (entry->tuple->album_name != NULL && g_utf8_validate(entry->tuple->album_name, -1, NULL)) { @@ -281,25 +310,6 @@ xmlAddChild(track, tmp); } - if (entry->tuple->track_name != NULL && - g_utf8_validate(entry->tuple->track_name, -1, NULL)) - { - tmp = xmlNewNode(NULL, "title"); - xmlAddChild(tmp, xmlNewText(entry->tuple->track_name)); - xmlAddChild(track, tmp); - } - - if (entry->tuple->length > 0) - { - gchar *str; - str = g_malloc(TMP_BUF_LEN); - tmp = xmlNewNode(NULL, "duration"); - sprintf(str, "%d", entry->tuple->length); - xmlAddChild(tmp, xmlNewText(str)); - g_free(str); - xmlAddChild(track, tmp); - } - if (entry->tuple->track_number != 0) { gchar *str; @@ -311,11 +321,14 @@ xmlAddChild(track, tmp); } - if (entry->tuple->comment != NULL && - g_utf8_validate(entry->tuple->comment, -1, NULL)) + if (entry->tuple->length > 0) { - tmp = xmlNewNode(NULL, "annotation"); - xmlAddChild(tmp, xmlNewText(entry->tuple->comment)); + gchar *str; + str = g_malloc(TMP_BUF_LEN); + tmp = xmlNewNode(NULL, "duration"); + sprintf(str, "%d", entry->tuple->length); + xmlAddChild(tmp, xmlNewText(str)); + g_free(str); xmlAddChild(track, tmp); }