[FFmpeg-devel] [PATCH 3/8] lavd/avdevice: add device iterators

Nicolas George george at nsup.org
Wed Feb 26 12:32:27 CET 2014


Le septidi 7 ventôse, an CCXXII, Lukasz Marek a écrit :
> >From ae6eceeaee9e3244f01d67ee6c3dafc40692fd23 Mon Sep 17 00:00:00 2001
> From: Lukasz Marek <lukasz.m.luki at gmail.com>
> Date: Sat, 22 Feb 2014 23:32:55 +0100
> Subject: [PATCH 3/4] lavd/avdevice: add device iterators
> 
> TODO: minor bump, update doc/APIChanges
> 
> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> ---
>  libavdevice/avdevice.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  libavdevice/avdevice.h | 16 ++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
> index 9e2b7d5..ada4bb8 100644
> --- a/libavdevice/avdevice.c
> +++ b/libavdevice/avdevice.c
> @@ -37,6 +37,46 @@ const char * avdevice_license(void)
>      return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
>  }
>  
> +AVInputFormat *av_input_audio_device_next(AVInputFormat  *d)
> +{
> +    AVInputFormat *o = av_iformat_next(d);
> +    while (o && (!o->priv_class ||
> +          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT &&
> +           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_INPUT)))
> +        o = av_iformat_next(o);
> +    return o;
> +}
> +
> +AVInputFormat *av_input_video_device_next(AVInputFormat  *d)
> +{
> +    AVInputFormat *o = av_iformat_next(d);
> +    while (o && (!o->priv_class ||
> +          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT &&
> +           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_INPUT)))
> +        o = av_iformat_next(o);
> +    return o;
> +}
> +
> +AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d)
> +{
> +    AVOutputFormat *o = av_oformat_next(d);
> +    while (o && (!o->priv_class ||
> +          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT &&
> +           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_OUTPUT)))
> +        o = av_oformat_next(o);
> +    return o;
> +}
> +
> +AVOutputFormat *av_output_video_device_next(AVOutputFormat *d)
> +{
> +    AVOutputFormat *o = av_oformat_next(d);
> +    while (o && (!o->priv_class ||
> +          (o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT &&
> +           o->priv_class->category != AV_CLASS_CATEGORY_DEVICE_OUTPUT)))
> +        o = av_oformat_next(o);
> +    return o;
> +}
> +
>  int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type,
>                                          void *data, size_t data_size)
>  {
> diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
> index 28344ca..47bf8f4 100644
> --- a/libavdevice/avdevice.h
> +++ b/libavdevice/avdevice.h
> @@ -66,6 +66,22 @@ const char *avdevice_license(void);
>   */
>  void avdevice_register_all(void);
>  
> +/**
> + * If d is NULL, returns the first registered input audio/video device,
> + * if d is non-NULL, returns the next registered input audio/video device after d
> + * or NULL if d is the last one.
> + */
> +AVInputFormat *av_input_audio_device_next(AVInputFormat  *d);
> +AVInputFormat *av_input_video_device_next(AVInputFormat  *d);
> +
> +/**
> + * If d is NULL, returns the first registered output audio/video device,
> + * if d is non-NULL, returns the next registered output audio/video device after d
> + * or NULL if d is the last one.
> + */
> +AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d);
> +AVOutputFormat *av_output_video_device_next(AVOutputFormat *d);
> +
>  typedef struct AVDeviceRect {
>      int x;      /**< x coordinate of top left corner */
>      int y;      /**< y coordinate of top left corner */

Looks like a lot of duplicated code. Maybe a single iterator that accepts a
"category" argument?

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140226/b4029784/attachment.asc>


More information about the ffmpeg-devel mailing list