[FFmpeg-devel] [PATCH] Add get_device_list() to AVFoundation input device.
Thilo Borgmann
thilo.borgmann at mail.de
Thu Apr 23 11:41:42 CEST 2015
Am 23.04.15 um 11:07 schrieb Daniel Ly:
> This makes avdevice_list_input_sources() available for
> device_name = "avfoundation".
>
> I didn't yet retrofit avf_read_header() to use the new function to
> keep this patch small. I will post the follow-up patch in the same
> thread.
>
> Signed-off-by: Daniel Ly <nalply at gmail.com>
> ---
> libavdevice/avfoundation.m | 98 ++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 90 insertions(+), 8 deletions(-)
>
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index 763e675..19ce2a0 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -34,6 +34,7 @@
> #include "libavformat/internal.h"
> #include "libavutil/internal.h"
> #include "libavutil/parseutils.h"
> +#include "libavutil/avstring.h"
> #include "libavutil/time.h"
> #include "avdevice.h"
>
> @@ -1007,6 +1008,86 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt)
> return 0;
> }
>
> +static int avf_add_device_info(AVDeviceInfoList *list, AVFormatContext *s,
> + int index, const char *description, const char *model)
> +{
> + AVDeviceInfo *info = av_mallocz(sizeof(AVDeviceInfo));
> + if (!info) return AVERROR(ENOMEM);
> +
> + info->device_name = av_asprintf("[%d] %s: %s", index, description, model);
So I assume that this is not parsed later.
However, it changes current output format and should interfere with
parse_device_string(). Consider choosing the very same format string which is
there already.
> + info->device_description = strdup(description);
> + if (!info->device_name || !info->device_description) {
> + av_free(info);
> + return AVERROR(ENOMEM);
> + }
> +
> + av_log(s->priv_data, AV_LOG_INFO, "%s\n", info->device_name);
This always prints all devices, which is an unwanted behaviour.
Currently you have to cause an error (e.g. wrong index) or explicitly call with
-list_devices to get that.
Otherwise it already looks good. However, your follow-up patch incorporating
this to avoid redundancy will show if it is ok to commit.
-Thilo
More information about the ffmpeg-devel
mailing list