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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182021-02-14 - xxxxxxxxxx - lavd 58.12.100 - avdevice.h
19 Deprecated avdevice_capabilities_create() and
20 avdevice_capabilities_free().
21
182021-02-xx - xxxxxxxxxx - lavu 56.xx.100 - common.h222021-02-xx - xxxxxxxxxx - lavu 56.xx.100 - common.h
19 Add FFABS64U()23 Add FFABS64U()
20 24
libavdevice/avdevice.c+6−65
@@ -27,39 +27,11 @@ · 26 unmodified lines
27#include "libavutil/ffversion.h"27#include "libavutil/ffversion.h"
28const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;28const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
29 29
30#define E AV_OPT_FLAG_ENCODING_PARAM30#if FF_API_DEVICE_CAPABILITIES
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
36const AVOption av_device_capabilities[] = {31const 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 },
55 { NULL }32 { NULL }
56};33};
57 34#endif
58#undef E
59#undef D
60#undef A
61#undef V
62#undef OFFSET
63 35
64unsigned avdevice_version(void)36unsigned avdevice_version(void)
65{37{
@@ -94,49 +66,18 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA · 28 unmodified lines
94 return s->control_message_cb(s, type, data, data_size);66 return s->control_message_cb(s, type, data, data_size);
95}67}
96 68
69#if FF_API_DEVICE_CAPABILITIES
97int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,70int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
98 AVDictionary **device_options)71 AVDictionary **device_options)
99{72{
100 int ret;73 return AVERROR(ENOSYS);
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;
124}74}
125 75
126void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s)76void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s)
127{77{
128 if (!s || !caps || !(*caps))78 return;
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);
139}79}
80#endif
140 81
141int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)82int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
142{83{
libavdevice/avdevice.h+5−0
@@ -321,6 +321,7 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, · 320 unmodified lines
321 enum AVDevToAppMessageType type,321 enum AVDevToAppMessageType type,
322 void *data, size_t data_size);322 void *data, size_t data_size);
323 323
324#if FF_API_DEVICE_CAPABILITIES
324/**325/**
325 * Following API allows user to probe device capabilities (supported codecs,326 * Following API allows user to probe device capabilities (supported codecs,
326 * pixel formats, sample formats, resolutions, channel counts, etc).327 * pixel formats, sample formats, resolutions, channel counts, etc).
@@ -416,6 +417,7 @@ typedef struct AVDeviceCapabilitiesQuery { · 89 unmodified lines
416/**417/**
417 * AVOption table used by devices to implement device capabilities API. Should not be used by a user.418 * AVOption table used by devices to implement device capabilities API. Should not be used by a user.
418 */419 */
420attribute_deprecated
419extern const AVOption av_device_capabilities[];421extern const AVOption av_device_capabilities[];
420 422
421/**423/**
@@ -435,6 +437,7 @@ extern const AVOption av_device_capabilities[]; · 13 unmodified lines
435 *437 *
436 * @return >= 0 on success, negative otherwise.438 * @return >= 0 on success, negative otherwise.
437 */439 */
440attribute_deprecated
438int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,441int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s,
439 AVDictionary **device_options);442 AVDictionary **device_options);
440 443
@@ -444,7 +447,9 @@ int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatConte · 3 unmodified lines
444 * @param caps Device capabilities data to be freed.447 * @param caps Device capabilities data to be freed.
445 * @param s Context of the device.448 * @param s Context of the device.
446 */449 */
450attribute_deprecated
447void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s);451void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s);
452#endif
448 453
449/**454/**
450 * Structure describes basic parameters of the device.455 * Structure describes basic parameters of the device.
libavdevice/version.h+5−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
28#include "libavutil/version.h"28#include "libavutil/version.h"
29 29
30#define LIBAVDEVICE_VERSION_MAJOR 5830#define LIBAVDEVICE_VERSION_MAJOR 58
31#define LIBAVDEVICE_VERSION_MINOR 1131#define LIBAVDEVICE_VERSION_MINOR 12
32#define LIBAVDEVICE_VERSION_MICRO 10332#define LIBAVDEVICE_VERSION_MICRO 100
33 33
34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
35 LIBAVDEVICE_VERSION_MINOR, \35 LIBAVDEVICE_VERSION_MINOR, \
@@ -46,5 +46,8 @@ · 10 unmodified lines
46 * dropped at a future version bump. The defines themselves are not part of46 * dropped at a future version bump. The defines themselves are not part of
47 * the public API and may change, break or disappear at any time.47 * the public API and may change, break or disappear at any time.
48 */48 */
49#ifndef FF_API_DEVICE_CAPABILITIES
50#define FF_API_DEVICE_CAPABILITIES (LIBAVDEVICE_VERSION_MAJOR < 60)
51#endif
49 52
50#endif /* AVDEVICE_VERSION_H */53#endif /* AVDEVICE_VERSION_H */
libavformat/avformat.h+4−0
@@ -590,6 +590,7 @@ typedef struct AVOutputFormat { · 589 unmodified lines
590 * @see avdevice_list_devices() for more details.590 * @see avdevice_list_devices() for more details.
591 */591 */
592 int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);592 int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
593#if LIBAVFORMAT_VERSION_MAJOR < 59
593 /**594 /**
594 * Initialize device capabilities submodule.595 * Initialize device capabilities submodule.
595 * @see avdevice_capabilities_create() for more details.596 * @see avdevice_capabilities_create() for more details.
@@ -600,6 +601,7 @@ typedef struct AVOutputFormat { · 4 unmodified lines
600 * @see avdevice_capabilities_free() for more details.601 * @see avdevice_capabilities_free() for more details.
601 */602 */
602 int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);603 int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
604#endif
603 enum AVCodecID data_codec; /**< default data codec */605 enum AVCodecID data_codec; /**< default data codec */
604 /**606 /**
605 * Initialize format. May allocate data here, and set any AVFormatContext or607 * Initialize format. May allocate data here, and set any AVFormatContext or
@@ -769,6 +771,7 @@ typedef struct AVInputFormat { · 163 unmodified lines
769 */771 */
770 int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);772 int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
771 773
774#if LIBAVFORMAT_VERSION_MAJOR < 59
772 /**775 /**
773 * Initialize device capabilities submodule.776 * Initialize device capabilities submodule.
774 * @see avdevice_capabilities_create() for more details.777 * @see avdevice_capabilities_create() for more details.
@@ -780,6 +783,7 @@ typedef struct AVInputFormat { · 5 unmodified lines
780 * @see avdevice_capabilities_free() for more details.783 * @see avdevice_capabilities_free() for more details.
781 */784 */
782 int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);785 int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
786#endif
783} AVInputFormat;787} AVInputFormat;
784/**788/**
785 * @}789 * @}

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