[FFmpeg-devel] [PATCH] lavd: add list devices API
Lukasz Marek
lukasz.m.luki at gmail.com
Tue Feb 4 23:19:36 CET 2014
Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
---
libavdevice/avdevice.c | 26 ++++++++++++++++++++++++++
libavdevice/avdevice.h | 39 +++++++++++++++++++++++++++++++++++++++
libavdevice/version.h | 2 +-
libavformat/avformat.h | 5 +++++
libavformat/version.h | 4 ++--
5 files changed, 73 insertions(+), 3 deletions(-)
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 51617fb..0adadbb 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -52,3 +52,29 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA
return AVERROR(ENOSYS);
return s->control_message_cb(s, type, data, data_size);
}
+
+int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list)
+{
+ if (!s->oformat || !s->oformat->get_device_list)
+ return AVERROR(ENOSYS);
+ return s->oformat->get_device_list(s, (void **)device_list);
+}
+
+void avdevice_free_list_devices(AVDeviceInfoList **device_list)
+{
+ AVDeviceInfoList *list;
+ AVDeviceInfo *dev;
+ int i;
+
+ if (!device_list || !(*device_list))
+ return;
+ list = *device_list;
+
+ for (i = 0; i < list->nb_devices; i++) {
+ dev = &list->devices[i];
+ av_free(dev->device_name);
+ av_free(dev->device_description);
+ av_free(dev);
+ }
+ av_freep(device_list);
+}
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index a6408ea..2392cac 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -186,4 +186,43 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
enum AVDevToAppMessageType type,
void *data, size_t data_size);
+/**
+ * Structure describes basic parameters of the device.
+ */
+typedef struct AVDeviceInfo {
+ char *device_name; /**< device name, format depends on device */
+ char *device_description; /**< human friendly name */
+} AVDeviceInfo;
+
+/**
+ * List of devices.
+ */
+typedef struct AVDeviceInfoList {
+ AVDeviceInfo *devices; /**< list of autodetected devices */
+ int nb_devices; /**< number of autodetected devices */
+ int default_device; /**< index of default device or -1 if no default */
+} AVDeviceInfoList;
+
+/**
+ * List devices.
+ *
+ * Returns available device names and their parameters.
+ *
+ * @note: Some devices may accept system-dependent device names that cannot be
+ * autodetected. The list returned by this function cannot be assumed to
+ * be always completed.
+ *
+ * @param s device context.
+ * @param[out] device_list list of autodetected devices.
+ * @return count of autodetected devices, negative on error.
+ */
+int avdevice_list_devices(struct AVFormatContext *s, AVDeviceInfoList **device_list);
+
+/**
+ * Convinient function to free result of avdevice_list_devices().
+ *
+ * @param devices device list to be freed.
+ */
+void avdevice_free_list_devices(AVDeviceInfoList **device_list);
+
#endif /* AVDEVICE_AVDEVICE_H */
diff --git a/libavdevice/version.h b/libavdevice/version.h
index a621775..0dedc73 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -28,7 +28,7 @@
#include "libavutil/version.h"
#define LIBAVDEVICE_VERSION_MAJOR 55
-#define LIBAVDEVICE_VERSION_MINOR 7
+#define LIBAVDEVICE_VERSION_MINOR 8
#define LIBAVDEVICE_VERSION_MICRO 100
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index fe3757a..b653997 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -460,6 +460,11 @@ typedef struct AVOutputFormat {
*/
int (*control_message)(struct AVFormatContext *s, int type,
void *data, size_t data_size);
+ /**
+ * Returns device list with it properties.
+ * @see avdevice_list_devices() for more details.
+ */
+ int (*get_device_list)(struct AVFormatContext *s, void **device_list);
} AVOutputFormat;
/**
* @}
diff --git a/libavformat/version.h b/libavformat/version.h
index 7a9aa4d..0fcbe60 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 29
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR 30
+#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
--
1.8.3.2
More information about the ffmpeg-devel
mailing list