diff mbox

[FFmpeg-devel,1/1] avformat/hlsenc: Added configuration to override HTTP User-Agent

Message ID CADxeRwkATfOyTe_YAxUfHP+gfCJe+kXXEjVMjQa=ggGBa7GiZA@mail.gmail.com
State New
Headers show

Commit Message

Steven Liu Sept. 4, 2017, 8:06 a.m. UTC
2017-09-04 16:01 GMT+08:00 Jeyapal, Karthick <kjeyapal@akamai.com>:
>>On 9/4/17, 12:41 PM, "Steven Liu" <lingjiujianke@gmail.com<mailto:lingjiujianke@gmail.com>> wrote:
>>
>>Hi Karthick,
>>set user_agent better than user-agent, because the user-agent is
>>duplicate with user_agent, and the user-agent will be deprecated in
>>new version, refer to :
>>https://ffmpeg.org/ffmpeg-protocols.html#http
>>
>>       BTW, the patch is ok, if modify the user-agent to user_agent
>
> Hi Steven,
>
> Thanks for the reply. I am not using ‘user-agent’. I was using ‘http_user_agent’. Do you want me to rename ‘http_user_agent’ to ‘user_agent’?
> I used ‘http_user_agent’ just to indirectly infer that it is http-specific option. But I am OK to rename it to ‘user_agent’ if you insist.
>
> Regards,
> Karthick
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
From 352a1f8fa223f573ec634be55197a17c71dd606d Mon Sep 17 00:00:00 2001
From: Karthick J <kjeyapal@akamai.com>
Date: Fri, 1 Sep 2017 15:55:48 +0530
Subject: [PATCH 1/1] avformat/hlsenc: Added configuration to override HTTP
 User-Agent

Signed-off-by: Karthick J <kjeyapal@akamai.com>
---
 doc/muxers.texi       | 4 ++++
 libavformat/hlsenc.c  | 5 +++++
 libavformat/version.h | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

Comments

Jeyapal, Karthick Sept. 4, 2017, 8:16 a.m. UTC | #1
>On 9/4/17, 1:36 PM, "Steven Liu" <lingjiujianke@gmail.com<mailto:lingjiujianke@gmail.com>> wrote:

>+    if (c->user_agent)

>+        av_dict_set(options, "user-agent", c->user_agent, 0);

>

>should be

>av_dict_set(options, "user_agent", c->user_agent, 0);


Oh! OK Got it. Sorry for the confusion. Have attached the patch with user_agent being set.

Thanks,
Karthick
Steven Liu Sept. 4, 2017, 8:47 a.m. UTC | #2
2017-09-04 16:16 GMT+08:00 Jeyapal, Karthick <kjeyapal@akamai.com>:
>>On 9/4/17, 1:36 PM, "Steven Liu" <lingjiujianke@gmail.com<mailto:lingjiujianke@gmail.com>> wrote:
>>+    if (c->user_agent)
>>+        av_dict_set(options, "user-agent", c->user_agent, 0);
>>
>>should be
>>av_dict_set(options, "user_agent", c->user_agent, 0);
>
> Oh! OK Got it. Sorry for the confusion. Have attached the patch with user_agent being set.
>
> Thanks,
> Karthick
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

LGTM
Michael Niedermayer Sept. 5, 2017, 1:45 p.m. UTC | #3
On Mon, Sep 04, 2017 at 08:16:53AM +0000, Jeyapal, Karthick wrote:
> >On 9/4/17, 1:36 PM, "Steven Liu" <lingjiujianke@gmail.com<mailto:lingjiujianke@gmail.com>> wrote:
> >+    if (c->user_agent)
> >+        av_dict_set(options, "user-agent", c->user_agent, 0);
> >
> >should be
> >av_dict_set(options, "user_agent", c->user_agent, 0);
> 
> Oh! OK Got it. Sorry for the confusion. Have attached the patch with user_agent being set.
> 
> Thanks,
> Karthick

>  doc/muxers.texi       |    4 ++++
>  libavformat/hlsenc.c  |    5 +++++
>  libavformat/version.h |    2 +-
>  3 files changed, 10 insertions(+), 1 deletion(-)
> 012d43c19fc3e01262158cd9becb63ce582f02f9  0001-avformat-hlsenc-Added-configuration-to-override-HTTP.patch
> From 7edb12511ec72ada156af86cc8b23c9410695117 Mon Sep 17 00:00:00 2001
> From: Karthick J <kjeyapal@akamai.com>
> Date: Fri, 1 Sep 2017 15:55:48 +0530
> Subject: [PATCH 1/1] avformat/hlsenc: Added configuration to override HTTP
>  User-Agent
> 
> Signed-off-by: Karthick J <kjeyapal@akamai.com>
> ---
>  doc/muxers.texi       | 4 ++++
>  libavformat/hlsenc.c  | 5 +++++
>  libavformat/version.h | 2 +-
>  3 files changed, 10 insertions(+), 1 deletion(-)

doesnt apply automatically

Applying: avformat/hlsenc: Added configuration to override HTTP User-Agent
error: sha1 information is lacking or useless (libavformat/hlsenc.c).
error: could not build fake ancestor
Patch failed at 0001 avformat/hlsenc: Added configuration to override HTTP User-Agent
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


