From patchwork Tue Sep 24 03:08:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 15243 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 729EE449BE5 for ; Tue, 24 Sep 2019 06:08:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4657F68A1B8; Tue, 24 Sep 2019 06:08:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6CD0689EEA for ; Tue, 24 Sep 2019 06:08:48 +0300 (EEST) X-QQ-mid: bizesmtp20t1569294519tgc0b4ps Received: from localhost (unknown [49.7.58.242]) by esmtp6.qq.com (ESMTP) with id ; Tue, 24 Sep 2019 11:08:38 +0800 (CST) X-QQ-SSF: 01100000002000K0ZQF0000A0000000 X-QQ-FEAT: +52Xi0nxjsT0m6RsHij5Bc/ha1Tx548c3wa0L2gP35H3lboAYecyg2B/0TLIj Tm7Z+0tq+vZITB4Z270uDocbnJx6LDJE24i32Nd05FlSawWZBrD4ELoirTpR8zAPTbEIZMf VqxdKMy+E5wP9wUU7y6JVWfzuWWUr4hw1B0W1M01pteUgsmSaNTDjeFjlWXbkvcNNcZ0XtS /WgRJBrolSt8UCHK4kQsSfTJ6kEIKi0cjmvs9GpOmAxTl1FodsgixucHiuGwH5RC1nui9JJ z3AWQAMhtnyLBA75CeP3QsLVqZ6/kyTChRlAH2HslqEMZs/RaJfAr7XbIjvacYMa2EHA== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Sep 2019 11:08:34 +0800 Message-Id: <20190924030834.15149-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.17.2 (Apple Git-113) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hls: support data protocol in uri for EXT-X-MAP X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Steven Liu --- libavformat/file.c | 4 ++-- libavformat/hls.c | 12 ++++++++++-- libavformat/http.c | 2 +- 3 files changed, 13 insertions(+), 5 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 0611ddc6bb..27a802bbaf 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -409,7 +409,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); @@ -620,7 +624,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, int ret; int is_http = 0; - if (av_strstart(url, "crypto", NULL)) { + if (av_strstart(url, "crypto", NULL) || av_strstart(url, "data", NULL)) { if (url[6] == '+' || url[6] == ':') proto_name = avio_find_protocol_name(url + 7); } @@ -642,6 +646,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; @@ -649,6 +655,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 71dd6c2b1f..e87818aa30 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1785,7 +1785,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 */