[FFmpeg-devel] [PATCH] HLS fixes: better relative path handling, larger buffer for long URIs, only send range header when necessary
Duncan Salerno
duncan.salerno at gmail.com
Sat Sep 22 22:17:36 CEST 2012
---
libavformat/http.c | 6 +++---
libavformat/utils.c | 27 +++++++++++++++++++++++----
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/libavformat/http.c b/libavformat/http.c
index 376ff9e..669fdf4 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -33,7 +33,7 @@
only a subset of it. */
/* used for protocol handling */
-#define BUFFER_SIZE 1024
+#define BUFFER_SIZE 4096
#define MAX_REDIRECTS 8
typedef struct {
@@ -380,7 +380,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
{
HTTPContext *s = h->priv_data;
int post, err;
- char headers[1024] = "";
+ char headers[4096] = "";
char *authstr = NULL, *proxyauthstr = NULL;
int64_t off = s->off;
int len = 0;
@@ -411,7 +411,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
if (!has_header(s->headers, "\r\nAccept: "))
len += av_strlcpy(headers + len, "Accept: */*\r\n",
sizeof(headers) - len);
- if (!has_header(s->headers, "\r\nRange: ") && !post)
+ if (!has_header(s->headers, "\r\nRange: ") && !post && s->off > 0)
len += av_strlcatf(headers + len, sizeof(headers) - len,
"Range: bytes=%"PRId64"-\r\n", s->off);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9c607d7..e5337f8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4457,10 +4457,16 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
av_strlcpy(buf, base, size);
sep = strstr(buf, "://");
if (sep) {
- sep += 3;
- sep = strchr(sep, '/');
- if (sep)
- *sep = '\0';
+ /* Take scheme from base url */
+ if (rel[1] == '/')
+ sep[1] = '\0';
+ else {
+ /* Take scheme and host from base url */
+ sep += 3;
+ sep = strchr(sep, '/');
+ if (sep)
+ *sep = '\0';
+ }
}
av_strlcat(buf, rel, size);
return;
@@ -4472,6 +4478,19 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
}
if (base != buf)
av_strlcpy(buf, base, size);
+
+ /* Stip off any query string from base */
+ char *path_query = strchr(buf, '?');
+ if (path_query != NULL)
+ *path_query = '\0';
+
+ /* Is relative path just a new query part? */
+ if (rel[0] == '?')
+ {
+ av_strlcat(buf, rel, size);
+ return;
+ }
+
/* Remove the file name from the base url */
sep = strrchr(buf, '/');
if (sep)
--
1.7.9.5
More information about the ffmpeg-devel
mailing list