summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2019-09-24 11:18:59 +0800
committerSteven Liu <lq@chinaffmpeg.org>2020-01-18 22:41:11 +0800
commitb9606064c406a1e2a169590ff098c8edb7516bae (patch)
tree703cd6bce15f8669a2240562599459187c1c7f62 /libavformat
parent62a0d226212d5e0857c62effb1cb41e5f4af6707 (diff)
avformat/hls: support data protocol in uri for EXT-X-MAP
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/file.c4
-rw-r--r--libavformat/hls.c13
-rw-r--r--libavformat/http.c2
3 files changed, 15 insertions, 4 deletions
diff --git a/libavformat/file.c b/libavformat/file.c
index 08c7f8e6dd..8303436be0 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -369,7 +369,7 @@ const URLProtocol ff_file_protocol = {
.url_open_dir = file_open_dir,
.url_read_dir = file_read_dir,
.url_close_dir = file_close_dir,
- .default_whitelist = "file,crypto"
+ .default_whitelist = "file,crypto,data"
};
#endif /* CONFIG_FILE_PROTOCOL */
@@ -408,7 +408,7 @@ const URLProtocol ff_pipe_protocol = {
.url_check = file_check,
.priv_data_size = sizeof(FileContext),
.priv_data_class = &pipe_class,
- .default_whitelist = "crypto"
+ .default_whitelist = "crypto,data"
};
#endif /* CONFIG_PIPE_PROTOCOL */
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 538af0dbf8..31d7f5526a 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -413,7 +413,11 @@ static struct segment *new_init_section(struct playlist *pls,
if (!sec)
return NULL;
- ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
+ if (!av_strncasecmp(info->uri, "data:", 5)) {
+ strncpy(tmp_str, info->uri, strlen(info->uri));
+ } else {
+ ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri);
+ }
sec->url = av_strdup(tmp_str);
if (!sec->url) {
av_free(sec);
@@ -627,6 +631,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
if (av_strstart(url, "crypto", NULL)) {
if (url[6] == '+' || url[6] == ':')
proto_name = avio_find_protocol_name(url + 7);
+ } else if (av_strstart(url, "data", NULL)) {
+ if (url[4] == '+' || url[4] == ':')
+ proto_name = avio_find_protocol_name(url + 5);
}
if (!proto_name)
@@ -646,6 +653,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
}
} else if (av_strstart(proto_name, "http", NULL)) {
is_http = 1;
+ } else if (av_strstart(proto_name, "data", NULL)) {
+ ;
} else
return AVERROR_INVALIDDATA;
@@ -653,6 +662,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
;
else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] == ':')
;
+ else if (av_strstart(url, "data", NULL) && !strncmp(proto_name, url + 5, strlen(proto_name)) && url[5 + strlen(proto_name)] == ':')
+ ;
else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
return AVERROR_INVALIDDATA;
diff --git a/libavformat/http.c b/libavformat/http.c
index 85cbd06092..142511d091 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1791,7 +1791,7 @@ const URLProtocol ff_http_protocol = {
.priv_data_size = sizeof(HTTPContext),
.priv_data_class = &http_context_class,
.flags = URL_PROTOCOL_FLAG_NETWORK,
- .default_whitelist = "http,https,tls,rtp,tcp,udp,crypto,httpproxy"
+ .default_whitelist = "http,https,tls,rtp,tcp,udp,crypto,httpproxy,data"
};
#endif /* CONFIG_HTTP_PROTOCOL */