diff mbox series

[FFmpeg-devel,v5,09/13] avdevice: add info about media types(s) to AVDeviceInfo

Message ID 20211219192134.1296-10-dcnieho@gmail.com
State Superseded, archived
Headers show
Series dshow enhancements | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Diederick C. Niehorster Dec. 19, 2021, 7:21 p.m. UTC
An avdevice, regardless of whether its category says its an audio or
video device, may provide access to devices providing different media
types, or even single devices providing multiple media types. Also, some
devices may provide no media types. dshow is an example encompassing all
of these cases. Users should be provided with this information, so
AVDeviceInfo is extended to provide it.

Bump avdevice version

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
---
 libavdevice/avdevice.c | 2 ++
 libavdevice/avdevice.h | 2 ++
 libavdevice/version.h  | 2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)

Comments

Andreas Rheinhardt Dec. 20, 2021, 12:59 a.m. UTC | #1
Diederick Niehorster:
> An avdevice, regardless of whether its category says its an audio or
> video device, may provide access to devices providing different media
> types, or even single devices providing multiple media types. Also, some
> devices may provide no media types. dshow is an example encompassing all
> of these cases. Users should be provided with this information, so
> AVDeviceInfo is extended to provide it.
> 
> Bump avdevice version
> 
> Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
> ---
>  libavdevice/avdevice.c | 2 ++
>  libavdevice/avdevice.h | 2 ++
>  libavdevice/version.h  | 2 +-
>  3 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
> index 2ae26ab8e3..712ef1e80c 100644
> --- a/libavdevice/avdevice.c
> +++ b/libavdevice/avdevice.c
> @@ -157,6 +157,8 @@ void avdevice_free_list_devices(AVDeviceInfoList **device_list)
>          if (dev) {
>              av_freep(&dev->device_name);
>              av_freep(&dev->device_description);
> +            if (dev->media_types)
> +                av_freep(&dev->media_types);

av_freep() can handle the case of dev->media_types == NULL just fine, so
the check can be removed (yes, this might be a tiny bit slower in case
dev->media_types is NULL, but this is not hot code).

>              av_free(dev);
>          }
>      }
> diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
> index 8370bbc7f2..6f24976dcc 100644
> --- a/libavdevice/avdevice.h
> +++ b/libavdevice/avdevice.h
> @@ -457,6 +457,8 @@ void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContex
>  typedef struct AVDeviceInfo {
>      char *device_name;                   /**< device name, format depends on device */
>      char *device_description;            /**< human friendly name */
> +    enum AVMediaType *media_types;       /**< array indicating what media types(s), if any, a device can provide. If null, cannot provide any */
> +    int nb_media_types;                  /**< length of media_types array, 0 if device cannot provide any media types */

Personally, I'd prefer it if this were unsigned given that negative
values don't make sense. But this is just a personal preference.

>  } AVDeviceInfo;
>  
>  /**
> diff --git a/libavdevice/version.h b/libavdevice/version.h
> index 914e156ec7..c549768e12 100644
> --- a/libavdevice/version.h
> +++ b/libavdevice/version.h
> @@ -28,7 +28,7 @@
>  #include "libavutil/version.h"
>  
>  #define LIBAVDEVICE_VERSION_MAJOR  59
> -#define LIBAVDEVICE_VERSION_MINOR   0
> +#define LIBAVDEVICE_VERSION_MINOR   1
>  #define LIBAVDEVICE_VERSION_MICRO 101

MICRO should be reset if MINOR is bumped.

>  
>  #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
>
Diederick C. Niehorster Dec. 20, 2021, 9:54 a.m. UTC | #2
Hi Andreas,

On Mon, Dec 20, 2021 at 1:59 AM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Diederick Niehorster:
> > diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
> > index 8370bbc7f2..6f24976dcc 100644
> > --- a/libavdevice/avdevice.h
> > +++ b/libavdevice/avdevice.h
> > @@ -457,6 +457,8 @@ void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContex
> >  typedef struct AVDeviceInfo {
> >      char *device_name;                   /**< device name, format depends on device */
> >      char *device_description;            /**< human friendly name */
> > +    enum AVMediaType *media_types;       /**< array indicating what media types(s), if any, a device can provide. If null, cannot provide any */
> > +    int nb_media_types;                  /**< length of media_types array, 0 if device cannot provide any media types */
>
> Personally, I'd prefer it if this were unsigned given that negative
> values don't make sense. But this is just a personal preference.

I agree with you, but almost all nb_ in ffmpeg are int, so I guess its
best to use that here too and avoid any surprises.

I have applied all your comments, except the two i asked questions
about, and you comment on patch 8 to allocate media_types on the
stack, since it is to be returned to caller as you noticed yourself
later.

Thanks for the comments!
Dee
diff mbox series

Patch

diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 2ae26ab8e3..712ef1e80c 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -157,6 +157,8 @@  void avdevice_free_list_devices(AVDeviceInfoList **device_list)
         if (dev) {
             av_freep(&dev->device_name);
             av_freep(&dev->device_description);
+            if (dev->media_types)
+                av_freep(&dev->media_types);
             av_free(dev);
         }
     }
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index 8370bbc7f2..6f24976dcc 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -457,6 +457,8 @@  void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContex
 typedef struct AVDeviceInfo {
     char *device_name;                   /**< device name, format depends on device */
     char *device_description;            /**< human friendly name */
+    enum AVMediaType *media_types;       /**< array indicating what media types(s), if any, a device can provide. If null, cannot provide any */
+    int nb_media_types;                  /**< length of media_types array, 0 if device cannot provide any media types */
 } AVDeviceInfo;
 
 /**
diff --git a/libavdevice/version.h b/libavdevice/version.h
index 914e156ec7..c549768e12 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -28,7 +28,7 @@ 
 #include "libavutil/version.h"
 
 #define LIBAVDEVICE_VERSION_MAJOR  59
-#define LIBAVDEVICE_VERSION_MINOR   0
+#define LIBAVDEVICE_VERSION_MINOR   1
 #define LIBAVDEVICE_VERSION_MICRO 101
 
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \