summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorPierre-Anthony Lemieux <pal@palemieux.com>2021-12-14 16:35:14 -0800
committerZane van Iperen <zane@zanevaniperen.com>2021-12-19 00:35:24 +1000
commitc8b5f2848dcdc7103a5b85c50c4c3082382d1f82 (patch)
tree699e92914d599952d1bff0c485387175ad1cb694 /libavformat/aviobuf.c
parenta8a7c5d502a851d16c4668e03bff12d0e16c32b8 (diff)
avformat/aviobuf: ffio_copy_url_options
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 14d4b8f240..29d4bd7510 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1020,6 +1020,30 @@ URLContext* ffio_geturlcontext(AVIOContext *s)
return NULL;
}
+int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts)
+{
+ const char *opts[] = {
+ "headers", "user_agent", "cookies", "http_proxy", "referer", "rw_timeout", "icy", NULL };
+ const char **opt = opts;
+ uint8_t *buf = NULL;
+ int ret = 0;
+
+ while (*opt) {
+ if (av_opt_get(pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
+ if (buf[0] != '\0') {
+ ret = av_dict_set(avio_opts, *opt, buf, AV_DICT_DONT_STRDUP_VAL);
+ if (ret < 0)
+ return ret;
+ } else {
+ av_freep(&buf);
+ }
+ }
+ opt++;
+ }
+
+ return ret;
+}
+
static void update_checksum(AVIOContext *s)
{
if (s->update_checksum && s->buf_ptr > s->checksum_ptr) {