From patchwork Fri Oct 9 20:18:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 22801 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 53E7A44A118 for ; Fri, 9 Oct 2020 23:25:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B7E568BA1D; Fri, 9 Oct 2020 23:25:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B076D68BA0C for ; Fri, 9 Oct 2020 23:25:33 +0300 (EEST) Received: by mail-qk1-f193.google.com with SMTP id v123so11922836qkd.9 for ; Fri, 09 Oct 2020 13:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=68ycgKC2/ozu7Z1smYATDJ/AlyudbPimZDFh1zhsy+I=; b=RW1CEOs2RopdVATjMAPLkCCK70RxA7sUmoldbVx2Nw8tHGtUTmSywXi9ChCX64h80j Hi0EgLnLHVSTDUtoxhgzT89pBBq9LJYzteXBoGzyR7K2KQdGLjyvUlB4rnlF+D0jwneM aDLjD7LSytkqiGjDTYqV5gD5GMDMMENUnWDXMD/5PYJIB86c/jNZhNNodavlijPRKR2S egl9Jug8ZIMsX1/23jmWTGoFHdhdaG62KKEvjxwxkmg3g5mgDex+/s7bbtDuYCClh/4t wrhpdM7ulRr7YisFLVZw6MPL0TftlDhJkj8YuUWBIjMoZTI9twX+dsMy7grD4kiUGrlo TkVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=68ycgKC2/ozu7Z1smYATDJ/AlyudbPimZDFh1zhsy+I=; b=M7cbAEq0LcpYXw+t/g5GPirrsnSHJ890+bJ1TnfOz2a43HRy2esBM7ZbAJyQllwjut obLYoMdU19PvDfYAG+stf7FCy4uDUtJbuYr3TmwxdqqbAYRvhyAUPeHApfD8hCTgMU86 PJfQfc4tJI5OuBWNYV1Fc0Y2DV5o8RtFeN5L3c//DJaN7HJH4pB6yzJ2MvI/16hVRerK uEmRM4TbwWJSTqbLbcFS+0yRQh6CKJc0XVeZeYQcuNaRn6s4+cAOww4v/4giRUm0NMGp ilHnNTTHlUoESbxpNWpGfqMYckXInNwQSUT0LrRQ14i+yHvwDYB5CmSC641BehcshcpX Bz4w== X-Gm-Message-State: AOAM5301YX8xRK1ryFUAecm+S+FpSTpe0uXouXKxAzsk6oX27gsLlkvK /WAxrrbBYskNHQdQEvX0q/QY6VfaxqAZgw== X-Google-Smtp-Source: ABdhPJyrlkkv48zb895XvJR0Q4ZmFx3dQZkGOKIgFOWCZdJNC2FQWUlz9C3TwTxjD0F7r3xWN87S/A== X-Received: by 2002:ac8:f6d:: with SMTP id l42mr15969750qtk.367.1602274742553; Fri, 09 Oct 2020 13:19:02 -0700 (PDT) Received: from localhost.localdomain ([181.23.78.153]) by smtp.gmail.com with ESMTPSA id o47sm7146591qtk.21.2020.10.09.13.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 13:19:01 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Oct 2020 17:18:10 -0300 Message-Id: <20201009201811.10710-2-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201009201811.10710-1-jamrial@gmail.com> References: <20201009201811.10710-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avdevice: add new API for iterating input and output devices 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" And deprecate the linked list based one. Based on a patch by Josh de Kock. Signed-off-by: James Almer --- doc/APIchanges | 5 +++++ libavdevice/alldevices.c | 22 ++++++++++++++++++++++ libavdevice/avdevice.h | 36 ++++++++++++++++++++++++++++++++++++ libavdevice/version.h | 7 +++++-- 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f2830968bb..ae1f9ace77 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,11 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-10-xx - xxxxxxxxxx - lavd 58.12.100 - avdevice.h + Deprecate use of av_input_audio_device_next(), av_input_video_device_next(), + av_output_audio_device_next(), av_output_video_device_next(). + Add av_indev_iterate(), and av_outdev_iterate(). + 2020-xx-xx - xxxxxxxxxx - lavu 56.60.100 - buffer.h Add a av_buffer_replace() convenience function. diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index 4137f60109..2f17e9f33b 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -63,11 +63,32 @@ extern AVInputFormat ff_libdc1394_demuxer; #include "libavdevice/outdev_list.c" #include "libavdevice/indev_list.c" +const AVOutputFormat *av_outdev_iterate(void **opaque) +{ + uintptr_t i = (uintptr_t)*opaque; + const AVOutputFormat *f = outdev_list[i]; + + if (f) + *opaque = (void*)(i + 1); + return f; +} + +const AVInputFormat *av_indev_iterate(void **opaque) +{ + uintptr_t i = (uintptr_t)*opaque; + const AVInputFormat *f = indev_list[i]; + + if (f) + *opaque = (void*)(i + 1); + return f; +} + void avdevice_register_all(void) { avpriv_register_devices(outdev_list, indev_list); } +#if FF_API_DEVICE_NEXT static void *next_input(AVInputFormat *prev, AVClassCategory c2) { const AVClass *pc; @@ -143,3 +164,4 @@ AVOutputFormat *av_output_video_device_next(AVOutputFormat *d) { return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT); } +#endif diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index ee9462480e..388f93c155 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -70,13 +70,39 @@ const char *avdevice_license(void); */ void avdevice_register_all(void); +/** + * Iterate over all registered output devices. + * + * @param opaque a pointer where libavdevice will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered output device or NULL when the iteration is + * finished + */ +const AVOutputFormat *av_outdev_iterate(void **opaque); + +/** + * Iterate over all registered input devices. + * + * @param opaque a pointer where libavdevice will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered input device or NULL when the iteration is + * finished + */ +const AVInputFormat *av_indev_iterate(void **opaque); + +#if FF_API_DEVICE_NEXT /** * Audio input devices iterator. * * If d is NULL, returns the first registered input audio/video device, * if d is non-NULL, returns the next registered input audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_indev_iterate() instead */ +attribute_deprecated AVInputFormat *av_input_audio_device_next(AVInputFormat *d); /** @@ -85,7 +111,10 @@ AVInputFormat *av_input_audio_device_next(AVInputFormat *d); * If d is NULL, returns the first registered input audio/video device, * if d is non-NULL, returns the next registered input audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_indev_iterate() instead */ +attribute_deprecated AVInputFormat *av_input_video_device_next(AVInputFormat *d); /** @@ -94,7 +123,10 @@ AVInputFormat *av_input_video_device_next(AVInputFormat *d); * If d is NULL, returns the first registered output audio/video device, * if d is non-NULL, returns the next registered output audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_outdev_iterate() instead */ +attribute_deprecated AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d); /** @@ -103,8 +135,12 @@ AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d); * If d is NULL, returns the first registered output audio/video device, * if d is non-NULL, returns the next registered output audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_outdev_iterate() instead */ +attribute_deprecated AVOutputFormat *av_output_video_device_next(AVOutputFormat *d); +#endif typedef struct AVDeviceRect { int x; /**< x coordinate of top left corner */ diff --git a/libavdevice/version.h b/libavdevice/version.h index e3aca9e3d2..7f5f46e428 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 58 -#define LIBAVDEVICE_VERSION_MINOR 11 -#define LIBAVDEVICE_VERSION_MICRO 102 +#define LIBAVDEVICE_VERSION_MINOR 12 +#define LIBAVDEVICE_VERSION_MICRO 100 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ @@ -46,5 +46,8 @@ * dropped at a future version bump. The defines themselves are not part of * the public API and may change, break or disappear at any time. */ +#ifndef FF_API_DEVICE_NEXT +#define FF_API_DEVICE_NEXT (LIBAVDEVICE_VERSION_MAJOR < 60) +#endif #endif /* AVDEVICE_VERSION_H */