va: Add render node name in non-first devices.
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 30 Nov 2022 12:33:49 +0000 (13:33 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 1 Dec 2022 16:00:55 +0000 (16:00 +0000)
There could be multi-GPU setups where the non-first has more
entrypoints than the first one, and the elements names are not
homogeneous, leading to pipeline building error.

This patch add the render node in the elements names when they belong
to the non-first device.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3491>

subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c
subprojects/gst-plugins-bad/sys/va/gstvadevice.c
subprojects/gst-plugins-bad/sys/va/gstvadevice.h
subprojects/gst-plugins-bad/sys/va/gstvah264dec.c
subprojects/gst-plugins-bad/sys/va/gstvah264enc.c
subprojects/gst-plugins-bad/sys/va/gstvah265dec.c
subprojects/gst-plugins-bad/sys/va/gstvah265enc.c
subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c
subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c
subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c
subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c

index 3530654..10f3432 100644 (file)
@@ -1119,16 +1119,14 @@ gst_va_av1_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaAV1Dec");
-  feature_name = g_strdup ("vaav1dec");
-
   /* The first decoder to be registered should use a constant name,
    * like vaav1dec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaAV1Dec");
+    feature_name = g_strdup ("vaav1dec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sAV1Dec", basename);
     feature_name = g_strdup_printf ("va%sav1dec", basename);
     cdata->description = basename;
index 33ab55a..832fc0c 100644 (file)
@@ -42,7 +42,8 @@ gst_va_device_free (GstVaDevice * device)
 }
 
 static GstVaDevice *
-gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path)
+gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path,
+    gint index)
 {
   GstVaDevice *device = g_new0 (GstVaDevice, 1);
 
@@ -52,6 +53,7 @@ gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path)
   /* take ownership */
   device->display = display;
   device->render_device_path = g_strdup (render_device_path);
+  device->index = index;
 
   return device;
 }
@@ -61,7 +63,7 @@ compare_device_path (gconstpointer a, gconstpointer b, gpointer user_data)
 {
   const GstVaDevice *pa = a, *pb = b;
 
-  return strcmp (pa->render_device_path, pb->render_device_path);
+  return g_strcmp0 (pa->render_device_path, pb->render_device_path);
 }
 
 #if HAVE_GUDEV
@@ -71,6 +73,7 @@ gst_va_device_find_devices (void)
   GUdevClient *client;
   GList *udev_devices, *dev;
   GQueue devices = G_QUEUE_INIT;
+  gint i = 0;
 
   client = g_udev_client_new (NULL);
   udev_devices = g_udev_client_query_by_subsystem (client, "drm");
@@ -90,7 +93,7 @@ gst_va_device_find_devices (void)
       continue;
 
     GST_INFO ("Found VA-API device: %s", path);
-    g_queue_push_head (&devices, gst_va_device_new (dpy, path));
+    g_queue_push_head (&devices, gst_va_device_new (dpy, path, i++));
   }
 
   g_queue_sort (&devices, compare_device_path, NULL);
@@ -106,7 +109,7 @@ gst_va_device_find_devices (void)
   GstVaDisplay *dpy;
   GQueue devices = G_QUEUE_INIT;
   gchar path[64];
-  guint i;
+  guint i, j = 0;
 
   for (i = 0; i < 8; i++) {
     g_snprintf (path, sizeof (path), "/dev/dri/renderD%d", 128 + i);
@@ -117,7 +120,7 @@ gst_va_device_find_devices (void)
       continue;
 
     GST_INFO ("Found VA-API device: %s", path);
-    g_queue_push_head (&devices, gst_va_device_new (dpy, path));
+    g_queue_push_head (&devices, gst_va_device_new (dpy, path, j++));
   }
 
   g_queue_sort (&devices, compare_device_path, NULL);
index 662acd3..2ed498c 100644 (file)
@@ -36,6 +36,7 @@ typedef struct
 
   GstVaDisplay *display;
   gchar *render_device_path;
+  gint index;
 } GstVaDevice;
 
 GType                 gst_va_device_get_type              (void);
