diff options
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 51617fb..9e2b7d5 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); +} |