[FFmpeg-devel] [PATCH] avformat/hls: fix hls-aes-128 set offset bug

Liu Steven lq at chinaffmpeg.org
Mon Mar 4 10:27:56 EET 2019



> 在 2019年3月4日,下午3:34,lmzeng(曾令明) <lmzeng at tencent.com> 写道:
> 
> From 45720887a4466b97dbd63b6cac452e814e20a567 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?lmzeng=28=E6=9B=BE=E4=BB=A4=E6=98=8E=29?=
> <lmzeng at tencent.com>
> Date: Mon, 4 Mar 2019 15:05:45 +0800
> Subject: [PATCH] fix hls-aes-128 set offset bug
> 
> ---
> libavformat/hls.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
> mode change 100644 => 100755 libavformat/hls.c
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> old mode 100644
> new mode 100755
> index 8975a87..fa9b055
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -1184,17 +1184,16 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
>     if (c->http_persistent)
>         av_dict_set(&opts, "multiple_requests", "1", 0);
> 
> -    if (seg->size >= 0) {
> -        /* try to restrict the HTTP request to the part we want
> -         * (if this is in fact a HTTP request) */
> -        av_dict_set_int(&opts, "offset", seg->url_offset, 0);
> -        av_dict_set_int(&opts, "end_offset", seg->url_offset + seg->size, 0);
> -    }
> -
>     av_log(pls->parent, AV_LOG_VERBOSE, "HLS request for url '%s', offset %"PRId64", playlist %d\n",
>            seg->url, seg->url_offset, pls->index);
> 
>     if (seg->key_type == KEY_NONE) {
> +        if (seg->size >= 0) {
> +            /* try to restrict the HTTP request to the part we want
> +             * (if this is in fact a HTTP request) */
> +            av_dict_set_int(&opts, "offset", seg->url_offset, 0);
> +            av_dict_set_int(&opts, "end_offset", seg->url_offset + seg->size, 0);
> +        }
>         ret = open_url(pls->parent, in, seg->url, c->avio_opts, opts, &is_http);
>     } else if (seg->key_type == KEY_AES_128) {
>         char iv[33], key[33], url[MAX_URL_SIZE];
> @@ -1224,6 +1223,13 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
>         av_dict_set(&opts, "key", key, 0);
>         av_dict_set(&opts, "iv", iv, 0);
> 
> +        if (seg->size >= 0) {
> +            /* try to restrict the HTTP request to the part we want
> +             * (if this is in fact a HTTP request) */
> +            av_dict_set_int(&opts, "offset", seg->url_offset, 0);
> +            av_dict_set_int(&opts, "end_offset", seg->url_offset + seg->size, 0);
> +        }
> +

duplicate code with above modify?
>         ret = open_url(pls->parent, in, url, c->avio_opts, opts, &is_http);
>         if (ret < 0) {
>             goto cleanup;
> --
> 2.7.4
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel





More information about the ffmpeg-devel mailing list