Mercurial > audlegacy
changeset 684:d991052592f6 trunk
[svn] - Roll back broken HTTP-based stream detection code.
author | nenolod |
---|---|
date | Sat, 25 Feb 2006 01:25:21 -0800 |
parents | b57801a2a70f |
children | 147e844e16cb |
files | Plugins/Input/mpg123/mpg123.c |
diffstat | 1 files changed, 3 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Input/mpg123/mpg123.c Sat Feb 25 00:09:42 2006 -0800 +++ b/Plugins/Input/mpg123/mpg123.c Sat Feb 25 01:25:21 2006 -0800 @@ -288,89 +288,14 @@ return ret; } -static gboolean -mpg123_detect_by_content_stream(gchar *url) -{ - gchar *buf, inbuf[BUFSIZE_X]; - struct hostent *hp; - struct sockaddr_in sa; - gint s, i, y = 0; - gchar *user, *pass, *host, *filename; - gint port; - - g_strstrip(url); - - parse_url(url, &user, &pass, &host, &port, &filename); - - if (!(s = socket(AF_INET, SOCK_STREAM, 0))) - { - perror("socket"); - return FALSE; - } - - if ((hp = gethostbyname(host)) == NULL) - { - g_print("[stream detect] Unable to resolve %s\n", host); - close(s); - return FALSE; - } - - memset(&sa, '\0', sizeof(sa)); - sa.sin_family = AF_INET; - sa.sin_port = htons(port); - memcpy(&sa.sin_addr, hp->h_addr, hp->h_length); - - if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) - { - perror("connect"); - return FALSE; - } - - g_print("[stream detect] connected to %s, port %d\n", host, port); - - buf = g_strdup_printf("GET /%s HTTP/1.0\r\nUser-Agent: " PACKAGE "/" PACKAGE_VERSION "\r\n\r\n", filename ? filename : ""); - i = write(s, buf, strlen(buf)); - g_free(buf); - - if (i == -1) - { - perror("write"); - return FALSE; - } - - /* don't ask. --nenolod */ - while ((i = read(s, inbuf + y, BUFSIZE_X - y)) != 0 && y < BUFSIZE_X) - { - inbuf[y + i] = '\0'; - y += i; - } - - close(s); - - buf = strtok(inbuf, "\n"); - while ((buf = strtok(NULL, "\n")) != NULL) - { - if (!g_strncasecmp("content-type:audio/mpeg", buf, 23) || - !g_strncasecmp("icy-br:", buf, 7) || /* XXX ShoutCAST sometimes doesnt send the content-type header */ - !g_strncasecmp("Content-Type: audio/mpeg", buf, 24)) - { - g_print("[stream detect] server is providing audio/mpeg stream\n"); - return TRUE; - } - } - - g_print("[stream detect] server is NOT providing audio/mpeg stream\n"); - return FALSE; -} - static int is_our_file(char *filename) { gchar *ext = strrchr(filename, '.'); - if (!strncasecmp(filename, "http://", 7)) - return mpg123_detect_by_content_stream(filename); - else if (strncasecmp(ext, ".mp3", 7)) /* If extension ends in .mp3, let it be --nenolod */ + if (!strncasecmp(filename, "http://", 7) && (!ext || !strncasecmp(ext, ".mp3", 4))) + return TRUE; + else if (strncasecmp(ext, ".mp3", 4)) /* If extension ends in .mp3, let it be --nenolod */ return (mpg123_detect_by_content(filename)); return TRUE; /* Why? The file ends in .mp3. Lalala. */