va: add driver description in element metadata

In the same spirit of libva-win32 elements this patch shows the driver of each
element in gst-inspect, giving more information to the user. This driver
description is parsed from vaQueryVendorString from mesa and intel drivers,
while copied as is for others. Also appends the render node for multi gpu
systems.

Fixes #2349

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4204>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-03-16 17:50:39 +01:00
parent ee759fb4bf
commit e794fcaa1c
2 changed files with 42 additions and 7 deletions

View file

@ -88,6 +88,40 @@ _get_implementation (const char *vendor)
return GST_VA_IMPLEMENTATION_OTHER;
}
static char *
_get_desc (const char *vendor, GstVaImplementation impl)
{
char *end, *start;
char desc[1024];
size_t size;
if (impl == GST_VA_IMPLEMENTATION_OTHER)
return g_strdup (vendor);
start = strstr (vendor, "for ");
if (!start)
return g_strdup (vendor);
start += 4;
switch (impl) {
case GST_VA_IMPLEMENTATION_MESA_GALLIUM:
end = strchr (start, '(');
break;
default:
end = strstr (start, "- ");
break;
}
if (!end)
return g_strdup (vendor);
end -= 1;
size = MIN (1024, end - start);
memcpy (desc, start, size);
desc[size] = '\0';
return g_strdup (desc);
}
static gboolean
_gst_va_display_filter_driver (GstVaDisplay * self, gpointer foreign_display)
{
@ -108,7 +142,7 @@ _gst_va_display_filter_driver (GstVaDisplay * self, gpointer foreign_display)
priv->foreign = TRUE;
}
priv->impl = _get_implementation (vendor);
priv->vendor_desc = g_strdup (vendor);
priv->vendor_desc = _get_desc (vendor, priv->impl);
return TRUE;
}

View file

@ -48,9 +48,7 @@ gst_va_create_feature_name (GstVaDevice * device,
if (device->index == 0) {
*type_name = g_strdup (type_name_default);
*feature_name = g_strdup (feature_name_default);
#ifdef G_OS_WIN32
g_object_get (device->display, "description", desc, NULL);
#endif
return;
}
#ifdef G_OS_WIN32
@ -62,12 +60,15 @@ gst_va_create_feature_name (GstVaDevice * device,
*type_name = g_strdup_printf (type_name_templ, basename);
*feature_name = g_strdup_printf (feature_name_templ, basename);
#ifdef G_OS_WIN32
g_object_get (device->display, "description", desc, NULL);
g_free (basename);
#else
*desc = basename;
#ifndef G_OS_WIN32
{
gchar *newdesc = g_strdup_printf ("%s in %s", *desc, basename);
g_free (*desc);
*desc = newdesc;
}
#endif
g_free (basename);
if (*rank > 0)
*rank -= 1;