index d92a626..559c5d5 100644 (file)
@@ -1034,16 +1034,14 @@ gst_va_h264_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaH264Dec");
-  feature_name = g_strdup ("vah264dec");
-
   /* The first decoder to be registered should use a constant name,
    * like vah264dec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaH264Dec");
+    feature_name = g_strdup ("vah264dec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sH264Dec", basename);
     feature_name = g_strdup_printf ("va%sh264dec", basename);
     cdata->description = basename;
index f93d87e..17120cb 100644 (file)
@@ -3814,21 +3814,20 @@ gst_va_h264_enc_register (GstPlugin * plugin, GstVaDevice * device,
       GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
 
   type_info.class_data = cdata;
-  if (entrypoint == VAEntrypointEncSlice) {
-    type_name = g_strdup ("GstVaH264Enc");
-    feature_name = g_strdup ("vah264enc");
-  } else {
-    type_name = g_strdup ("GstVaH264LPEnc");
-    feature_name = g_strdup ("vah264lpenc");
-  }
 
   /* The first encoder to be registered should use a constant name,
    * like vah264enc, for any additional encoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    if (entrypoint == VAEntrypointEncSlice) {
+      type_name = g_strdup ("GstVaH264Enc");
+      feature_name = g_strdup ("vah264enc");
+    } else {
+      type_name = g_strdup ("GstVaH264LPEnc");
+      feature_name = g_strdup ("vah264lpenc");
+    }
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     if (entrypoint == VAEntrypointEncSlice) {
       type_name = g_strdup_printf ("GstVa%sH264Enc", basename);
       feature_name = g_strdup_printf ("va%sh264enc", basename);
index 3cf526a..45b6c78 100644 (file)
@@ -1380,16 +1380,14 @@ gst_va_h265_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaH265Dec");
-  feature_name = g_strdup ("vah265dec");
-
   /* The first decoder to be registered should use a constant name,
    * like vah265dec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaH265Dec");
+    feature_name = g_strdup ("vah265dec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sH265Dec", basename);
     feature_name = g_strdup_printf ("va%sh265dec", basename);
     cdata->description = basename;
index 8a7034d..6d6537c 100644 (file)
@@ -5292,21 +5292,20 @@ gst_va_h265_enc_register (GstPlugin * plugin, GstVaDevice * device,
       GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
 
   type_info.class_data = cdata;
-  if (entrypoint == VAEntrypointEncSlice) {
-    type_name = g_strdup ("GstVaH265Enc");
-    feature_name = g_strdup ("vah265enc");
-  } else {
-    type_name = g_strdup ("GstVaH265LPEnc");
-    feature_name = g_strdup ("vah265lpenc");
-  }
 
   /* The first encoder to be registered should use a constant name,
    * like vah265enc, for any additional encoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    if (entrypoint == VAEntrypointEncSlice) {
+      type_name = g_strdup ("GstVaH265Enc");
+      feature_name = g_strdup ("vah265enc");
+    } else {
+      type_name = g_strdup ("GstVaH265LPEnc");
+      feature_name = g_strdup ("vah265lpenc");
+    }
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     if (entrypoint == VAEntrypointEncSlice) {
       type_name = g_strdup_printf ("GstVa%sH265Enc", basename);
       feature_name = g_strdup_printf ("va%sh265enc", basename);
@@ -5315,6 +5314,7 @@ gst_va_h265_enc_register (GstPlugin * plugin, GstVaDevice * device,
       feature_name = g_strdup_printf ("va%sh265lpenc", basename);
     }
     cdata->description = basename;
+
     /* lower rank for non-first device */
     if (rank > 0)
       rank--;
index a6e5a3f..2a00cb6 100644 (file)
@@ -623,16 +623,15 @@ gst_va_jpeg_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaJpegDec");
-  feature_name = g_strdup ("vajpegdec");
 
   /* The first decoder to be registered should use a constant name,
    * like vajpegdec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaJpegDec");
+    feature_name = g_strdup ("vajpegdec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sJpegDec", basename);
     feature_name = g_strdup_printf ("va%sjpegdec", basename);
     cdata->description = basename;
index 69be39c..06020e4 100644 (file)
@@ -712,16 +712,14 @@ gst_va_mpeg2_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaMpeg2Dec");
-  feature_name = g_strdup ("vampeg2dec");
-
   /* The first decoder to be registered should use a constant name,
    * like vampeg2dec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaMpeg2Dec");
+    feature_name = g_strdup ("vampeg2dec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sMpeg2Dec", basename);
     feature_name = g_strdup_printf ("va%smpeg2dec", basename);
     cdata->description = basename;
index 50d721d..0b78231 100644 (file)
@@ -581,16 +581,14 @@ gst_va_vp8_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaVp8Dec");
-  feature_name = g_strdup ("vavp8dec");
-
   /* The first decoder to be registered should use a constant name,
    * like vavp8dec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaVp8Dec");
+    feature_name = g_strdup ("vavp8dec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sVp8Dec", basename);
     feature_name = g_strdup_printf ("va%svp8dec", basename);
     cdata->description = basename;
index 45807f5..136de0c 100644 (file)
@@ -740,16 +740,14 @@ gst_va_vp9_dec_register (GstPlugin * plugin, GstVaDevice * device,
 
   type_info.class_data = cdata;
 
-  type_name = g_strdup ("GstVaVp9Dec");
-  feature_name = g_strdup ("vavp9dec");
-
   /* The first decoder to be registered should use a constant name,
    * like vavp9dec, for any additional decoders, we create unique
    * names, using inserting the render device name. */
-  if (g_type_from_name (type_name)) {
+  if (device->index == 0) {
+    type_name = g_strdup ("GstVaVp9Dec");
+    feature_name = g_strdup ("vavp9dec");
+  } else {
     gchar *basename = g_path_get_basename (device->render_device_path);
-    g_free (type_name);
-    g_free (feature_name);
     type_name = g_strdup_printf ("GstVa%sVp9Dec", basename);
     feature_name = g_strdup_printf ("va%svp9dec", basename);
     cdata->description = basename;