From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 73FEC42E57 for ; Tue, 10 May 2022 17:41:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4CBD468B31C; Tue, 10 May 2022 20:41:07 +0300 (EEST) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B9E7B68B1AC for ; Tue, 10 May 2022 20:41:01 +0300 (EEST) Received: by mail-lj1-f181.google.com with SMTP id g16so21754110lja.3 for ; Tue, 10 May 2022 10:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=YlloZ9pSFgjNSiUbumxrlK/59NIbaq/9p4Q86pniRW0=; b=kR0lEicdLgI0JwUGnrg2NX700dEJqnEPuYJ0nB0dhbkFEmVSwWC5oaAmFfpMgxYk6B F9L7c0tL8c9Rdyby+9XQkXLkNtrsHoq77UUy6O7Q0KSfx1Fpx0rauzdtkHAlLDC/ytSb YXrw3fsE5PjiBpxRWxV6yO7Uq4XGWpSioK4ZOKp2lIwxgh/EJASWpLxUFuaoIq1sRvEg e/Y3CbOHhsXu0YZs7nV5hvLt/nj5Z/BWC08EOmew9rNEWUi2eNIJX20g79gwBj1uZyTq Y3Co/NHoKq/NjLhX4XMwaVnIEEosvA/Wmsqfgcj8YYZ1/w8kbiipQw3VL+BT6jywQT0O e7gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=YlloZ9pSFgjNSiUbumxrlK/59NIbaq/9p4Q86pniRW0=; b=HItz1n6XVTR0i3/M3IxOsNE+BMm/hupCCiQci1ygKU7NNlPeQAGseHVIbNJ9vmyjGO 3DYPE30EMmU2/1CYBNaJaAVNTQGeNGrmoS9p6R60jJ8IGt8nuOpf3v23yfCHY7qw11L5 PqPBW0B7si59SnKr9Zx7chUPbV8py/uWUE+ekXeIxXfKwzyhEsZb4HNNnOHAUjPjCIgO 2VlfXg5fu446CRpkuTG5pysQL4JjpbrJ11BQTFL3g0OuZd/kqgQCeRtiI5/lVBY50IL3 1RTb8Q3a2NKZQygn9uwsAmlxR4o4vIXdO9r54p2MTC4Nkwbo3xTyprShLGrvaGOgWyAl 3YaQ== X-Gm-Message-State: AOAM530j33iF8ojkQF62J4OwKu/zVbl+727oN8Qb0pvTzF8Jx32Pa9Ea h92O+k/cV5vLe6d3F6Xz/6p6C0yqdawWImQmYjhYQpjG X-Google-Smtp-Source: ABdhPJzs+pnay5SVmnQFjyeKEx5VTtVI1X/PgvFc+3HgHnujtOB32PxMQyJsJ2dED49KTDEzOnhPEBeAeoPY2y4kuKc= X-Received: by 2002:a2e:bf1b:0:b0:247:d88b:2b05 with SMTP id c27-20020a2ebf1b000000b00247d88b2b05mr14726781ljr.515.1652204459978; Tue, 10 May 2022 10:40:59 -0700 (PDT) MIME-Version: 1.0 References: <20220330121806.822-1-dcnieho@gmail.com> <20220330121806.822-8-dcnieho@gmail.com> In-Reply-To: From: Hendrik Leppkes Date: Tue, 10 May 2022 19:40:47 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v5 07/21] avdevice/avdevice: Revert "Deprecate AVDevice Capabilities API" 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, May 10, 2022 at 7:25 PM Andreas Rheinhardt wrote: > > Diederick Niehorster: > > This reverts commit 4f49ca7bbc75a9db4cdf93f27f95a668c751f160. The next > > few patches clean up the API and implement this capability for > > avdevice/dshow. > > > > Bumping avformat and avdevice version. > > > > Signed-off-by: Diederick Niehorster > > --- > > libavdevice/avdevice.c | 71 ++++++++++++++++++++++++++++++++++++++---- > > libavdevice/avdevice.h | 5 --- > > libavdevice/version.h | 4 +-- > > libavformat/avformat.h | 21 +++++++++++++ > > libavformat/version.h | 2 +- > > 5 files changed, 89 insertions(+), 14 deletions(-) > > > > diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c > > index 43d3406670..d367189532 100644 > > --- a/libavdevice/avdevice.c > > +++ b/libavdevice/avdevice.c > > @@ -28,11 +28,39 @@ > > #include "libavutil/ffversion.h" > > const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION; > > > > -#if FF_API_DEVICE_CAPABILITIES > > +#define E AV_OPT_FLAG_ENCODING_PARAM > > +#define D AV_OPT_FLAG_DECODING_PARAM > > +#define A AV_OPT_FLAG_AUDIO_PARAM > > +#define V AV_OPT_FLAG_VIDEO_PARAM > > +#define OFFSET(x) offsetof(AVDeviceCapabilitiesQuery, x) > > + > > const AVOption av_device_capabilities[] = { > > + { "codec", "codec", OFFSET(codec), AV_OPT_TYPE_INT, > > + {.i64 = AV_CODEC_ID_NONE}, AV_CODEC_ID_NONE, INT_MAX, E|D|A|V }, > > + { "sample_format", "sample format", OFFSET(sample_format), AV_OPT_TYPE_SAMPLE_FMT, > > + {.i64 = AV_SAMPLE_FMT_NONE}, AV_SAMPLE_FMT_NONE, INT_MAX, E|D|A }, > > + { "sample_rate", "sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, > > + {.i64 = -1}, -1, INT_MAX, E|D|A }, > > + { "channels", "channels", OFFSET(channels), AV_OPT_TYPE_INT, > > + {.i64 = -1}, -1, INT_MAX, E|D|A }, > > + { "channel_layout", "channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, > > + {.i64 = -1}, -1, INT_MAX, E|D|A }, > > + { "pixel_format", "pixel format", OFFSET(pixel_format), AV_OPT_TYPE_PIXEL_FMT, > > + {.i64 = AV_PIX_FMT_NONE}, AV_PIX_FMT_NONE, INT_MAX, E|D|V }, > > + { "window_size", "window size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, > > + {.str = NULL}, -1, INT_MAX, E|D|V }, > > + { "frame_size", "frame size", OFFSET(frame_width), AV_OPT_TYPE_IMAGE_SIZE, > > + {.str = NULL}, -1, INT_MAX, E|D|V }, > > + { "fps", "fps", OFFSET(fps), AV_OPT_TYPE_RATIONAL, > > + {.dbl = -1}, -1, INT_MAX, E|D|V }, > > { NULL } > > }; > > -#endif > > + > > +#undef E > > +#undef D > > +#undef A > > +#undef V > > +#undef OFFSET > > > > unsigned avdevice_version(void) > > { > > @@ -81,18 +109,49 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA > > return s->control_message_cb(s, type, data, data_size); > > } > > > > -#if FF_API_DEVICE_CAPABILITIES > > int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, > > AVDictionary **device_options) > > { > > - return AVERROR(ENOSYS); > > + int ret; > > + av_assert0(s && caps); > > + av_assert0(s->iformat || s->oformat); > > + if ((s->oformat && !s->oformat->create_device_capabilities) || > > + (s->iformat && !s->iformat->create_device_capabilities)) > > + return AVERROR(ENOSYS); > > + *caps = av_mallocz(sizeof(**caps)); > > + if (!(*caps)) > > + return AVERROR(ENOMEM); > > + (*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) > > + goto fail; > > + } else { > > + if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0) > > + goto fail; > > + } > > + av_opt_set_defaults(*caps); > > + return 0; > > + fail: > > + av_freep(caps); > > + return ret; > > } > > > > void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s) > > { > > - return; > > + if (!s || !caps || !(*caps)) > > + return; > > + av_assert0(s->iformat || s->oformat); > > + if (s->iformat) { > > + if (s->iformat->free_device_capabilities) > > + s->iformat->free_device_capabilities(s, *caps); > > + } else { > > + if (s->oformat->free_device_capabilities) > > + s->oformat->free_device_capabilities(s, *caps); > > + } > > + av_freep(caps); > > } > > -#endif > > > > int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) > > { > > diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h > > index 74e9518a8e..9724e7edf5 100644 > > --- a/libavdevice/avdevice.h > > +++ b/libavdevice/avdevice.h > > @@ -347,7 +347,6 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, > > enum AVDevToAppMessageType type, > > void *data, size_t data_size); > > > > -#if FF_API_DEVICE_CAPABILITIES > > /** > > * Following API allows user to probe device capabilities (supported codecs, > > * pixel formats, sample formats, resolutions, channel counts, etc). > > @@ -443,7 +442,6 @@ typedef struct AVDeviceCapabilitiesQuery { > > /** > > * AVOption table used by devices to implement device capabilities API. Should not be used by a user. > > */ > > -attribute_deprecated > > extern const AVOption av_device_capabilities[]; > > > > /** > > @@ -463,7 +461,6 @@ extern const AVOption av_device_capabilities[]; > > * > > * @return >= 0 on success, negative otherwise. > > */ > > -attribute_deprecated > > int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, > > AVDictionary **device_options); > > > > @@ -473,9 +470,7 @@ int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatConte > > * @param caps Device capabilities data to be freed. > > * @param s Context of the device. > > */ > > -attribute_deprecated > > void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s); > > -#endif > > > > /** > > * Structure describes basic parameters of the device. > > diff --git a/libavdevice/version.h b/libavdevice/version.h > > index e2c8757b27..7c132f2174 100644 > > --- a/libavdevice/version.h > > +++ b/libavdevice/version.h > > @@ -30,8 +30,8 @@ > > > > #include "version_major.h" > > > > -#define LIBAVDEVICE_VERSION_MINOR 8 > > -#define LIBAVDEVICE_VERSION_MICRO 101 > > +#define LIBAVDEVICE_VERSION_MINOR 9 > > +#define LIBAVDEVICE_VERSION_MICRO 100 > > > > #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ > > LIBAVDEVICE_VERSION_MINOR, \ > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > > index 06db024559..027a914e13 100644 > > --- a/libavformat/avformat.h > > +++ b/libavformat/avformat.h > > @@ -617,6 +617,16 @@ typedef struct AVOutputFormat { > > * @see avdevice_list_devices() for more details. > > */ > > int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); > > + /** > > + * Initialize device capabilities submodule. > > + * @see avdevice_capabilities_create() for more details. > > + */ > > + int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); > > + /** > > + * Free device capabilities submodule. > > + * @see avdevice_capabilities_free() for more details. > > + */ > > + int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); > > enum AVCodecID data_codec; /**< default data codec */ > > /** > > * Initialize format. May allocate data here, and set any AVFormatContext or > > @@ -797,6 +807,17 @@ typedef struct AVInputFormat { > > */ > > int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); > > > > + /** > > + * Initialize device capabilities submodule. > > + * @see avdevice_capabilities_create() for more details. > > + */ > > + int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); > > + > > + /** > > + * Free device capabilities submodule. > > + * @see avdevice_capabilities_free() for more details. > > + */ > > + int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); > > } AVInputFormat; > > /** > > * @} > > diff --git a/libavformat/version.h b/libavformat/version.h > > index d195704a31..88d6f750a2 100644 > > --- a/libavformat/version.h > > +++ b/libavformat/version.h > > @@ -32,7 +32,7 @@ > > > > #include "version_major.h" > > > > -#define LIBAVFORMAT_VERSION_MINOR 22 > > +#define LIBAVFORMAT_VERSION_MINOR 23 > > #define LIBAVFORMAT_VERSION_MICRO 100 > > > > #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ > > I have not really looked at the actual content of your dshow patches (as > I know nothing about dshow). But I really don't like the thought that > something is added to AVInput/OutputFormat that only a tiny fraction of > all (de)muxers will likely ever use. I think it would be more efficient > to add a single callback for the seldomly used types of callback like this: > > int (*generic_callback)(struct AVFormatContext *s, int type, void > *priv1, void *priv2, int64_t num) > Frankly, this is a terrible API design in the abstract name of "efficiency". If something is very specific for devices, maybe your efficiency goal should be to divorce them from AVInputFormat. Just my 2c. - Hendrik _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".