From patchwork Tue Jul 27 14:48:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29070 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp4919716pxb; Tue, 27 Jul 2021 07:49:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOXjO3YWJgwpfSMDxIf3B/ZYi2xG/MreMLcn6D0CkpdenXvo9AxaEdiwsv0fX2bigT65RZ X-Received: by 2002:a17:906:94cd:: with SMTP id d13mr5123490ejy.158.1627397343712; Tue, 27 Jul 2021 07:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627397343; cv=none; d=google.com; s=arc-20160816; b=BljyNMYdervBWnuKZopI1+YNrTubpC9SjLguPhsw3TQSpHVoagcv196I7CAkKGm+j+ D285aMe5CWaGOTl63kLkMdRUV3tFXf/FHMt9fRb7MtmmrlA9oRkO0glpV8HZNpeBKYq8 JaRT6LAFUGYRFnH9asuKDGgQGC0PIx90m77vF0ib9zPkVhNQ94sGaUr3pKsMOs3eXtWJ /b0uWiICyYEXd1dIwkH25Iwr9Bjz4T5aU47G03yx6bFBYJgGoMLFLbXqDl4j280ovpQf THaZjQLA9WegbjHx+a8sZBwy8BqPYdU1joVEzlnzgYQIQC7l1DGqXZo0GK8EsvE+KQyv iAZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=XWQR0n8HywHimPfckrp0tXG5hqftpyqqXZ8tv0/87aY=; b=0uOnJzrTSnTsdnT/1Qhq1fBmHoSzVmREi8UYapLujH5yQGANs5TkpLZGmi3v5i9zXw hDwh2BUBaihbDwo12sx+BuXk906QX7PKYfETXCKHj+62DxS2dOIaGqTdKElZTxarkmXV xgzRXjJHowhxpgJb9kWtg4TcPmK9btX2e+Y3CNP0e0aySKWeHdCg/9rQCjzgov0b6XOJ 2uCehm9rpzOXI00XIA1lsRw4KfkK95HYehk27kcpulwO+o9M2MI+hghtdmnRKl+HTDb+ dbJEowAlRaBTM7dIbSlQFGXBgFCfmvq8iVNbE5HB0D1iW2BAzmuAqVlXTkgLicyc+PrT WbRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i11si3302671edv.472.2021.07.27.07.49.03; Tue, 27 Jul 2021 07:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D298968A066; Tue, 27 Jul 2021 17:48:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 772686881B5 for ; Tue, 27 Jul 2021 17:48:18 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 16REmHq6026200 for ; Tue, 27 Jul 2021 16:48:18 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id A7A6AE0027; Tue, 27 Jul 2021 16:48:17 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Jul 2021 16:48:06 +0200 Message-Id: <20210727144813.452917-4-george@nsup.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727144813.452917-1-george@nsup.org> References: <20210727144813.452917-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Tue, 27 Jul 2021 16:48:18 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 03/10] lavfi: add fs protocol as synonym for file. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0NOCDGx/I1Tx Signed-off-by: Nicolas George --- libavformat/file.c | 47 ++++++++++++++++++++++++++++++++++++----- libavformat/protocols.c | 1 + 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 8303436be0..2fb93c23fd 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -203,17 +203,15 @@ static int file_move(URLContext *h_src, URLContext *h_dst) return 0; } -#if CONFIG_FILE_PROTOCOL +#if CONFIG_FILE_PROTOCOL || CONFIG_FS_PROTOCOL -static int file_open(URLContext *h, const char *filename, int flags) +static int file_open_common(URLContext *h, const char *filename, int flags) { FileContext *c = h->priv_data; int access; int fd; struct stat st; - av_strstart(filename, "file:", &filename); - if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) { access = O_CREAT | O_RDWR; if (c->trunc) @@ -353,6 +351,16 @@ static int file_close_dir(URLContext *h) #endif /* HAVE_LSTAT */ } +#endif /* CONFIG_FILE_PROTOCOL || CONFIG_FS_PROTOCOL */ + +#if CONFIG_FILE_PROTOCOL + +static int file_open(URLContext *h, const char *filename, int flags) +{ + av_strstart(filename, "file:", &filename); + return file_open_common(h, filename, flags); +} + const URLProtocol ff_file_protocol = { .name = "file", .url_open = file_open, @@ -369,11 +377,40 @@ 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,data" + .default_whitelist = "file,fs,crypto,data" }; #endif /* CONFIG_FILE_PROTOCOL */ +#if CONFIG_FS_PROTOCOL + +static int fs_open(URLContext *h, const char *filename, int flags) +{ + av_strstart(filename, "fs:", &filename); + return file_open_common(h, filename, flags); +} + +const URLProtocol ff_fs_protocol = { + .name = "fs", + .url_open = fs_open, + .url_read = file_read, + .url_write = file_write, + .url_seek = file_seek, + .url_close = file_close, + .url_get_file_handle = file_get_handle, + .url_check = file_check, + .url_delete = file_delete, + .url_move = file_move, + .priv_data_size = sizeof(FileContext), + .priv_data_class = &file_class, + .url_open_dir = file_open_dir, + .url_read_dir = file_read_dir, + .url_close_dir = file_close_dir, + .default_whitelist = "file,fs,crypto,data" +}; + +#endif /* CONFIG_FS_PROTOCOL */ + #if CONFIG_PIPE_PROTOCOL static int pipe_open(URLContext *h, const char *filename, int flags) diff --git a/libavformat/protocols.c b/libavformat/protocols.c index 7f08f151b6..a0035da590 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -33,6 +33,7 @@ extern const URLProtocol ff_data_protocol; extern const URLProtocol ff_ffrtmpcrypt_protocol; extern const URLProtocol ff_ffrtmphttp_protocol; extern const URLProtocol ff_file_protocol; +extern const URLProtocol ff_fs_protocol; extern const URLProtocol ff_ftp_protocol; extern const URLProtocol ff_gopher_protocol; extern const URLProtocol ff_gophers_protocol;