diff mbox

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

Message ID AED01BE40B4CAD41A590B456FC8C4B8E010BA62BF0@EXMBX-SZMail009.tencent.com
State New
Headers show

Commit Message

lmzeng(曾令明) March 4, 2019, 7:34 a.m. UTC
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@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

--
2.7.4

Comments

Liu Steven March 4, 2019, 8:27 a.m. UTC | #1
> 在 2019年3月4日,下午3:34,lmzeng(曾令明) <lmzeng@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@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@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Michael Niedermayer March 4, 2019, 7:36 p.m. UTC | #2
On Mon, Mar 04, 2019 at 07:34:00AM +0000, lmzeng(曾令明) wrote:
> 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@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

this looks unintended

[...]
diff mbox

Patch

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);
+        }
+
         ret = open_url(pls->parent, in, url, c->avio_opts, opts, &is_http);
         if (ret < 0) {
             goto cleanup;