diff mbox

[FFmpeg-devel] avformat/hlsenc: improve hls encrypt get key file operation

Message ID 20170721034959.21403-1-lq@chinaffmpeg.org
State Accepted
Commit 805ce25b1d2f08ac4a8e9dcdb9657ad5f5e83d9e
Headers show

Commit Message

Liu Steven July 21, 2017, 3:49 a.m. UTC
get key file only once time is ok, no need more times.
Ticket-id: #6545

Found-by: JohnPi
Signed-off-by: Steven Liu <lq@onvideo.cn>
---
 libavformat/hlsenc.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Steven Liu July 25, 2017, 2:32 a.m. UTC | #1
2017-07-21 11:49 GMT+08:00 Steven Liu <lq@chinaffmpeg.org>:
> get key file only once time is ok, no need more times.
> Ticket-id: #6545
>
> Found-by: JohnPi
> Signed-off-by: Steven Liu <lq@onvideo.cn>
> ---
>  libavformat/hlsenc.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 8a233270b5..6f721eb010 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1222,12 +1222,15 @@ static int hls_start(AVFormatContext *s)
>              av_log(s, AV_LOG_WARNING, "Cannot use both -hls_key_info_file and -hls_enc,"
>                    " will use -hls_key_info_file priority\n");
>          }
> -        if (c->key_info_file) {
> -            if ((err = hls_encryption_start(s)) < 0)
> -                goto fail;
> -        } else {
> -            if ((err = do_encrypt(s)) < 0)
> -                goto fail;
> +
> +        if (c->number <= 1) {
> +            if (c->key_info_file) {
> +                if ((err = hls_encryption_start(s)) < 0)
> +                    goto fail;
> +            } else {
> +                if ((err = do_encrypt(s)) < 0)
> +                    goto fail;
> +            }
>          }
>          if ((err = av_dict_set(&options, "encryption_key", c->key_string, 0))
>                  < 0)
> --
> 2.11.0 (Apple Git-81)
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Pushed!


Thanks
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 8a233270b5..6f721eb010 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1222,12 +1222,15 @@  static int hls_start(AVFormatContext *s)
             av_log(s, AV_LOG_WARNING, "Cannot use both -hls_key_info_file and -hls_enc,"
                   " will use -hls_key_info_file priority\n");
         }
-        if (c->key_info_file) {
-            if ((err = hls_encryption_start(s)) < 0)
-                goto fail;
-        } else {
-            if ((err = do_encrypt(s)) < 0)
-                goto fail;
+
+        if (c->number <= 1) {
+            if (c->key_info_file) {
+                if ((err = hls_encryption_start(s)) < 0)
+                    goto fail;
+            } else {
+                if ((err = do_encrypt(s)) < 0)
+                    goto fail;
+            }
         }
         if ((err = av_dict_set(&options, "encryption_key", c->key_string, 0))
                 < 0)