From patchwork Thu May 28 20:15:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 19955 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 F20D044ACB3 for ; Thu, 28 May 2020 23:19:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF53D68AFA0; Thu, 28 May 2020 23:16:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (unknown [176.97.15.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 90AD668AFBC for ; Thu, 28 May 2020 23:16:30 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 9BBA828A6E4 for ; Thu, 28 May 2020 22:16:28 +0200 (CEST) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TOSfvyERPaKR for ; Thu, 28 May 2020 22:16:27 +0200 (CEST) Received: from quelana.khirnov.net (quelana.khirnov.net [IPv6:2a00:c500:561:200::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) client-signature RSA-PSS (2048 bits)) (Client CN "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id 4294F28A6F4 for ; Thu, 28 May 2020 22:16:22 +0200 (CEST) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id F2ABA20279 for ; Thu, 28 May 2020 22:16:21 +0200 (CEST) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id n72KStaWlpM1 for ; Thu, 28 May 2020 22:16:21 +0200 (CEST) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 91AF222E63 for ; Thu, 28 May 2020 22:16:15 +0200 (CEST) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id F2DB920E0146; Thu, 28 May 2020 22:16:12 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 May 2020 22:15:57 +0200 Message-Id: <20200528201559.22618-15-anton@khirnov.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200528201559.22618-1-anton@khirnov.net> References: <20200528201559.22618-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/17] URLContext: switch to child_class_iterate() 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" --- libavformat/avio.c | 3 +++ libavformat/protocols.c | 16 ++++++++++++++++ libavformat/url.h | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index 237966c303..3886ed7a90 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -67,7 +67,10 @@ const AVClass ffurl_context_class = { .option = options, .version = LIBAVUTIL_VERSION_INT, .child_next = urlcontext_child_next, +#if FF_API_CHILD_CLASS_NEXT .child_class_next = ff_urlcontext_child_class_next, +#endif + .child_class_iterate = ff_urlcontext_child_class_iterate, }; /*@}*/ diff --git a/libavformat/protocols.c b/libavformat/protocols.c index f1b8eab0fd..7df18fbb3b 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -73,6 +73,7 @@ extern const URLProtocol ff_libzmq_protocol; #include "libavformat/protocol_list.c" +#if FF_API_CHILD_CLASS_NEXT const AVClass *ff_urlcontext_child_class_next(const AVClass *prev) { int i; @@ -91,7 +92,22 @@ const AVClass *ff_urlcontext_child_class_next(const AVClass *prev) return url_protocols[i]->priv_data_class; return NULL; } +#endif +const AVClass *ff_urlcontext_child_class_iterate(void **iter) +{ + const AVClass *ret = NULL; + uintptr_t i; + + for (i = (uintptr_t)*iter; url_protocols[i]; i++) { + ret = url_protocols[i]->priv_data_class; + if (ret) + break; + } + + *iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i); + return ret; +} const char *avio_enum_protocols(void **opaque, int output) { diff --git a/libavformat/url.h b/libavformat/url.h index 4750bfff82..de0d30aca0 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -322,7 +322,11 @@ void ff_make_absolute_url(char *buf, int size, const char *base, */ AVIODirEntry *ff_alloc_dir_entry(void); +#if FF_API_CHILD_CLASS_NEXT const AVClass *ff_urlcontext_child_class_next(const AVClass *prev); +#endif + +const AVClass *ff_urlcontext_child_class_iterate(void **iter); /** * Construct a list of protocols matching a given whitelist and/or blacklist.