diff options
author | Lukasz Marek <lukasz.m.luki@gmail.com> | 2014-02-16 20:06:23 +0100 |
---|---|---|
committer | Lukasz Marek <lukasz.m.luki@gmail.com> | 2014-02-16 20:07:08 +0100 |
commit | 81c3f81d6f11bf1dad9c6f3de5938e665447b991 (patch) | |
tree | 68bdd8e0804413e940f1a473c3900b4ac1bf2a68 /libavdevice/avdevice.c | |
parent | d3cf9b24cf80eb4d317964e887c591809a149cef (diff) | |
download | ffmpeg-81c3f81d6f11bf1dad9c6f3de5938e665447b991.tar.gz |
lavd: add list devices API
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat (limited to 'libavdevice/avdevice.c')
-rw-r--r-- | libavdevice/avdevice.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 51617fb921..9e2b7d52da 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -52,3 +52,44 @@ 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) +{ + av_assert0(s); + av_assert0(device_list); + av_assert0(s->oformat || s->iformat); + if ((s->oformat && !s->oformat->get_device_list) || + (s->iformat && !s->iformat->get_device_list)) { + *device_list = NULL; + return AVERROR(ENOSYS); + } + *device_list = av_mallocz(sizeof(AVDeviceInfoList)); + if (!(*device_list)) + return AVERROR(ENOMEM); + if (s->oformat) + return s->oformat->get_device_list(s, *device_list); + return s->iformat->get_device_list(s, *device_list); +} + +void avdevice_free_list_devices(AVDeviceInfoList **device_list) +{ + AVDeviceInfoList *list; + AVDeviceInfo *dev; + int i; + + av_assert0(device_list); + list = *device_list; + if (!list) + return; + + for (i = 0; i < list->nb_devices; i++) { + dev = list->devices[i]; + if (dev) { + av_free(dev->device_name); + av_free(dev->device_description); + av_free(dev); + } + } + av_free(list->devices); + av_freep(device_list); +} |