diff mbox series

[FFmpeg-devel] configure: autodetect uuid and use it for dshow and vulkan

Message ID MoHgdtE--3-2@lynne.ee
State New
Headers show
Series [FFmpeg-devel] configure: autodetect uuid and use it for dshow and vulkan
Related show

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

Lynne Nov. 12, 2021, 5:50 a.m. UTC
The UUID library is even more ubiquitous than iconv, and it hasn't 
changed its API and ABI for maybe 20 years.
MediaFoundation and dshow already depends on it silently, and
vulkan can optionally use it to parse user-given UUIDs, which I think
would be a popular way to specify devices on servers.

Patch attached.
Subject: [PATCH] configure: autodetect uuid and use it for dshow and vulkan

The UUID library is even more ubiquitous than iconv, and it hasn't
changed its API and ABI for maybe 20 years.
dshow already depends on it silently, and vulkan can optionally use
it to parse user-given UUIDs, which I think would be a popular way
to specify devices on servers.
---
 configure                    | 13 ++++++++++---
 doc/ffmpeg.texi              |  6 ++++--
 libavutil/hwcontext_vulkan.c | 10 +++++++++-
 3 files changed, 23 insertions(+), 6 deletions(-)

Comments

Martin Storsjö Nov. 12, 2021, 6:04 a.m. UTC | #1
On Fri, 12 Nov 2021, Lynne wrote:

> The UUID library is even more ubiquitous than iconv, and it hasn't
> changed its API and ABI for maybe 20 years.
> MediaFoundation and dshow already depends on it silently, and

The "uuid" library on Windows is something entirely different, it's just a 
collection of GUID constants, not the uuid parsing/generation tools of the 
unix libuuid.

// Martin
Lynne Nov. 12, 2021, 6:41 a.m. UTC | #2
12 Nov 2021, 07:04 by martin@martin.st:

> On Fri, 12 Nov 2021, Lynne wrote:
>
>> The UUID library is even more ubiquitous than iconv, and it hasn't
>> changed its API and ABI for maybe 20 years.
>> MediaFoundation and dshow already depends on it silently, and
>>
>
> The "uuid" library on Windows is something entirely different, it's just a collection of GUID constants, not the uuid parsing/generation tools of the unix libuuid.
>

Oh, I see.
I'll leave this patch here if anyone wants to pick it up/needs it.
diff mbox series

Patch

diff --git a/configure b/configure
index eb451d2782..11bdff1a40 100755
--- a/configure
+++ b/configure
@@ -321,6 +321,7 @@  External library support:
   --disable-sdl2           disable sdl2 [autodetect]
   --disable-securetransport disable Secure Transport, needed for TLS support
                            on OSX if openssl and gnutls are not used [autodetect]
+  --disable-uuid           disable uuid [autodetect]
   --enable-vapoursynth     enable VapourSynth demuxer [no]
   --enable-vulkan          enable Vulkan code [no]
   --disable-xlib           disable xlib [autodetect]
@@ -1747,6 +1748,7 @@  EXTERNAL_AUTODETECT_LIBRARY_LIST="
     sdl2
     securetransport
     sndio
+    uuid
     xlib
     zlib
 "
@@ -2964,6 +2966,7 @@  vaapi_x11_deps="xlib_x11"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
 vulkan_deps_any="libdl LoadLibrary"
+vulkan_suggest="uuid"
 xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
@@ -3454,8 +3457,8 @@  decklink_indev_extralibs="-lstdc++"
 decklink_outdev_deps="decklink threads"
 decklink_outdev_suggest="libklvanc"
 decklink_outdev_extralibs="-lstdc++"
-dshow_indev_deps="IBaseFilter"
-dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi"
+dshow_indev_deps="IBaseFilter uuid"
+dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -loleaut32 -lshlwapi"
 fbdev_indev_deps="linux_fb_h"
 fbdev_outdev_deps="linux_fb_h"
 gdigrab_indev_deps="CreateDIBSection"
@@ -3743,7 +3746,7 @@  avfilter_deps="avutil"
 avfilter_suggest="libm"
 avformat_deps="avcodec avutil"
 avformat_suggest="libm network zlib"
-avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt"
+avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx uuid opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt"
 postproc_deps="avutil gpl"
 postproc_suggest="libm"
 swresample_deps="avutil"
@@ -6826,6 +6829,10 @@  enabled vdpau &&
 enabled vdpau &&
     check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11
 
+enabled uuid &&
+    check_pkg_config uuid uuid "uuid/uuid.h" uuid_parse ||
+    check_lib uuid "uuid/uuid.h" uuid_parse -luuid
+
 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 if enabled vulkan; then
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 62d9703b7a..ddee99b364 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1184,8 +1184,10 @@  extension.
 
 @item vulkan
 If @var{device} is an integer, it selects the device by its index in a
-system-dependent list of devices.  If @var{device} is any other string, it
-selects the first device with a name containing that string as a substring.
+system-dependent list of devices. If @var{device} is a UUID, the device
+will be selected by checking for matching UUIDs. If @var{device} is any other
+string, it selects the first device with a name containing that string as a
+substring.
 
 The following options are recognized:
 @table @option
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 93a304ca95..29197a2100 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -38,6 +38,10 @@ 
 #include <dlfcn.h>
 #endif
 
+#if CONFIG_UUID
+#include <uuid/uuid.h>
+#endif
+
 #if CONFIG_LIBDRM
 #include <xf86drm.h>
 #include <drm_fourcc.h>
@@ -1367,7 +1371,11 @@  static int vulkan_device_create(AVHWDeviceContext *ctx, const char *device,
         dev_select.index = strtol(device, &end, 10);
         if (end == device) {
             dev_select.index = 0;
-            dev_select.name  = device;
+#if CONFIG_UUID
+            if (!uuid_parse(device, dev_select.uuid))
+                dev_select.has_uuid = 1;
+#endif
+                dev_select.name  = device;
         }
     }