diff mbox series

[FFmpeg-devel,v2] avformat/hlsenc: set the options when open the key info files

Message ID 20200307034723.65257-1-lq@chinaffmpeg.org
State Accepted
Headers show
Series [FFmpeg-devel,v2] avformat/hlsenc: set the options when open the key info files | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Liu Steven March 7, 2020, 3:47 a.m. UTC
make the options same as segments for the http put method

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
---
 libavformat/hlsenc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt March 7, 2020, 3:51 a.m. UTC | #1
Steven Liu:
> make the options same as segments for the http put method
> 
> Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
> ---
>  libavformat/hlsenc.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index f6dd894343..4b28c412fa 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -685,6 +685,7 @@ static int do_encrypt(AVFormatContext *s, VariantStream *vs)
>      }
>  
>      if (!*hls->key_string) {
> +        AVDictionary *options = NULL;
>          if (!hls->key) {
>              if ((ret = randomize(key, sizeof(key))) < 0) {
>                  av_log(s, AV_LOG_ERROR, "Cannot generate a strong random key\n");
> @@ -695,7 +696,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream *vs)
>          }
>  
>          ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
> -        if ((ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_WRITE, NULL)) < 0)
> +        set_http_options(s, &options, hls);
> +        ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_WRITE, &options);
> +        av_dict_free(&options);
> +        if (ret < 0)
>              return ret;
>          avio_seek(pb, 0, SEEK_CUR);
>          avio_write(pb, key, KEYSIZE);
> @@ -711,13 +715,16 @@ static int hls_encryption_start(AVFormatContext *s)
>      int ret;
>      AVIOContext *pb;
>      uint8_t key[KEYSIZE];
> +    AVDictionary *options = NULL;
>  
> -    if ((ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, NULL)) < 0) {
> +    set_http_options(s, &options, hls);
> +    ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, &options);
> +    av_dict_free(&options);
> +    if (ret < 0) {
>          av_log(hls, AV_LOG_ERROR,
>                 "error opening key info file %s\n", hls->key_info_file);
>          return ret;
>      }
> -

Unrelated whitespace change. I have no objections apart from that; but
I am not really qualified to judge the patch on its merits.

- Andreas
Liu Steven March 7, 2020, 4:13 a.m. UTC | #2
> 2020年3月7日 上午11:51,Andreas Rheinhardt <andreas.rheinhardt@gmail.com> 写道:
> 
> Steven Liu:
>> make the options same as segments for the http put method
>> 
>> Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
>> ---
>> libavformat/hlsenc.c | 18 ++++++++++++++----
>> 1 file changed, 14 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index f6dd894343..4b28c412fa 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -685,6 +685,7 @@ static int do_encrypt(AVFormatContext *s, VariantStream *vs)
>>     }
>> 
>>     if (!*hls->key_string) {
>> +        AVDictionary *options = NULL;
>>         if (!hls->key) {
>>             if ((ret = randomize(key, sizeof(key))) < 0) {
>>                 av_log(s, AV_LOG_ERROR, "Cannot generate a strong random key\n");
>> @@ -695,7 +696,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream *vs)
>>         }
>> 
>>         ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
>> -        if ((ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_WRITE, NULL)) < 0)
>> +        set_http_options(s, &options, hls);
>> +        ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_WRITE, &options);
>> +        av_dict_free(&options);
>> +        if (ret < 0)
>>             return ret;
>>         avio_seek(pb, 0, SEEK_CUR);
>>         avio_write(pb, key, KEYSIZE);
>> @@ -711,13 +715,16 @@ static int hls_encryption_start(AVFormatContext *s)
>>     int ret;
>>     AVIOContext *pb;
>>     uint8_t key[KEYSIZE];
>> +    AVDictionary *options = NULL;
>> 
>> -    if ((ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, NULL)) < 0) {
>> +    set_http_options(s, &options, hls);
>> +    ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, &options);
>> +    av_dict_free(&options);
>> +    if (ret < 0) {
>>         av_log(hls, AV_LOG_ERROR,
>>                "error opening key info file %s\n", hls->key_info_file);
>>         return ret;
>>     }
>> -
> 
> Unrelated whitespace change.
Fix it locally
> I have no objections apart from that; but
> I am not really qualified to judge the patch on its merits.
> 
> - Andreas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Thanks

Steven
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f6dd894343..4b28c412fa 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -685,6 +685,7 @@  static int do_encrypt(AVFormatContext *s, VariantStream *vs)
     }
 
     if (!*hls->key_string) {
+        AVDictionary *options = NULL;
         if (!hls->key) {
             if ((ret = randomize(key, sizeof(key))) < 0) {
                 av_log(s, AV_LOG_ERROR, "Cannot generate a strong random key\n");
@@ -695,7 +696,10 @@  static int do_encrypt(AVFormatContext *s, VariantStream *vs)
         }
 
         ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
-        if ((ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_WRITE, NULL)) < 0)
+        set_http_options(s, &options, hls);
+        ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_WRITE, &options);
+        av_dict_free(&options);
+        if (ret < 0)
             return ret;
         avio_seek(pb, 0, SEEK_CUR);
         avio_write(pb, key, KEYSIZE);
@@ -711,13 +715,16 @@  static int hls_encryption_start(AVFormatContext *s)
     int ret;
     AVIOContext *pb;
     uint8_t key[KEYSIZE];
+    AVDictionary *options = NULL;
 
-    if ((ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, NULL)) < 0) {
+    set_http_options(s, &options, hls);
+    ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, &options);
+    av_dict_free(&options);
+    if (ret < 0) {
         av_log(hls, AV_LOG_ERROR,
                "error opening key info file %s\n", hls->key_info_file);
         return ret;
     }
-
     ff_get_line(pb, hls->key_uri, sizeof(hls->key_uri));
     hls->key_uri[strcspn(hls->key_uri, "\r\n")] = '\0';
 
@@ -739,7 +746,10 @@  static int hls_encryption_start(AVFormatContext *s)
         return AVERROR(EINVAL);
     }
 
-    if ((ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_READ, NULL)) < 0) {
+    set_http_options(s, &options, hls);
+    ret = s->io_open(s, &pb, hls->key_file, AVIO_FLAG_READ, &options);
+    av_dict_free(&options);
+    if (ret < 0) {
         av_log(hls, AV_LOG_ERROR, "error opening key file %s\n", hls->key_file);
         return ret;
     }