From patchwork Mon Jun 7 23:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28142 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp3886352iof; Mon, 7 Jun 2021 16:05:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWDASm6i/ksmhDoBr+YtjbPD5bDUm5r2qIT6plDCIcLeHbiLbt4mowiJqV09CsB7r/ygT+ X-Received: by 2002:aa7:c547:: with SMTP id s7mr22048480edr.239.1623107132091; Mon, 07 Jun 2021 16:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623107132; cv=none; d=google.com; s=arc-20160816; b=qkTGYmO4LYa7RPCvJA5Ghl8bMjLC/Jw4Zr8kD0eupFB+Y2BM4bJnRorZd4/Who1FVS beoWiRsftOZ6D9Amr5ve2HSsaHao49kv7EBL35pRRdc+ECPM8pXrBfdUZTcGjJoJTki/ MWfUVw/UH9yKDOFxdqWfjGEMKUg78fpcQ95j2snY9pkfxHUdcffGXJiUDFjQ//xzQP4K PCMSfCkF9MKJXwiiiYQiSJXu2SpuA+EQqT7F9xYkParp4MPiZQoOH3BqC+eRHyG7JU/k AjFZhlYXTfEZof9cKvHwTs2TnWqnoIfE5r32zU6/X2/S+FwRUJ5uX43+0mwC0hDe6ZDa bYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=Y/N+P8islhg0pQRuurco54ewG7OB337mXsFBXbg6K+U=; b=a9bo9UCQ5AUfQyQAsjVMnwFOEWelsqFimvLkErkargIAyOPin9rmtvn227Ad0xkv73 IEPaSB9caYUzMlNVDyKnwFKXFmoz59meG7wsu/qsPX3M97V1tsYjYqi2xu1EIF84p4NY Xp2XSi03rufWOiFWJ2jI2VAU3pD58Lm+xB9l+VMtWp6Crc6s19TWIjfx6eqXQftF5m1f O/WuV6s7lm3YyRiUrrWNwT7bcdDb3oWicZiDspH8fWbZszZ4LjJP6erbkem46kNlpaQB Wl5nS3BzigovM1TsUU7gNpEASpqYvknKopidJaoc6I5pv+/by+ozesa2yrYbCuGUZhE8 aSHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=D29zbJZL; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bq17si382435ejb.171.2021.06.07.16.05.30; Mon, 07 Jun 2021 16:05:32 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=D29zbJZL; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 70F7E680A07; Tue, 8 Jun 2021 02:04:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A08E1680923 for ; Tue, 8 Jun 2021 02:04:47 +0300 (EEST) Received: by mail-lf1-f45.google.com with SMTP id f30so29026516lfj.1 for ; Mon, 07 Jun 2021 16:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jsQe9tTS/A408I+gJNr6RNZYGwNa8iaF53DL4fvUiYU=; b=D29zbJZLLiv2/IeLWyzTAVoU50Tj+cw7gIDqcoevsH6o0Rk/4Vp2CSSHLkbA7qhoa8 mekIfLPB/jo5z3jqrf+a8ZTKyR629pDP1aukfL8RHdU9G7MjJsbZE3P2VF9Md/Sy6293 h/fUW0obxeId+URpehUhNg0v6MgMBoJGC6hUbaLTLHTKK/iNEBEQiwoiGEhqOrYSdqsx tZkYupy5tfkV5qfG9epvK9Lj6hfiEekBBIU43OLqfsMVyR9iV/zcfOOZwRuz3TZGdfvg 3f9jsiqolAXkv3/MnydSvFzhYjq3JqCEMfLMFI/INuIqUOTIyoGP8jRVOpCd2Y0UUEf+ dZuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jsQe9tTS/A408I+gJNr6RNZYGwNa8iaF53DL4fvUiYU=; b=Mlf763U4Tk6EHL6zPzDdIY9tSik6lWx+i8+1Kak0/SMxCSaNepc521Bj75NcASJvxr DY9XIvsvPQjhXVHzJFIjU+VvfVs7GhaNs2tkREBNEVld/AkVHwxqFRbLsv0qDi2+qoMh rFtzuZpNzAFDxtqXp+0shUumM6PtVeyTJHB3rvzliWnS0sfq5swoaRaFuhZRDCU6SPJX P6QgqWWIpOO1zjj9HCMj2BjhSY3kcSkxI+kcCXpQSHwqsQTJPTg0HMm8xJsPQGWwSF6k dxTHNTkmb9Aou2idpv3wO8qCt91RVifoiPuSUti5AdW9VgAkceF0GyQGVOofTOedLGnF gJRA== X-Gm-Message-State: AOAM532OaQG97u3msFFxbdl4Ty9FOzsWfrD5e1Bv+iL6VJk3BfOH2J7/ ouu1um3AvTt8svJu8UMkPJ2h/wDFEADYfA== X-Received: by 2002:a19:6d19:: with SMTP id i25mr10071231lfc.655.1623107086671; Mon, 07 Jun 2021 16:04:46 -0700 (PDT) Received: from localhost.localdomain (84-217-56-54.customers.ownit.se. [84.217.56.54]) by smtp.gmail.com with ESMTPSA id v9sm1999563ljv.131.2021.06.07.16.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 16:04:46 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Jun 2021 01:04:00 +0200 Message-Id: <20210607230414.612-22-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210607230414.612-1-dcnieho@gmail.com> References: <20210607230414.612-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public 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 Cc: Diederick Niehorster Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: oreTauB21Im7 NB: will break build, makes needed corresponding changes to avformat. Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 34 ++++++++++++++++++++-------------- libavdevice/avdevice.h | 42 +++++++++--------------------------------- libavdevice/internal.h | 33 +++++++++++++++++++++++++++++++++ libavdevice/version.h | 2 +- 4 files changed, 63 insertions(+), 48 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index d73d36e1dd..b521516ff5 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -96,51 +96,57 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA return s->control_message_cb(s, type, data, data_size); } -int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, +int avdevice_capabilities_create(void** opaque, AVFormatContext *s, AVDictionary **device_options) { int ret; + AVDeviceCapabilitiesQuery *caps = NULL; av_assert0(s); - av_assert0(caps); + av_assert0(opaque); av_assert0(s->iformat || s->oformat); + *opaque = NULL; if ((s->oformat && !s->oformat->create_device_capabilities) || (s->iformat && !s->iformat->create_device_capabilities)) { - *caps = NULL; return AVERROR(ENOSYS); } - *caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); - if (!(*caps)) + *opaque = caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); + if (!caps) return AVERROR(ENOMEM); - (*caps)->device_context = s; + caps->device_context = s; if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0)) goto fail; if (s->iformat) { - if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0) + if ((ret = s->iformat->create_device_capabilities(s, caps)) < 0) goto fail; } else { - if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0) + if ((ret = s->oformat->create_device_capabilities(s, caps)) < 0) goto fail; } - av_opt_set_defaults(*caps); + av_opt_set_defaults(caps); return 0; fail: av_freep(caps); + *opaque = NULL; return ret; } -void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s) +void avdevice_capabilities_free(void **opaque, AVFormatContext *s) { - if (!s || !caps || !(*caps)) + AVDeviceCapabilitiesQuery *caps; + if (!s || !opaque) + return; + caps = *(AVDeviceCapabilitiesQuery **) opaque; + if (!caps) return; av_assert0(s->iformat || s->oformat); if (s->iformat) { if (s->iformat->free_device_capabilities) - s->iformat->free_device_capabilities(s, *caps); + s->iformat->free_device_capabilities(s, caps); } else { if (s->oformat->free_device_capabilities) - s->oformat->free_device_capabilities(s, *caps); + s->oformat->free_device_capabilities(s, caps); } - av_freep(caps); + av_freep(opaque); } int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 7c5e77df00..389ac0b5f2 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -401,40 +401,15 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, * @endcode */ -/** - * Structure describes device capabilities. - * - * It is used by devices in conjunction with av_device_capabilities AVOption table - * to implement capabilities probing API based on AVOption API. Should not be used directly. - */ -typedef struct AVDeviceCapabilitiesQuery { - const AVClass *av_class; - AVFormatContext *device_context; - enum AVCodecID codec; - enum AVSampleFormat sample_format; - enum AVPixelFormat pixel_format; - int sample_rate; - int channels; - int64_t channel_layout; - int window_width; - int window_height; - int frame_width; - int frame_height; - AVRational fps; -} AVDeviceCapabilitiesQuery; - -/** - * AVOption table used by devices to implement device capabilities API. Should not be used by a user. - */ -extern const AVOption av_device_capabilities[]; - /** * Initialize capabilities probing API based on AVOption API. * * avdevice_capabilities_free() must be called when query capabilities API is * not used anymore. - * - * @param[out] caps Device capabilities data. Pointer to a NULL pointer must be passed. + * + * @param[out] opaque A pointer where the capabilities API state will be stored. Pointer + * to a NULL pointer must be passed and caller must not touch this in + * any way. * @param s Context of the device. * @param device_options An AVDictionary filled with device-private options. * On return this parameter will be destroyed and replaced with a dict @@ -445,16 +420,17 @@ extern const AVOption av_device_capabilities[]; * * @return >= 0 on success, negative otherwise. */ -int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, +int avdevice_capabilities_create(void **opaque, AVFormatContext *s, AVDictionary **device_options); /** * Free resources created by avdevice_capabilities_create() * - * @param caps Device capabilities data to be freed. - * @param s Context of the device. + * @param[out] opaque Pointer to be freed that was returned from + * avdevice_capabilities_create. + * @param s Context of the device. */ -void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s); +void avdevice_capabilities_free(void **opaque, AVFormatContext *s); /** * Structure describes basic parameters of the device. diff --git a/libavdevice/internal.h b/libavdevice/internal.h index 67c90e1f87..fe4be64ee7 100644 --- a/libavdevice/internal.h +++ b/libavdevice/internal.h @@ -20,9 +20,42 @@ #define AVDEVICE_INTERNAL_H #include "libavformat/avformat.h" +#include "libavcodec/codec_id.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" +#include "libavutil/samplefmt.h" av_warn_unused_result int ff_alloc_input_device_context(struct AVFormatContext **avctx, const AVInputFormat *iformat, const char *format); +/** + * Structure describes device capabilities. + * + * It is used by devices in conjunction with av_device_capabilities AVOption table + * to implement capabilities probing API based on AVOption API. Should not be used directly. + */ +typedef struct AVDeviceCapabilitiesQuery { + const AVClass *av_class; + AVFormatContext *device_context; + enum AVCodecID codec; + enum AVSampleFormat sample_format; + enum AVPixelFormat pixel_format; + int sample_rate; + int channels; + int64_t channel_layout; + int window_width; + int window_height; + int frame_width; + int frame_height; + AVRational fps; +} AVDeviceCapabilitiesQuery; + +/** + * AVOption table used by devices to implement device capabilities API. Should not be used by a user. + */ +extern const AVOption av_device_capabilities[]; + #endif diff --git a/libavdevice/version.h b/libavdevice/version.h index 0381d6cd0d..53af6fa0d0 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 59 -#define LIBAVDEVICE_VERSION_MINOR 2 +#define LIBAVDEVICE_VERSION_MINOR 3 #define LIBAVDEVICE_VERSION_MICRO 100 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \