[FFmpeg-devel] [PATCH] Add get_device_list() to AVFoundation input device.

Clément Bœsch u at pkh.me
Thu Apr 23 11:37:51 CEST 2015


On Thu, Apr 23, 2015 at 11:07:43AM +0200, Daniel Ly wrote:
> 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);
> +    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);

Why do you log this?

Won't this cause a dup of the list in the output?

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150423/f2decac9/attachment.asc>


More information about the ffmpeg-devel mailing list