From patchwork Fri Jan 10 11:21:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 17276 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 1D5E344AD70 for ; Fri, 10 Jan 2020 13:21:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0488768A7B8; Fri, 10 Jan 2020 13:21:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B922680083 for ; Fri, 10 Jan 2020 13:21:26 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id C2FCF29489B for ; Fri, 10 Jan 2020 12:21:25 +0100 (CET) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id I32xLrHsRIzg for ; Fri, 10 Jan 2020 12:21:24 +0100 (CET) Received: from quelana.khirnov.net (unknown [IPv6:2002:b061:f0a:201:5e:e696:5100:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id 89978294875 for ; Fri, 10 Jan 2020 12:21:24 +0100 (CET) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id 31BAE7FEDE for ; Fri, 10 Jan 2020 12:21:20 +0100 (CET) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NuR3dus-Yivz for ; Fri, 10 Jan 2020 12:21:19 +0100 (CET) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 00A937F90B for ; Fri, 10 Jan 2020 12:21:18 +0100 (CET) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id 6CB6420E024A; Fri, 10 Jan 2020 12:21:14 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Jan 2020 12:21:07 +0100 Message-Id: <20200110112108.22983-1-anton@khirnov.net> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] examples/avio_dir_cmd: drop support for move/delete operations 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" They use non-public functions, which is unacceptable for a public API example. Rename the example back to avio_list_dir. This effectively reverts c84d208c275d6a43b3c3421d38772179abf8acee and 767d780ec001167b2fd8f6cfe4ef78a3a8b1e34c. --- configure | 4 +- doc/examples/.gitignore | 2 +- doc/examples/Makefile | 2 +- doc/examples/Makefile.example | 2 +- .../{avio_dir_cmd.c => avio_list_dir.c} | 56 ++----------------- 5 files changed, 9 insertions(+), 57 deletions(-) rename doc/examples/{avio_dir_cmd.c => avio_list_dir.c} (69%) diff --git a/configure b/configure index 46f2038627..65a5a30f36 100755 --- a/configure +++ b/configure @@ -1664,7 +1664,7 @@ COMPONENT_LIST=" " EXAMPLE_LIST=" - avio_dir_cmd_example + avio_list_dir_example avio_reading_example decode_audio_example decode_video_example @@ -3599,7 +3599,7 @@ yadif_cuda_filter_deps="ffnvcodec" yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm" # examples -avio_dir_cmd_deps="avformat avutil" +avio_list_dir_deps="avformat avutil" avio_reading_deps="avformat avcodec avutil" decode_audio_example_deps="avcodec avutil" decode_video_example_deps="avcodec avutil" diff --git a/doc/examples/.gitignore b/doc/examples/.gitignore index 75152cb50b..44960e1de7 100644 --- a/doc/examples/.gitignore +++ b/doc/examples/.gitignore @@ -1,4 +1,4 @@ -/avio_dir_cmd +/avio_list_dir /avio_reading /decode_audio /decode_video diff --git a/doc/examples/Makefile b/doc/examples/Makefile index 2935424e54..81bfd34d5d 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -1,4 +1,4 @@ -EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd +EXAMPLES-$(CONFIG_AVIO_LIST_DIR_EXAMPLE) += avio_list_dir EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video diff --git a/doc/examples/Makefile.example b/doc/examples/Makefile.example index 6428154c51..a232d97f98 100644 --- a/doc/examples/Makefile.example +++ b/doc/examples/Makefile.example @@ -11,7 +11,7 @@ CFLAGS += -Wall -g CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS) LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) -EXAMPLES= avio_dir_cmd \ +EXAMPLES= avio_list_dir \ avio_reading \ decode_audio \ decode_video \ diff --git a/doc/examples/avio_dir_cmd.c b/doc/examples/avio_list_dir.c similarity index 69% rename from doc/examples/avio_dir_cmd.c rename to doc/examples/avio_list_dir.c index 0722bd9ab1..3073baaefa 100644 --- a/doc/examples/avio_dir_cmd.c +++ b/doc/examples/avio_list_dir.c @@ -102,38 +102,15 @@ static int list_op(const char *input_dir) return ret; } -static int del_op(const char *url) -{ - int ret = avpriv_io_delete(url); - if (ret < 0) - av_log(NULL, AV_LOG_ERROR, "Cannot delete '%s': %s.\n", url, av_err2str(ret)); - return ret; -} - -static int move_op(const char *src, const char *dst) -{ - int ret = avpriv_io_move(src, dst); - if (ret < 0) - av_log(NULL, AV_LOG_ERROR, "Cannot move '%s' into '%s': %s.\n", src, dst, av_err2str(ret)); - return ret; -} - - static void usage(const char *program_name) { - fprintf(stderr, "usage: %s OPERATION entry1 [entry2]\n" - "API example program to show how to manipulate resources " - "accessed through AVIOContext.\n" - "OPERATIONS:\n" - "list list content of the directory\n" - "move rename content in directory\n" - "del delete content in directory\n", - program_name); + fprintf(stderr, "usage: %s input_dir\n" + "API example program to show how to list files in directory " + "accessed through AVIOContext.\n", program_name); } int main(int argc, char *argv[]) { - const char *op = NULL; int ret; av_log_set_level(AV_LOG_DEBUG); @@ -145,32 +122,7 @@ int main(int argc, char *argv[]) avformat_network_init(); - op = argv[1]; - if (strcmp(op, "list") == 0) { - if (argc < 3) { - av_log(NULL, AV_LOG_INFO, "Missing argument for list operation.\n"); - ret = AVERROR(EINVAL); - } else { - ret = list_op(argv[2]); - } - } else if (strcmp(op, "del") == 0) { - if (argc < 3) { - av_log(NULL, AV_LOG_INFO, "Missing argument for del operation.\n"); - ret = AVERROR(EINVAL); - } else { - ret = del_op(argv[2]); - } - } else if (strcmp(op, "move") == 0) { - if (argc < 4) { - av_log(NULL, AV_LOG_INFO, "Missing argument for move operation.\n"); - ret = AVERROR(EINVAL); - } else { - ret = move_op(argv[2], argv[3]); - } - } else { - av_log(NULL, AV_LOG_INFO, "Invalid operation %s\n", op); - ret = AVERROR(EINVAL); - } + ret = list_op(argv[1]); avformat_network_deinit(); From patchwork Fri Jan 10 11:21:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 17277 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 ED66544AD70 for ; Fri, 10 Jan 2020 13:21:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E00DF68A8AA; Fri, 10 Jan 2020 13:21:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 67B2868A7D8 for ; Fri, 10 Jan 2020 13:21:28 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 1E76829489C for ; Fri, 10 Jan 2020 12:21:28 +0100 (CET) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wbgYsNkWKbMU for ; Fri, 10 Jan 2020 12:21:27 +0100 (CET) Received: from quelana.khirnov.net (unknown [IPv6:2a00:c500:61:23b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id 9A52A294875 for ; Fri, 10 Jan 2020 12:21:27 +0100 (CET) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id 87B697FEDF for ; Fri, 10 Jan 2020 12:21:24 +0100 (CET) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jzUZZM1fPPjC for ; Fri, 10 Jan 2020 12:21:21 +0100 (CET) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 077877FDD1 for ; Fri, 10 Jan 2020 12:21:18 +0100 (CET) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id 8BA6F20E0011; Fri, 10 Jan 2020 12:21:14 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Jan 2020 12:21:08 +0100 Message-Id: <20200110112108.22983-2-anton@khirnov.net> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200110112108.22983-1-anton@khirnov.net> References: <20200110112108.22983-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avio: do not export avpriv_io_{move, delete} 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" They are private and not used by anything outside of lavf. There is no reason for them to be exported. --- libavformat/avio.c | 4 ++-- libavformat/avio.h | 19 ------------------- libavformat/dashenc.c | 10 +++++----- libavformat/url.h | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 2dd2312296..3e390fe719 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -494,7 +494,7 @@ int avio_check(const char *url, int flags) return ret; } -int avpriv_io_move(const char *url_src, const char *url_dst) +int ffurl_move(const char *url_src, const char *url_dst) { URLContext *h_src, *h_dst; int ret = ffurl_alloc(&h_src, url_src, AVIO_FLAG_READ_WRITE, NULL); @@ -516,7 +516,7 @@ int avpriv_io_move(const char *url_src, const char *url_dst) return ret; } -int avpriv_io_delete(const char *url) +int ffurl_delete(const char *url) { URLContext *h; int ret = ffurl_alloc(&h, url, AVIO_FLAG_WRITE, NULL); diff --git a/libavformat/avio.h b/libavformat/avio.h index 9141642e75..34c5957791 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -374,25 +374,6 @@ const char *avio_find_protocol_name(const char *url); */ int avio_check(const char *url, int flags); -/** - * Move or rename a resource. - * - * @note url_src and url_dst should share the same protocol and authority. - * - * @param url_src url to resource to be moved - * @param url_dst new url to resource if the operation succeeded - * @return >=0 on success or negative on error. - */ -int avpriv_io_move(const char *url_src, const char *url_dst); - -/** - * Delete a resource. - * - * @param url resource to be deleted. - * @return >=0 on success or negative on error. - */ -int avpriv_io_delete(const char *url); - /** * Open directory for reading. * diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index b84736881f..46041337c2 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -540,7 +540,7 @@ static void write_hls_media_playlist(OutputStream *os, AVFormatContext *s, dashenc_io_close(s, &c->m3u8_out, temp_filename_hls); if (use_rename) - if (avpriv_io_move(temp_filename_hls, filename_hls) < 0) { + if (ffurl_move(temp_filename_hls, filename_hls) < 0) { av_log(os->ctx, AV_LOG_WARNING, "renaming file %s to %s failed\n\n", temp_filename_hls, filename_hls); } } @@ -1037,7 +1037,7 @@ static int write_manifest(AVFormatContext *s, int final) dashenc_io_close(s, &c->mpd_out, temp_filename); if (use_rename) { - if ((ret = avpriv_io_move(temp_filename, s->url)) < 0) + if ((ret = ffurl_move(temp_filename, s->url)) < 0) return ret; } @@ -1119,7 +1119,7 @@ static int write_manifest(AVFormatContext *s, int final) } dashenc_io_close(s, &c->m3u8_out, temp_filename); if (use_rename) - if ((ret = avpriv_io_move(temp_filename, filename_hls)) < 0) + if ((ret = ffurl_move(temp_filename, filename_hls)) < 0) return ret; c->master_playlist_created = 1; } @@ -1507,7 +1507,7 @@ static void dashenc_delete_file(AVFormatContext *s, char *filename) { av_dict_free(&http_opts); ff_format_io_close(s, &out); } else { - int res = avpriv_io_delete(filename); + int res = ffurl_delete(filename); if (res < 0) { char errbuf[AV_ERROR_MAX_STRING_SIZE]; av_strerror(res, errbuf, sizeof(errbuf)); @@ -1619,7 +1619,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream) dashenc_io_close(s, &os->out, os->temp_path); if (use_rename) { - ret = avpriv_io_move(os->temp_path, os->full_path); + ret = ffurl_move(os->temp_path, os->full_path); if (ret < 0) break; } diff --git a/libavformat/url.h b/libavformat/url.h index 4750bfff82..98ac6e3ccd 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -340,4 +340,24 @@ const AVClass *ff_urlcontext_child_class_next(const AVClass *prev); const URLProtocol **ffurl_get_protocols(const char *whitelist, const char *blacklist); +/** + * Move or rename a resource. + * + * @note url_src and url_dst should share the same protocol and authority. + * + * @param url_src url to resource to be moved + * @param url_dst new url to resource if the operation succeeded + * @return >=0 on success or negative on error. + */ +int ffurl_move(const char *url_src, const char *url_dst); + +/** + * Delete a resource. + * + * @param url resource to be deleted. + * @return >=0 on success or negative on error. + */ +int ffurl_delete(const char *url); + + #endif /* AVFORMAT_URL_H */