History

avdevice/avdevice: Deprecate AVDevice Capabilities API

It has been added in 6db42a2b6b22e6f1928fafcf3faa67ed78201004, yet since then none of the necessary create/free_device_capabilities functions has been implemented, making this API completely useless. Because of this one can already simplify avdevice_capabilities_free/create and can already remove the function pointers at the next major bump; given that the documentation explicitly states that av_device_capabilities is not to be used by a user, it's options can already be removed (save for the sentinel).

Andreas Rheinhardt committed 5 years ago

Commit 4f49ca71 parent ee1c5b45 files · +24 −67Browse files

Unified · Split

5 files
  1. doc/APIchanges +4 −0
  2. libavdevice/avdevice.c +6 −65
  3. libavdevice/avdevice.h +5 −0
  4. libavdevice/version.h +5 −2
  5. libavformat/avformat.h +4 −0
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2017-10-21 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2021-02-14 - xxxxxxxxxx - lavd 58.12.100 - avdevice.h
19+ Deprecated avdevice_capabilities_create() and
20+ avdevice_capabilities_free().
21+
1822 2021-02-xx - xxxxxxxxxx - lavu 56.xx.100 - common.h
1923 Add FFABS64U()
2024
libavdevice/avdevice.c+6−65
@@ -27,39 +27,11 @@ · 26 unmodified lines
2727 #include "libavutil/ffversion.h"
2828 const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
2929
30−#define E AV_OPT_FLAG_ENCODING_PARAM
31−#define D AV_OPT_FLAG_DECODING_PARAM
32−#define A AV_OPT_FLAG_AUDIO_PARAM
33−#define V AV_OPT_FLAG_VIDEO_PARAM
34−#define OFFSET(x) offsetof(AVDeviceCapabilitiesQuery, x)
35−
30+#if FF_API_DEVICE_CAPABILITIES
3631 const AVOption av_device_capabilities[] = {
37− { "codec", "codec", OFFSET(codec), AV_OPT_TYPE_INT,
38− {.i64 = AV_CODEC_ID_NONE}, AV_CODEC_ID_NONE, INT_MAX, E|D|A|V },
39− { "sample_format", "sample format", OFFSET(sample_format), AV_OPT_TYPE_SAMPLE_FMT,
40− {.i64 = AV_SAMPLE_FMT_NONE}, AV_SAMPLE_FMT_NONE, INT_MAX, E|D|A },
41− { "sample_rate", "sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT,
42− {.i64 = -1}, -1, INT_MAX, E|D|A },
43− { "channels", "channels", OFFSET(channels), AV_OPT_TYPE_INT,
44− {.i64 = -1}, -1, INT_MAX, E|D|A },
45− { "channel_layout", "channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT,
46− {.i64 = -1}, -1, INT_MAX, E|D|A },
47− { "pixel_format", "pixel format", OFFSET(pixel_format), AV_OPT_TYPE_PIXEL_FMT,
48− {.i64 = AV_PIX_FMT_NONE}, AV_PIX_FMT_NONE, INT_MAX, E|D|V },
49− { "window_size", "window size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE,
50− {.str = NULL}, -1, INT_MAX, E|D|V },
51− { "frame_size", "frame size", OFFSET(frame_width), AV_OPT_TYPE_IMAGE_SIZE,
52− {.str = NULL}, -1, INT_MAX, E|D|V },
53− { "fps", "fps", OFFSET(fps), AV_OPT_TYPE_RATIONAL,
54− {.dbl = -1}, -1, INT_MAX, E|D|V },
5532 { NULL }
5633 };
57−
58−#undef E
59−#undef D
60−#undef A
61−#undef V
62−#undef OFFSET
34+#endif
6335
6436 unsigned avdevice_version(void)
6537 {
@@ -94,49 +66,18 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA · 28 unmodified lines
9466 return s->control_message_cb(s, type, data, data_size);
9567 }
9668
69+#if FF_API_DEVICE_CAPABILITIES
9770 int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
9871 AVDictionary **device_options)
9972 {
100− int ret;
101− av_assert0(s && caps);
102− av_assert0(s->iformat || s->oformat);
103− if ((s->oformat && !s->oformat->create_device_capabilities) ||
104− (s->iformat && !s->iformat->create_device_capabilities))
105− return AVERROR(ENOSYS);
106− *caps = av_mallocz(sizeof(**caps));
107− if (!(*caps))
108− return AVERROR(ENOMEM);
109− (*caps)->device_context = s;
110− if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0))
111− goto fail;
112− if (s->iformat) {
113− if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0)
114− goto fail;
115− } else {
116− if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0)
117− goto fail;
118− }
119− av_opt_set_defaults(*caps);
120− return 0;
121− fail:
122− av_freep(caps);
123− return ret;
73+ return AVERROR(ENOSYS);
12474 }
12575
12676 void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s)
12777 {
128− if (!s || !caps || !(*caps))
129− return;
130− av_assert0(s->iformat || s->oformat);
131− if (s->iformat) {
132− if (s->iformat->free_device_capabilities)
133− s->iformat->free_device_capabilities(s, *caps);
134− } else {
135− if (s->oformat->free_device_capabilities)
136− s->oformat->free_device_capabilities(s, *caps);
137− }
138− av_freep(caps);
78+ return;
13979 }
80+#endif
14081
14182 int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
14283 {
libavdevice/avdevice.h+5−0
@@ -321,6 +321,7 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, · 320 unmodified lines
321321 enum AVDevToAppMessageType type,
322322 void *data, size_t data_size);
323323
324+#if FF_API_DEVICE_CAPABILITIES
324325 /**
325326 * Following API allows user to probe device capabilities (supported codecs,
326327 * pixel formats, sample formats, resolutions, channel counts, etc).
@@ -416,6 +417,7 @@ typedef struct AVDeviceCapabilitiesQuery { · 89 unmodified lines
416417 /**
417418 * AVOption table used by devices to implement device capabilities API. Should not be used by a user.
418419 */
420+attribute_deprecated
419421 extern const AVOption av_device_capabilities[];
420422
421423 /**
@@ -435,6 +437,7 @@ extern const AVOption av_device_capabilities[]; · 13 unmodified lines
435437 *
436438 * @return >= 0 on success, negative otherwise.
437439 */
440+attribute_deprecated
438441 int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
439442 AVDictionary **device_options);
440443
@@ -444,7 +447,9 @@ int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatConte · 3 unmodified lines
444447 * @param caps Device capabilities data to be freed.
445448 * @param s Context of the device.
446449 */
450+attribute_deprecated
447451 void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s);
452+#endif
448453
449454 /**
450455 * Structure describes basic parameters of the device.
libavdevice/version.h+5−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVDEVICE_VERSION_MAJOR 58
31−#define LIBAVDEVICE_VERSION_MINOR 11
32−#define LIBAVDEVICE_VERSION_MICRO 103
31+#define LIBAVDEVICE_VERSION_MINOR 12
32+#define LIBAVDEVICE_VERSION_MICRO 100
3333
3434 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
3535 LIBAVDEVICE_VERSION_MINOR, \
@@ -46,5 +46,8 @@ · 10 unmodified lines
4646 * dropped at a future version bump. The defines themselves are not part of
4747 * the public API and may change, break or disappear at any time.
4848 */
49+#ifndef FF_API_DEVICE_CAPABILITIES
50+#define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
51+#endif
4952
5053 #endif /* AVDEVICE_VERSION_H */
libavformat/avformat.h+4−0
@@ -590,6 +590,7 @@ typedef struct AVOutputFormat { · 589 unmodified lines
590590 * @see avdevice_list_devices() for more details.
591591 */
592592 int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
593+#if LIBAVFORMAT_VERSION_MAJOR < 59
593594 /**
594595 * Initialize device capabilities submodule.
595596 * @see avdevice_capabilities_create() for more details.
@@ -600,6 +601,7 @@ typedef struct AVOutputFormat { · 4 unmodified lines
600601 * @see avdevice_capabilities_free() for more details.
601602 */
602603 int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
604+#endif
603605 enum AVCodecID data_codec; /**< default data codec */
604606 /**
605607 * Initialize format. May allocate data here, and set any AVFormatContext or
@@ -769,6 +771,7 @@ typedef struct AVInputFormat { · 163 unmodified lines
769771 */
770772 int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
771773
774+#if LIBAVFORMAT_VERSION_MAJOR < 59
772775 /**
773776 * Initialize device capabilities submodule.
774777 * @see avdevice_capabilities_create() for more details.
@@ -780,6 +783,7 @@ typedef struct AVInputFormat { · 5 unmodified lines
780783 * @see avdevice_capabilities_free() for more details.
781784 */
782785 int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
786+#endif
783787 } AVInputFormat;
784788 /**
785789 * @}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t