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