summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2009-10-10 14:50:31 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2009-10-10 14:50:31 +0100
commitac4a311c81c5d01cfbc332d248907bb833ecfed3 (patch)
tree1019df995b3db215778237b5d7cc4cace176eb99 /src
parentc579d6f6fb0fd0075faf02a80be1a24f7f75071a (diff)
parent556f8d0d0799bd05f38cfb454fdb80de85dd2f7c (diff)
downloadxine-lib-ac4a311c81c5d01cfbc332d248907bb833ecfed3.tar.gz
xine-lib-ac4a311c81c5d01cfbc332d248907bb833ecfed3.tar.bz2
Merge from 1.1.
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_qt.c11
-rw-r--r--src/input/http_helper.c17
-rw-r--r--src/input/http_helper.h13
-rw-r--r--src/input/input_http.c12
-rw-r--r--src/input/mms.c2
-rw-r--r--src/input/mmsh.c2
6 files changed, 46 insertions, 11 deletions
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index 0f3c42276..ce4ccba7d 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -1663,6 +1663,7 @@ static qt_error parse_reference_atom (reference_t *ref,
case RDRF_ATOM: {
size_t string_size = _X_BE_32(&ref_atom[i + 12]);
size_t url_offset = 0;
+ int http = 0;
if (string_size >= current_atom_size || i + string_size >= ref_atom_size)
return QT_NOT_A_VALID_FILE;
@@ -1671,7 +1672,13 @@ static qt_error parse_reference_atom (reference_t *ref,
if ( memcmp(&ref_atom[i + 16], "http://", 7) &&
memcmp(&ref_atom[i + 16], "rtsp://", 7) &&
base_mrl )
- url_offset = strlen(base_mrl);
+ {
+ /* We need a "qt" prefix hack for Apple trailers */
+ http = !strncasecmp (base_mrl, "http://", 7);
+ url_offset = strlen(base_mrl) + 2 * http;
+ }
+ if (url_offset >= 0x80000000)
+ return QT_NOT_A_VALID_FILE;
/* otherwise, append relative URL to base MRL */
string_size += url_offset;
@@ -1679,7 +1686,7 @@ static qt_error parse_reference_atom (reference_t *ref,
ref->url = xine_xmalloc(string_size + 1);
if ( url_offset )
- strcpy(ref->url, base_mrl);
+ sprintf (ref->url, "%s%s", http ? "qt" : "", base_mrl);
memcpy(ref->url + url_offset, &ref_atom[i + 16], _X_BE_32(&ref_atom[i + 12]));
diff --git a/src/input/http_helper.c b/src/input/http_helper.c
index f4950a084..9bd54cb6e 100644
--- a/src/input/http_helper.c
+++ b/src/input/http_helper.c
@@ -29,8 +29,18 @@
#include <xine/xine_internal.h>
#include "http_helper.h"
+
+const char *_x_url_user_agent (const char *url)
+{
+ if (!strncasecmp (url, "qthttp://", 9))
+ return "QuickTime"; /* needed for Apple trailers */
+ return NULL;
+}
+
int _x_parse_url (char *url, char **proto, char** host, int *port,
- char **user, char **password, char **uri) {
+ char **user, char **password, char **uri,
+ const char **user_agent)
+{
char *start = NULL;
char *authcolon = NULL;
char *at = NULL;
@@ -63,6 +73,9 @@ int _x_parse_url (char *url, char **proto, char** host, int *port,
end = start + strlen(start) - 1;
*proto = strndup(url, start - url);
+ if (user_agent)
+ *user_agent = _x_url_user_agent (url);
+
/* user:password */
start += 3;
at = strchr(start, '@');
@@ -234,7 +247,7 @@ static int check_url(char *url, int ok) {
printf("--------------------------------\n");
printf("url=%s\n", url);
res = _x_parse_url (url,
- &proto, &host, &port, &user, &password, &uri);
+ &proto, &host, &port, &user, &password, &uri, NULL);
if (res) {
printf("proto=%s, host=%s, port=%d, user=%s, password=%s, uri=%s\n",
proto, host, port, user, password, uri);
diff --git a/src/input/http_helper.h b/src/input/http_helper.h
index 9baa05235..7ca3ac150 100644
--- a/src/input/http_helper.h
+++ b/src/input/http_helper.h
@@ -24,6 +24,16 @@
#define HTTP_HELPER_H
/*
+ * user agent finder, using modified protcol names
+ * {proto}://...
+ * e.g. "qthttp://example.com/foo.mov" → "QuickTime"
+ *
+ * return:
+ * NULL or user agent prefix
+ */
+const char *_x_url_user_agent (const char *url);
+
+/*
* url parser
* {proto}://{user}:{password}@{host}:{port}{uri}
* {proto}://{user}:{password}@{[host]}:{port}{uri}
@@ -33,7 +43,8 @@
* 1 valid url
*/
int _x_parse_url (char *url, char **proto, char** host, int *port,
- char **user, char **password, char **uri);
+ char **user, char **password, char **uri,
+ const char **user_agent);
/*
* canonicalise url, given base
diff --git a/src/input/input_http.c b/src/input/input_http.c
index a4a37c501..fdd7d74f8 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -88,7 +88,7 @@ typedef struct {
off_t preview_size;
char *mime_type;
-
+ const char *user_agent;
char *proto;
char *user;
char *password;
@@ -644,7 +644,8 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
use_proxy = this_class->proxyhost && strlen(this_class->proxyhost);
if (!_x_parse_url(this->mrl, &this->proto, &this->host, &this->port,
- &this->user, &this->password, &this->uri)) {
+ &this->user, &this->password, &this->uri,
+ &this->user_agent)) {
_x_message(this->stream, XINE_MSG_GENERAL_WARNING, "malformed url", NULL);
return 0;
}
@@ -749,10 +750,12 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
}
snprintf(this->buf + buflen, BUFSIZE - buflen,
- "User-Agent: xine/%s\015\012"
+ "User-Agent: %s%sxine/%s\015\012"
"Accept: */*\015\012"
"Icy-MetaData: 1\015\012"
"\015\012",
+ this->user_agent ? this->user_agent : "",
+ this->user_agent ? " " : "",
VERSION);
buflen = strlen(this->buf);
if (_x_io_tcp_write (this->stream, this->fh, this->buf, buflen) != buflen) {
@@ -1003,7 +1006,8 @@ static input_plugin_t *http_class_get_instance (input_class_t *cls_gen, xine_str
if (strncasecmp (mrl, "http://", 7) &&
strncasecmp (mrl, "unsv://", 7) &&
- strncasecmp (mrl, "peercast://pls/", 15)) {
+ strncasecmp (mrl, "peercast://pls/", 15) &&
+ !_x_url_user_agent (mrl) /* user agent hacks */) {
return NULL;
}
this = calloc(1, sizeof(http_input_plugin_t));
diff --git a/src/input/mms.c b/src/input/mms.c
index c3cc15401..b94d986d3 100644
--- a/src/input/mms.c
+++ b/src/input/mms.c
@@ -698,7 +698,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) {
report_progress (stream, 0);
if (!_x_parse_url (this->url, &this->proto, &this->host, &this->port,
- &this->user, &this->password, &this->uri)) {
+ &this->user, &this->password, &this->uri, NULL)) {
lprintf ("invalid url\n");
goto fail;
}
diff --git a/src/input/mmsh.c b/src/input/mmsh.c
index 1f69680f9..95ab64d10 100644
--- a/src/input/mmsh.c
+++ b/src/input/mmsh.c
@@ -649,7 +649,7 @@ mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) {
report_progress (stream, 0);
if (!_x_parse_url (this->url, &this->proto, &this->host, &this->port,
- &this->user, &this->password, &this->uri)) {
+ &this->user, &this->password, &this->uri, NULL)) {
xine_log (this->stream->xine, XINE_LOG_MSG, _("invalid url\n"));
goto fail;
}