* [FFmpeg-devel] [PATCH v1] lavf/hls: add option for hls segment request append http get request parameters
@ 2022-08-31 13:12 mirsfang
0 siblings, 0 replies; 3+ messages in thread
From: mirsfang @ 2022-08-31 13:12 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: mirs
From: mirs <mirsfang@gmail.com>
Signed-off-by: mirs <mirsfang@gmail.com>
---
libavformat/hls.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3dc7bd3930..3a1cc855c4 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -220,6 +220,7 @@ typedef struct HLSContext {
AVIOInterruptCB *interrupt_callback;
AVDictionary *avio_opts;
AVDictionary *seg_format_opts;
+ int seg_append_http_get_params;
char *allowed_extensions;
int max_reload;
int http_persistent;
@@ -307,6 +308,23 @@ static void free_rendition_list(HLSContext *c)
c->n_renditions = 0;
}
+static void hls_append_param_to_url(const HLSContext * c,char *buf, int size, const char *base,
+ const char *rel)
+{
+ if (c && c->seg_append_http_get_params && base) {
+ char * ch = strchr(base, '?');
+ if (!ch) {
+ return;
+ }
+
+ if (strchr(buf, '?')) {
+ ch++;
+ av_strlcat(buf, "&", size);
+ }
+ av_strlcat(buf, ch, size);
+ }
+}
+
static struct playlist *new_playlist(HLSContext *c, const char *url,
const char *base)
{
@@ -319,6 +337,7 @@ static struct playlist *new_playlist(HLSContext *c, const char *url,
return NULL;
}
ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
+ hls_append_param_to_url(c,pls->url, sizeof(pls->url), base, url);
if (!pls->url[0]) {
av_packet_free(&pls->pkt);
av_free(pls);
@@ -411,7 +430,7 @@ struct init_section_info {
char byterange[32];
};
-static struct segment *new_init_section(struct playlist *pls,
+static struct segment *new_init_section(const HLSContext * c,struct playlist *pls,
struct init_section_info *info,
const char *url_base)
{
@@ -429,6 +448,7 @@ static struct segment *new_init_section(struct playlist *pls,
ptr = info->uri;
} else {
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
+ hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url_base, info->uri);
if (!tmp_str[0]) {
av_free(sec);
return NULL;
@@ -861,7 +881,7 @@ static int parse_playlist(HLSContext *c, const char *url,
goto fail;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args,
&info);
- cur_init_section = new_init_section(pls, &info, url);
+ cur_init_section = new_init_section(c,pls, &info, url);
if (!cur_init_section) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -877,6 +897,7 @@ static int parse_playlist(HLSContext *c, const char *url,
if (key_type != KEY_NONE) {
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
+ hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url, key);
if (!tmp_str[0]) {
av_free(cur_init_section);
ret = AVERROR_INVALIDDATA;
@@ -949,6 +970,7 @@ static int parse_playlist(HLSContext *c, const char *url,
if (key_type != KEY_NONE) {
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
+ hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url, key);
if (!tmp_str[0]) {
ret = AVERROR_INVALIDDATA;
av_free(seg);
@@ -963,8 +985,9 @@ static int parse_playlist(HLSContext *c, const char *url,
} else {
seg->key = NULL;
}
-
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line);
+ hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url, line);
+
if (!tmp_str[0]) {
ret = AVERROR_INVALIDDATA;
if (seg->key)
@@ -2548,6 +2571,8 @@ static const AVOption hls_options[] = {
OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS},
{"seg_format_options", "Set options for segment demuxer",
OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
+ {"seg_append_http_get_params", "Segment request append http get parameters 0 = disable 1 = enable",
+ OFFSET(seg_append_http_get_params), AV_OPT_TYPE_BOOL,{.i64 = 1}, 0, 1, FLAGS},
{NULL}
};
--
2.32.1 (Apple Git-133)
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH v1] lavf/hls: add option for hls segment request append http get request parameters
@ 2022-08-31 7:13 mirsfang
2022-08-31 7:22 ` Steven Liu
0 siblings, 1 reply; 3+ messages in thread
From: mirsfang @ 2022-08-31 7:13 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: mirs
From: mirs <mirsfang@gmail.com>
Signed-off-by: mirs <mirsfang@gmail.com>
add option for hls when client reqeust segment url maybe use get parameters for user authenticatio
---
libavformat/hls.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3dc7bd3930..06d0a89a95 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -220,6 +220,7 @@ typedef struct HLSContext {
AVIOInterruptCB *interrupt_callback;
AVDictionary *avio_opts;
AVDictionary *seg_format_opts;
+ int seg_append_http_get_params;
char *allowed_extensions;
int max_reload;
int http_persistent;
@@ -307,6 +308,25 @@ static void free_rendition_list(HLSContext *c)
c->n_renditions = 0;
}
+static void hls_make_url(const HLSContext * c,char *buf, int size, const char *base,
+ const char *rel)
+{
+ ff_make_absolute_url(buf, size, base, rel);
+
+ if (c && c->seg_append_http_get_params && base) {
+ char * ch = strchr(base, '?');
+ if (!ch) {
+ return;
+ }
+
+ if (strchr(buf, '?')) {
+ ch++;
+ av_strlcat(buf, "&", size);
+ }
+ av_strlcat(buf, ch, size);
+ }
+}
+
static struct playlist *new_playlist(HLSContext *c, const char *url,
const char *base)
{
@@ -318,7 +338,7 @@ static struct playlist *new_playlist(HLSContext *c, const char *url,
av_free(pls);
return NULL;
}
- ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
+ hls_make_url(c,pls->url, sizeof(pls->url), base, url);
if (!pls->url[0]) {
av_packet_free(&pls->pkt);
av_free(pls);
@@ -411,7 +431,7 @@ struct init_section_info {
char byterange[32];
};
-static struct segment *new_init_section(struct playlist *pls,
+static struct segment *new_init_section(const HLSContext * c,struct playlist *pls,
struct init_section_info *info,
const char *url_base)
{
@@ -428,7 +448,7 @@ static struct segment *new_init_section(struct playlist *pls,
if (!av_strncasecmp(info->uri, "data:", 5)) {
ptr = info->uri;
} else {
- ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
+ hls_make_url(c,tmp_str, sizeof(tmp_str), url_base, info->uri);
if (!tmp_str[0]) {
av_free(sec);
return NULL;
@@ -861,7 +881,7 @@ static int parse_playlist(HLSContext *c, const char *url,
goto fail;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args,
&info);
- cur_init_section = new_init_section(pls, &info, url);
+ cur_init_section = new_init_section(c,pls, &info, url);
if (!cur_init_section) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -876,7 +896,7 @@ static int parse_playlist(HLSContext *c, const char *url,
}
if (key_type != KEY_NONE) {
- ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
+ hls_make_url(c,tmp_str, sizeof(tmp_str), url, key);
if (!tmp_str[0]) {
av_free(cur_init_section);
ret = AVERROR_INVALIDDATA;
@@ -948,7 +968,7 @@ static int parse_playlist(HLSContext *c, const char *url,
}
if (key_type != KEY_NONE) {
- ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
+ hls_make_url(c,tmp_str, sizeof(tmp_str), url, key);
if (!tmp_str[0]) {
ret = AVERROR_INVALIDDATA;
av_free(seg);
@@ -964,7 +984,7 @@ static int parse_playlist(HLSContext *c, const char *url,
seg->key = NULL;
}
- ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line);
+ hls_make_url(c,tmp_str, sizeof(tmp_str), url, line);
if (!tmp_str[0]) {
ret = AVERROR_INVALIDDATA;
if (seg->key)
@@ -2548,6 +2568,8 @@ static const AVOption hls_options[] = {
OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS},
{"seg_format_options", "Set options for segment demuxer",
OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
+ {"seg_append_http_get_params", "Segment request append http get parameters 0 = disable 1 = enable",
+ OFFSET(seg_append_http_get_params), AV_OPT_TYPE_BOOL,{.i64 = 0}, 0, 1, FLAGS},
{NULL}
};
--
2.32.1 (Apple Git-133)
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH v1] lavf/hls: add option for hls segment request append http get request parameters
2022-08-31 7:13 mirsfang
@ 2022-08-31 7:22 ` Steven Liu
0 siblings, 0 replies; 3+ messages in thread
From: Steven Liu @ 2022-08-31 7:22 UTC (permalink / raw)
To: FFmpeg development discussions and patches
<mirsfang@gmail.com> 于2022年8月31日周三 15:16写道:
>
> From: mirs <mirsfang@gmail.com>
>
> Signed-off-by: mirs <mirsfang@gmail.com>
>
> add option for hls when client reqeust segment url maybe use get parameters for user authenticatio
>
> ---
> libavformat/hls.c | 36 +++++++++++++++++++++++++++++-------
> 1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 3dc7bd3930..06d0a89a95 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -220,6 +220,7 @@ typedef struct HLSContext {
> AVIOInterruptCB *interrupt_callback;
> AVDictionary *avio_opts;
> AVDictionary *seg_format_opts;
> + int seg_append_http_get_params;
> char *allowed_extensions;
> int max_reload;
> int http_persistent;
> @@ -307,6 +308,25 @@ static void free_rendition_list(HLSContext *c)
> c->n_renditions = 0;
> }
>
> +static void hls_make_url(const HLSContext * c,char *buf, int size, const char *base,
Do you mean this should name about params concatenation?
> + const char *rel)
> +{
> + ff_make_absolute_url(buf, size, base, rel);
> +
> + if (c && c->seg_append_http_get_params && base) {
> + char * ch = strchr(base, '?');
> + if (!ch) {
> + return;
> + }
> +
> + if (strchr(buf, '?')) {
> + ch++;
> + av_strlcat(buf, "&", size);
> + }
> + av_strlcat(buf, ch, size);
> + }
> +}
> +
> static struct playlist *new_playlist(HLSContext *c, const char *url,
> const char *base)
> {
> @@ -318,7 +338,7 @@ static struct playlist *new_playlist(HLSContext *c, const char *url,
> av_free(pls);
> return NULL;
> }
> - ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
> + hls_make_url(c,pls->url, sizeof(pls->url), base, url);
> if (!pls->url[0]) {
> av_packet_free(&pls->pkt);
> av_free(pls);
> @@ -411,7 +431,7 @@ struct init_section_info {
> char byterange[32];
> };
>
> -static struct segment *new_init_section(struct playlist *pls,
> +static struct segment *new_init_section(const HLSContext * c,struct playlist *pls,
> struct init_section_info *info,
> const char *url_base)
> {
> @@ -428,7 +448,7 @@ static struct segment *new_init_section(struct playlist *pls,
> if (!av_strncasecmp(info->uri, "data:", 5)) {
> ptr = info->uri;
> } else {
> - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
> + hls_make_url(c,tmp_str, sizeof(tmp_str), url_base, info->uri);
> if (!tmp_str[0]) {
> av_free(sec);
> return NULL;
> @@ -861,7 +881,7 @@ static int parse_playlist(HLSContext *c, const char *url,
> goto fail;
> ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args,
> &info);
> - cur_init_section = new_init_section(pls, &info, url);
> + cur_init_section = new_init_section(c,pls, &info, url);
> if (!cur_init_section) {
> ret = AVERROR(ENOMEM);
> goto fail;
> @@ -876,7 +896,7 @@ static int parse_playlist(HLSContext *c, const char *url,
> }
>
> if (key_type != KEY_NONE) {
> - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
> + hls_make_url(c,tmp_str, sizeof(tmp_str), url, key);
> if (!tmp_str[0]) {
> av_free(cur_init_section);
> ret = AVERROR_INVALIDDATA;
> @@ -948,7 +968,7 @@ static int parse_playlist(HLSContext *c, const char *url,
> }
>
> if (key_type != KEY_NONE) {
> - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
> + hls_make_url(c,tmp_str, sizeof(tmp_str), url, key);
> if (!tmp_str[0]) {
> ret = AVERROR_INVALIDDATA;
> av_free(seg);
> @@ -964,7 +984,7 @@ static int parse_playlist(HLSContext *c, const char *url,
> seg->key = NULL;
> }
>
> - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line);
> + hls_make_url(c,tmp_str, sizeof(tmp_str), url, line);
> if (!tmp_str[0]) {
> ret = AVERROR_INVALIDDATA;
> if (seg->key)
> @@ -2548,6 +2568,8 @@ static const AVOption hls_options[] = {
> OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS},
> {"seg_format_options", "Set options for segment demuxer",
> OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
> + {"seg_append_http_get_params", "Segment request append http get parameters 0 = disable 1 = enable",
> + OFFSET(seg_append_http_get_params), AV_OPT_TYPE_BOOL,{.i64 = 0}, 0, 1, FLAGS},
> {NULL}
> };
>
> --
> 2.32.1 (Apple Git-133)
>
> _______________________________________________
> 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".
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-31 13:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 13:12 [FFmpeg-devel] [PATCH v1] lavf/hls: add option for hls segment request append http get request parameters mirsfang
-- strict thread matches above, loose matches on Subject: below --
2022-08-31 7:13 mirsfang
2022-08-31 7:22 ` Steven Liu
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git