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

Lukasz Marek lukasz.m.luki at gmail.com
Fri Feb 28 02:57:43 CET 2014


On 26.02.2014 16:38, Lukasz M wrote:
> On 26 February 2014 12:32, Nicolas George <george at nsup.org
> <mailto:george at nsup.org>> wrote:
>
>     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
>     <mailto: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
>     <mailto: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?
>
>
> 2 of them uses InputFormat param, 2 OutputFormat. Handling wrong enums
> will also adds some code and complications to user.
> I can add one internal implementation and call it from these 4.


Updated patch attached

-- 
Best Regards,
Lukasz Marek

You can avoid reality, but you cannot avoid the consequences of avoiding 
reality. - Ayn Rand
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-lavd-avdevice-add-device-iterators.patch
Type: text/x-patch
Size: 3469 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140228/7d0d1764/attachment.bin>


More information about the ffmpeg-devel mailing list