[FFmpeg-devel] [PATCH] HLS fixes: better relative path handling, larger buffer for long URIs, only send range header when necessary

Michael Niedermayer michaelni at gmx.at
Sun Sep 23 02:51:54 CEST 2012


Hi

On Sat, Sep 22, 2012 at 09:17:36PM +0100, Duncan Salerno wrote:
> ---
>  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);
>  

split and applied above



> 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;
> +    }
> +

do you have testcases / public examples that use/need these ?
also the indention is a bit inconsistent

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120923/a20a5246/attachment.asc>


More information about the ffmpeg-devel mailing list