[...]
Steven Liu Sept. 5, 2017, 3:33 p.m. UTC | #4
2017-09-05 21:45 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Mon, Sep 04, 2017 at 08:16:53AM +0000, Jeyapal, Karthick wrote:
>> >On 9/4/17, 1:36 PM, "Steven Liu" <lingjiujianke@gmail.com<mailto:lingjiujianke@gmail.com>> wrote:
>> >+    if (c->user_agent)
>> >+        av_dict_set(options, "user-agent", c->user_agent, 0);
>> >
>> >should be
>> >av_dict_set(options, "user_agent", c->user_agent, 0);
>>
>> Oh! OK Got it. Sorry for the confusion. Have attached the patch with user_agent being set.
>>
>> Thanks,
>> Karthick
>
>>  doc/muxers.texi       |    4 ++++
>>  libavformat/hlsenc.c  |    5 +++++
>>  libavformat/version.h |    2 +-
>>  3 files changed, 10 insertions(+), 1 deletion(-)
>> 012d43c19fc3e01262158cd9becb63ce582f02f9  0001-avformat-hlsenc-Added-configuration-to-override-HTTP.patch
>> From 7edb12511ec72ada156af86cc8b23c9410695117 Mon Sep 17 00:00:00 2001
>> From: Karthick J <kjeyapal@akamai.com>
>> Date: Fri, 1 Sep 2017 15:55:48 +0530
>> Subject: [PATCH 1/1] avformat/hlsenc: Added configuration to override HTTP
>>  User-Agent
>>
>> Signed-off-by: Karthick J <kjeyapal@akamai.com>
>> ---
>>  doc/muxers.texi       | 4 ++++
>>  libavformat/hlsenc.c  | 5 +++++
>>  libavformat/version.h | 2 +-
>>  3 files changed, 10 insertions(+), 1 deletion(-)
>
> doesnt apply automatically
>
> Applying: avformat/hlsenc: Added configuration to override HTTP User-Agent
> error: sha1 information is lacking or useless (libavformat/hlsenc.c).
> error: could not build fake ancestor
> Patch failed at 0001 avformat/hlsenc: Added configuration to override HTTP User-Agent
> The copy of the patch that failed is found in: .git/rebase-apply/patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> "You are 36 times more likely to die in a bathtub than at the hands of a
> terrorist. Also, you are 2.5 times more likely to become a president and
> 2 times more likely to become an astronaut, than to die in a terrorist
> attack." -- Thoughty2
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Modify fixed apply error and applied.


Thanks.
Jeyapal, Karthick Sept. 6, 2017, 5:15 a.m. UTC | #5
Thanks.

Regards,
Karthick
diff mbox

Patch

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 2bec5f8..5a4f17b 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -728,6 +728,10 @@  server using the HTTP PUT method, and update the
m3u8 files every
 @code{refresh} times using the same method.
 Note that the HTTP server must support the given method for uploading
 files.
+
+@item http_user_agent
+Override User-Agent field in HTTP header. Applicable only for HTTP output.
+
 @end table

 @anchor{ico}
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index dd36fde..70ad281 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -175,6 +175,7 @@  typedef struct HLSContext {

     double initial_prog_date_time;
     char current_segment_final_filename_fmt[1024]; // when renaming segments
+    char *user_agent;
 } HLSContext;

 static int get_int_from_double(double val)
@@ -975,6 +976,9 @@  static void set_http_options(AVFormatContext *s,
AVDictionary **options, HLSCont
         av_log(c, AV_LOG_WARNING, "No HTTP method set, hls muxer
defaulting to method PUT.\n");
         av_dict_set(options, "method", "PUT", 0);
     }
+    if (c->user_agent)
+        av_dict_set(options, "user-agent", c->user_agent, 0);

should be
av_dict_set(options, "user_agent", c->user_agent, 0);
+
 }

 static void write_m3u8_head_block(HLSContext *hls, AVIOContext *out,
int version,
@@ -1818,6 +1822,7 @@  static const AVOption options[] = {
     {"generic", "start_number value (default)", 0, AV_OPT_TYPE_CONST,
{.i64 = HLS_START_SEQUENCE_AS_START_NUMBER }, INT_MIN, INT_MAX, E,
"start_sequence_source_type" },
     {"epoch", "seconds since epoch", 0, AV_OPT_TYPE_CONST, {.i64 =
HLS_START_SEQUENCE_AS_SECONDS_SINCE_EPOCH }, INT_MIN, INT_MAX, E,
"start_sequence_source_type" },
     {"datetime", "current datetime as YYYYMMDDhhmmss", 0,
AV_OPT_TYPE_CONST, {.i64 = HLS_START_SEQUENCE_AS_FORMATTED_DATETIME },
INT_MIN, INT_MAX, E, "start_sequence_source_type" },
+    {"http_user_agent", "override User-Agent field in HTTP header",
OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,    E},
     { NULL },
 };

diff --git a/libavformat/version.h b/libavformat/version.h
index 0af524c..9ee9d3e 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@ 
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  57
 #define LIBAVFORMAT_VERSION_MINOR  80
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101

 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \