nvcodec: Add plugin status message
authorSeungha Yang <seungha@centricular.com>
Tue, 20 Feb 2024 16:13:02 +0000 (01:13 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 22 Feb 2024 23:30:29 +0000 (23:30 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6167>

subprojects/gst-plugins-bad/sys/nvcodec/plugin.c

index 7d7c9a2b897a24d6e0e375c6db8f6126598b809c..08cac8f34ce528cef9cd0835b1e26dbb1589b019 100644 (file)
@@ -54,6 +54,8 @@
 #include "gstnvcodecutils.h"
 #include "gstnvjpegenc.h"
 
+#include <glib/gi18n-lib.h>
+
 GST_DEBUG_CATEGORY (gst_nvcodec_debug);
 GST_DEBUG_CATEGORY (gst_nvdec_debug);
 GST_DEBUG_CATEGORY (gst_nvenc_debug);
@@ -65,6 +67,22 @@ GST_DEBUG_CATEGORY (gst_cuda_nvmm_debug);
 
 #define GST_CAT_DEFAULT gst_nvcodec_debug
 
+#ifdef G_OS_WIN32
+#define CUDA_LIBNAME "nvcuda.dll"
+#define NVCUVID_LIBNAME "nvcuvid.dll"
+#ifdef _WIN64
+#define NVENC_LIBNAME "nvEncodeAPI64.dll"
+#else
+#define NVENC_LIBNAME "nvEncodeAPI.dll"
+#endif
+#define NVRTC_LIBNAME "nvrtc64_*_0.dll"
+#else /* G_OS_WIN32 */
+#define CUDA_LIBNAME "libcuda.so.1"
+#define NVCUVID_LIBNAME "libnvcuvid.so.1"
+#define NVENC_LIBNAME "libnvidia-encode.so.1"
+#define NVRTC_LIBNAME "libnvrtc.so"
+#endif /* G_OS_WIN32 */
+
 static void
 plugin_deinit (gpointer data)
 {
@@ -120,20 +138,24 @@ plugin_init (GstPlugin * plugin)
 #endif
 
   if (!gst_cuda_load_library ()) {
-    GST_WARNING ("Failed to load cuda library");
+    gst_plugin_add_status_warning (plugin,
+        "CUDA library \"" CUDA_LIBNAME "\" was not found.");
     return TRUE;
   }
 
   /* get available API version from nvenc and it will be passed to
    * nvdec */
   if (!gst_nvenc_load_library (&api_major_ver, &api_minor_ver)) {
-    GST_WARNING ("Failed to load nvenc library");
+    gst_plugin_add_status_warning (plugin,
+        "NVENC library \"" NVENC_LIBNAME "\" was not found.");
     nvenc_available = FALSE;
   }
 
   if (!gst_cuvid_load_library (api_major_ver, api_minor_ver)) {
     GST_WARNING ("Failed to load nvdec library version %u.%u", api_major_ver,
         api_minor_ver);
+    gst_plugin_add_status_warning (plugin,
+        "NVDEC library \"" NVCUVID_LIBNAME "\" was not found.");
     nvdec_available = FALSE;
   }
 
@@ -149,6 +171,10 @@ plugin_init (GstPlugin * plugin)
 
     /* to abort if GST_CUDA_CRITICAL_ERRORS is configured */
     gst_cuda_result (CUDA_ERROR_NO_DEVICE);
+
+    gst_plugin_add_status_error (plugin,
+        N_("Unable to initialize CUDA library."));
+
     return TRUE;
   }
 
@@ -158,10 +184,19 @@ plugin_init (GstPlugin * plugin)
     CuGetErrorString (cuda_ret, &err_desc);
     GST_ERROR ("No available device, cuDeviceGetCount ret: 0x%x: %s %s",
         (int) cuda_ret, err_name, err_desc);
+
+    gst_plugin_add_status_warning (plugin,
+        N_("No NVIDIA graphics cards detected!"));
+
     return TRUE;
   }
 
   have_nvrtc = check_runtime_compiler ();
+  if (!have_nvrtc) {
+    gst_plugin_add_status_info (plugin,
+        "CUDA runtime compilation library \"" NVRTC_LIBNAME "\" was not found, "
+        "check CUDA toolkit package installation");
+  }
 
   for (i = 0; i < dev_count; i++) {
     GstCudaContext *context = gst_cuda_context_new (i);